LLMS_Access_Plan::is_on_sale()
Determine if a plan is *currently* on sale
Return Return
(boolean)
Source Source
File: includes/models/model.llms.access.plan.php
775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 | $ret = false; if ( llms_parse_bool( $this ->get( 'on_sale' ) ) ) { $now = llms_current_time( 'timestamp' ); $start = $this ->get( 'sale_start' ); $end = $this ->get( 'sale_end' ); // Add times if the values exist (start of day & end of day). $start = ( $start ) ? strtotime ( $start . ' 00:00:00' ) : $start ; $end = ( $end ) ? strtotime ( '+1 day' , strtotime ( $end . ' 00:00:00' ) ) : $end ; // No dates, the product is indefinitely on sale. if ( ! $start && ! $end ) { $ret = true; // Start and end. } elseif ( $start && $end ) { $ret = ( $now < $end && $now > $start ); // Only start. } elseif ( $start && ! $end ) { $ret = ( $now > $start ); // Only end. } elseif ( ! $start && $end ) { $ret = ( $now < $end ); } } return apply_filters( 'llms_plan_is_on_sale' , $ret , $this ); } |
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |