|
@@ -16,7 +16,7 @@ discard block |
|
|
block discarded – undo |
|
16
|
16
|
*/ |
|
17
|
17
|
public static function init() { |
|
18
|
18
|
// Overrides the price of the subscription for sign up fee and/or trial on the 'wcsatt_cart_item' filter. |
|
19
|
|
- add_filter( 'wcsatt_cart_item', __CLASS__ . '::update_cart_item_sub_data', 10, 1 ); |
|
|
19
|
+ add_filter('wcsatt_cart_item', __CLASS__.'::update_cart_item_sub_data', 10, 1); |
|
20
|
20
|
} |
|
21
|
21
|
|
|
22
|
22
|
/** |
|
@@ -28,38 +28,38 @@ discard block |
|
|
block discarded – undo |
|
28
|
28
|
* @param array $cart_item |
|
29
|
29
|
* @return array |
|
30
|
30
|
*/ |
|
31
|
|
- public static function update_cart_item_sub_data( $cart_item ) { |
|
32
|
|
- $active_scheme = WCS_ATT_Schemes::get_active_subscription_scheme( $cart_item ); |
|
|
31
|
+ public static function update_cart_item_sub_data($cart_item) { |
|
|
32
|
+ $active_scheme = WCS_ATT_Schemes::get_active_subscription_scheme($cart_item); |
|
33
|
33
|
|
|
34
|
|
- $subscription_prices = WCS_ATT_Scheme_Prices::get_active_subscription_scheme_prices( $cart_item, $active_scheme ); |
|
|
34
|
+ $subscription_prices = WCS_ATT_Scheme_Prices::get_active_subscription_scheme_prices($cart_item, $active_scheme); |
|
35
|
35
|
|
|
36
|
|
- if ( $active_scheme && $cart_item['data']->is_converted_to_sub == 'yes' ) { |
|
|
36
|
+ if ($active_scheme && $cart_item['data']->is_converted_to_sub == 'yes') { |
|
37
|
37
|
|
|
38
|
38
|
// Subscription Price |
|
39
|
39
|
$price = $cart_item['data']->subscription_price; |
|
40
|
40
|
|
|
41
|
41
|
// Is there a sign up fee? |
|
42
|
|
- $sign_up_fee = isset( $subscription_prices['sign_up_fee'] ) ? $subscription_prices['sign_up_fee'] : ''; |
|
|
42
|
+ $sign_up_fee = isset($subscription_prices['sign_up_fee']) ? $subscription_prices['sign_up_fee'] : ''; |
|
43
|
43
|
|
|
44
|
44
|
// Checks if the cart item is a supported bundle type child. |
|
45
|
|
- $container_key = WCS_ATT_Integrations::has_bundle_type_container( $cart_item ); |
|
|
45
|
+ $container_key = WCS_ATT_Integrations::has_bundle_type_container($cart_item); |
|
46
|
46
|
|
|
47
|
47
|
// If the cart item is a child item then reset the sign-up fee. |
|
48
|
|
- if ( false !== $container_key ) { $sign_up_fee = ''; } |
|
|
48
|
+ if (false !== $container_key) { $sign_up_fee = ''; } |
|
49
|
49
|
|
|
50
|
50
|
// Put both the subscription price and the sign-up fee together. |
|
51
|
|
- $new_price = round( $price + $sign_up_fee, wc_get_price_decimals() ); |
|
|
51
|
+ $new_price = round($price + $sign_up_fee, wc_get_price_decimals()); |
|
52
|
52
|
|
|
53
|
|
- if ( $sign_up_fee > 0 ) { |
|
|
53
|
+ if ($sign_up_fee > 0) { |
|
54
|
54
|
$cart_item['data']->initial_amount = $new_price; |
|
55
|
55
|
$cart_item['data']->subscription_sign_up_fee = $sign_up_fee; |
|
56
|
56
|
} |
|
57
|
57
|
|
|
58
|
|
- $trial_length = isset( $subscription_prices['trial_length'] ) ? $subscription_prices['trial_length'] : 0; |
|
59
|
|
- $trial_period = isset( $subscription_prices['trial_period'] ) ? $subscription_prices['trial_period'] : ''; |
|
|
58
|
+ $trial_length = isset($subscription_prices['trial_length']) ? $subscription_prices['trial_length'] : 0; |
|
|
59
|
+ $trial_period = isset($subscription_prices['trial_period']) ? $subscription_prices['trial_period'] : ''; |
|
60
|
60
|
|
|
61
|
61
|
// If a trial length is more than zero then set the conditions for the cart. |
|
62
|
|
- if ( $trial_length > 0 ) { |
|
|
62
|
+ if ($trial_length > 0) { |
|
63
|
63
|
$cart_item['data']->subscription_trial_length = $trial_length; |
|
64
|
64
|
$cart_item['data']->subscription_trial_period = $trial_period; |
|
65
|
65
|
} else { |