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.
Return Return
(string[]) An array of strings describing the restrictions placed on the product.
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 );
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 3.38.0 | Introduced. |