PluginProbe
Tiered Pricing Table for WooCommerce / 8.0.2
Tiered Pricing Table for WooCommerce v8.0.2
8.0.2 7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 All 91 releases
← All changes | freemius/includes/entities/class-fs-subscription.php +136 -114 2.3.0 → 8.0.2 View file →
@@ -1,125 +1,147 @@
1 1 <?php
2 - /**
3 - * @package Freemius
4 - * @copyright Copyright (c) 2015, Freemius, Inc.
5 - * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6 - * @since 1.0.9
7 - */
2 + /**
3 + * @package Freemius
4 + * @copyright Copyright (c) 2015, Freemius, Inc.
5 + * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6 + * @since 1.0.9
7 + */
8 8
9 - if ( ! defined( 'ABSPATH' ) ) {
10 - exit;
11 - }
9 + if ( ! defined( 'ABSPATH' ) ) {
10 + exit;
11 + }
12 12
13 - class FS_Subscription extends FS_Entity {
13 + class FS_Subscription extends FS_Entity {
14 14
15 - #region Properties
15 + #region Properties
16 16
17 - /**
18 - * @var number
19 - */
20 - public $user_id;
21 - /**
22 - * @var number
23 - */
24 - public $install_id;
25 - /**
26 - * @var number
27 - */
28 - public $plan_id;
29 - /**
30 - * @var number
31 - */
32 - public $license_id;
33 - /**
34 - * @var float
35 - */
36 - public $total_gross;
37 - /**
38 - * @var float
39 - */
40 - public $amount_per_cycle;
41 - /**
42 - * @var int # of months
43 - */
44 - public $billing_cycle;
45 - /**
46 - * @var float
47 - */
48 - public $outstanding_balance;
49 - /**
50 - * @var int
51 - */
52 - public $failed_payments;
53 - /**
54 - * @var string
55 - */
56 - public $gateway;
57 - /**
58 - * @var string
59 - */
60 - public $external_id;
61 - /**
62 - * @var string|null
63 - */
64 - public $trial_ends;
65 - /**
66 - * @var string|null Datetime of the next payment, or null if cancelled
67 - */
68 - public $next_payment;
69 - /**
70 - * @var string|null
71 - */
72 - public $vat_id;
73 - /**
74 - * @var string Two characters country code
75 - */
76 - public $country_code;
17 + /**
18 + * @var number
19 + */
20 + public $user_id;
21 + /**
22 + * @var number
23 + */
24 + public $install_id;
25 + /**
26 + * @var number
27 + */
28 + public $plan_id;
29 + /**
30 + * @var number
31 + */
32 + public $license_id;
33 + /**
34 + * @var float
35 + */
36 + public $total_gross;
37 + /**
38 + * @var float
39 + */
40 + public $amount_per_cycle;
41 + /**
42 + * @var int # of months
43 + */
44 + public $billing_cycle;
45 + /**
46 + * @var float
47 + */
48 + public $outstanding_balance;
49 + /**
50 + * @var int
51 + */
52 + public $failed_payments;
53 + /**
54 + * @var string
55 + */
56 + public $gateway;
57 + /**
58 + * @var string
59 + */
60 + public $external_id;
61 + /**
62 + * @var string|null
63 + */
64 + public $trial_ends;
65 + /**
66 + * @var string|null Datetime of the next payment, or null if cancelled.
67 + */
68 + public $next_payment;
69 + /**
70 + * @since 2.3.1
71 + *
72 + * @var string|null Datetime of the cancellation.
73 + */
74 + public $canceled_at;
75 + /**
76 + * @var string|null
77 + */
78 + public $vat_id;
79 + /**
80 + * @var string Two characters country code
81 + */
82 + public $country_code;
77 83
78 - #endregion Properties
84 + #endregion Properties
79 85
80 - /**
81 - * @param object|bool $subscription
82 - */
83 - function __construct( $subscription = false ) {
84 - parent::__construct( $subscription );
85 - }
86 + /**
87 + * @param object|bool $subscription
88 + */
89 + function __construct( $subscription = false ) {
90 + parent::__construct( $subscription );
91 + }
86 92
87 - static function get_type() {
88 - return 'subscription';
89 - }
93 + static function get_type() {
94 + return 'subscription';
95 + }
90 96
91 - /**
92 - * Check if subscription is active.
93 - *
94 - * @author Vova Feldman (@svovaf)
95 - * @since 1.0.9
96 - *
97 - * @return bool
98 - */
99 - function is_active() {
100 - return ! empty( $this->next_payment ) &&
101 - ( strtotime( $this->next_payment ) > WP_FS__SCRIPT_START_TIME );
102 - }
97 + /**
98 + * Check if subscription is active.
99 + *
100 + * @author Vova Feldman (@svovaf)
101 + * @since 1.0.9
102 + *
103 + * @return bool
104 + */
105 + function is_active() {
106 + if ( $this->is_canceled() ) {
107 + return false;
108 + }
103 109
104 - /**
105 - * Subscription considered to be new without any payments
106 - * if the next payment should be made within less than 24 hours
107 - * from the subscription creation.
108 - *
109 - * @author Vova Feldman (@svovaf)
110 - * @since 1.0.9
111 - *
112 - * @return bool
113 - */
114 - function is_first_payment_pending() {
115 - return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->next_payment ) - strtotime( $this->created ) );
116 - }
110 + return (
111 + ! empty( $this->next_payment ) &&
112 + strtotime( $this->next_payment ) > WP_FS__SCRIPT_START_TIME
113 + );
114 + }
117 115
118 - /**
119 - * @author Vova Feldman (@svovaf)
120 - * @since 1.1.7
121 - */
122 - function has_trial() {
123 - return ! is_null( $this->trial_ends );
124 - }
125 - }
116 + /**
117 + * @author Vova Feldman (@svovaf)
118 + * @since 2.3.1
119 + *
120 + * @return bool
121 + */
122 + function is_canceled() {
123 + return ! is_null( $this->canceled_at );
124 + }
125 +
126 + /**
127 + * Subscription considered to be new without any payments
128 + * if the next payment should be made within less than 24 hours
129 + * from the subscription creation.
130 + *
131 + * @author Vova Feldman (@svovaf)
132 + * @since 1.0.9
133 + *
134 + * @return bool
135 + */
136 + function is_first_payment_pending() {
137 + return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->next_payment ) - strtotime( $this->created ) );
138 + }
139 +
140 + /**
141 + * @author Vova Feldman (@svovaf)
142 + * @since 1.1.7
143 + */
144 + function has_trial() {
145 + return ! is_null( $this->trial_ends );
146 + }
147 + }