PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 2.3.0
Subscriptions for WooCommerce with Stripe Recurring Payments v2.3.0
2.4.0 2.3.0 2.2.0 2.1.0 2.0.0 1.11.2 1.11.1 1.11.0 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.6 1.9.5 trunk 1.3.0 1.3.1 1.3.2 1.4.0 All 65 releases
← All changes | includes/Illuminate/Helper.php +30 -2 2.2.0 → 2.3.0 View file →
@@ -89,8 +89,22 @@
89 89 return isset( $statuses[ $status ] ) ? $statuses[ $status ] : '';
90 90 }
91 91
92 92 /**
93 + * Whether a subscription in this status still has a payment ahead.
94 + *
95 + * Cancelling or expiring keeps `_subscrpt_next_date` (the cancellation sweep
96 + * and reactivation read it), so views check the status before showing it.
97 + *
98 + * @param string $status Status.
99 + *
100 + * @return bool
101 + */
102 + public static function has_next_payment( $status ) {
103 + return ! in_array( $status, array( 'cancelled', 'expired' ), true );
104 + }
105 +
106 + /**
93 107 * Generate start date
94 108 *
95 109 * @param null|string $trial Trial.
96 110 *
@@ -998,9 +1012,9 @@
998 1012 array(
999 1013 'trial_status' => ! is_null( $cart_subscription['trial'] ),
1000 1014 'start_date' => self::start_date( $cart_subscription['trial'] ),
1001 1015 'next_date' => self::next_date( ( $cart_subscription['time'] ?? 1 ) . ' ' . $cart_subscription['type'], $cart_subscription['trial'] ),
1002 - 'can_user_cancel' => $cart_item['data']->get_meta( '_subscrpt_user_cancel' ),
1016 + 'can_user_cancel' => self::can_user_cancel( $cart_item['data']->get_meta( '_subscrpt_user_cancel' ) ) ? 'yes' : 'no',
1003 1017 'max_no_payment' => ! empty( $cart_item['subscrpt_max_no_payment'] )
1004 1018 ? (int) $cart_item['subscrpt_max_no_payment']
1005 1019 : $cart_item['data']->get_meta( '_subscrpt_max_no_payment' ),
1006 1020 // Exact plan total for split items (the entered price the split is
@@ -1389,8 +1403,22 @@
1389 1403 update_comment_meta( $comment_id, '_subscrpt_activity_type', 'renewal_order' );
1390 1404 }
1391 1405
1392 1406 /**
1407 + * Whether a stored `_subscrpt_user_cancel` value lets the customer cancel.
1408 + *
1409 + * Only an explicit "no" forbids it. An empty value means the option was never
1410 + * saved - plan-connected products never store it - and the product form shows
1411 + * "Yes" for that case, so the answer here has to be yes too.
1412 + *
1413 + * @param mixed $value Stored meta value.
1414 + * @return bool
1415 + */
1416 + public static function can_user_cancel( $value ): bool {
1417 + return 'no' !== $value;
1418 + }
1419 +
1420 + /**
1393 1421 * Get a subscription data.
1394 1422 *
1395 1423 * @param int $subscription_id Subscription ID.
1396 1424 * @return array|null
@@ -1419,9 +1447,9 @@
1419 1447
1420 1448 $order_id = get_post_meta( $subscription_id, '_subscrpt_order_id', true );
1421 1449 $order_item_id = get_post_meta( $subscription_id, '_subscrpt_order_item_id', true );
1422 1450
1423 - $can_user_cancel = in_array( get_post_meta( $subscription_id, '_subscrpt_user_cancel', true ), array( 1, '1', 'true', 'yes' ), true );
1451 + $can_user_cancel = self::can_user_cancel( get_post_meta( $subscription_id, '_subscrpt_user_cancel', true ) );
1424 1452
1425 1453 $start_datetime = (int) get_post_meta( $subscription_id, '_subscrpt_start_date', true );
1426 1454 $start_date = ! empty( $start_datetime ) ? gmdate( DATE_RFC2822, $start_datetime ) : null;
1427 1455