LLMS_Product::is_purchasable()

Determine if the product is purchasable 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


Description Description


Return Return

(boolean)


Top ↑

Source Source

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

	public function is_purchasable() {

		// Default to true.
		$ret = true;

		// Courses must have open enrollment & available capacity.
		if ( 'course' === $this->get( 'type' ) ) {

			$course = new LLMS_Course( $this->get( 'id' ) );
			$ret    = ( $course->is_enrollment_open() && $course->has_capacity() );

		}

		// if we're still true, make sure we have a purchasable plan & active gateways.
		if ( $ret ) {
			$gateways = LLMS()->payment_gateways();
			$ret      = ( $this->get_access_plans( false, false ) && $gateways->has_gateways( true ) );
		}

		return apply_filters( 'llms_product_is_purchasable', $ret, $this );

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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





Permalink: