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


Top ↑

Return Return

(bool)


Top ↑

Source Source

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

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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;
}


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.