LLMS_Product::get_restrictions()

Retrieve a list of restrictions on the product.


Description Description

Restrictions are used to in conjunction with "is_purchasable()" to determine if purchase/enrollment should be allowed for a given product.

Restrictions in the core currently only exist on courses:

  • Enrollment time period.
  • Student capacity.

Top ↑

Return Return

(string[]) An array of strings describing the restrictions placed on the product.


Top ↑

Source Source

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

	public function get_restrictions() {

		$restrictions = array();

		if ( 'course' === $this->get( 'type' ) ) {

			$course = new LLMS_Course( $this->get( 'id' ) );

			// Is the course enrollment period open?
			if ( ! $course->is_enrollment_open() ) {
				$restrictions[] = 'enrollment_period';
			}

			// Does the course have capacity?
			if ( ! $course->has_capacity() ) {
				$restrictions[] = 'student_capacity';
			}
		}

		/**
		 * Filter the product's restrictions.
		 *
		 * @since 6.8.0
		 *
		 * @param string[]     $restrictions An array of strings describing the restrictions placed on the product.
		 * @param LLMS_Product $product      The LLMS_Product object.
		 */
		return apply_filters( 'llms_product_get_restrictions', $restrictions, $this );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.38.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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