LLMS_Coupon::applies_to_plan( int|obj $plan_id )
Determine if the coupon can be applied to an access plan
Parameters Parameters
- $plan_id
-
(int|obj) (Required) WP Post ID of the LLMS Access Plan or an instance of LLMS_Access_Plan
Return Return
(bool)
Source Source
File: includes/models/model.llms.coupon.php
public function applies_to_plan( $plan_id ) {
if ( $plan_id instanceof LLMS_Access_Plan ) {
$plan = $plan_id;
} else {
$plan = new LLMS_Access_Plan( $plan_id );
}
// Check if it can be applied to the plan's product first.
if ( ! $this->applies_to_product( $plan->get( 'product_id' ) ) ) {
return false;
}
// If the coupon can only be used with one-time plans and the plan is recurring.
if ( 'one-time' === $this->get( 'plan_type' ) && $plan->is_recurring() ) {
return false;
}
return true;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |