LLMS_Product::is_purchasable()

Determine if the product is purchasable.


Description Description

At least one gateway must be enabled and at least one access plan must exist. If the product is a course, additionally checks to ensure course enrollment is open and has capacity.


Top ↑

Return Return

(bool)


Top ↑

Source Source

File: includes/models/model.llms.product.php

	public function is_purchasable() {

		// Default to false.
		$purchasable = false;

		// If the product doesn't have any purchase restrictions, make sure we have a purchasable plan & active gateways.
		if ( ! $this->has_restrictions() ) {
			$gateways    = llms()->payment_gateways();
			$purchasable = ( $this->get_access_plans( false, false ) && $gateways->has_gateways( true ) );
		}

		/**
		 * Filter whether the product is purchasable.
		 *
		 * @since Unknown
		 *
		 * @param bool         $purchasable Whether the product `$product` is purchasable.
		 * @param LLMS_Product $product     The LLMS_Product instance.
		 */
		return apply_filters( 'llms_product_is_purchasable', $purchasable, $this );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.38.0 Use has_restrictions() to determine if the product has additional restrictions.
3.25.2 Unknown.
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.