PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 2.4.0
Subscriptions for WooCommerce with Stripe Recurring Payments v2.4.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 +34 -4 2.0.0 → 2.4.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
@@ -1123,11 +1137,13 @@
1123 1137 $new_order->calculate_totals();
1124 1138 $new_order->save();
1125 1139
1126 1140 if ( ! is_admin() && function_exists( 'wc_add_notice' ) && WC()->session ) {
1127 - $message = 'Renewal Order(#' . $new_order->get_id() . ') Created.';
1141 + /* translators: %d: renewal order ID. */
1142 + $message = sprintf( __( 'Renewal order #%d created.', 'subscription' ), $new_order->get_id() );
1128 1143 if ( $new_order->has_status( 'pending' ) ) {
1129 - $message .= 'Please <a href="' . $new_order->get_checkout_payment_url() . '">Pay now</a>';
1144 + /* translators: %s: URL of the order payment page. */
1145 + $message .= ' ' . sprintf( __( 'Please <a href="%s">pay now</a>.', 'subscription' ), esc_url( $new_order->get_checkout_payment_url() ) );
1130 1146 }
1131 1147 wc_add_notice( $message, 'success' );
1132 1148 }
1133 1149
@@ -1389,8 +1405,22 @@
1389 1405 update_comment_meta( $comment_id, '_subscrpt_activity_type', 'renewal_order' );
1390 1406 }
1391 1407
1392 1408 /**
1409 + * Whether a stored `_subscrpt_user_cancel` value lets the customer cancel.
1410 + *
1411 + * Only an explicit "no" forbids it. An empty value means the option was never
1412 + * saved - plan-connected products never store it - and the product form shows
1413 + * "Yes" for that case, so the answer here has to be yes too.
1414 + *
1415 + * @param mixed $value Stored meta value.
1416 + * @return bool
1417 + */
1418 + public static function can_user_cancel( $value ): bool {
1419 + return 'no' !== $value;
1420 + }
1421 +
1422 + /**
1393 1423 * Get a subscription data.
1394 1424 *
1395 1425 * @param int $subscription_id Subscription ID.
1396 1426 * @return array|null
@@ -1419,9 +1449,9 @@
1419 1449
1420 1450 $order_id = get_post_meta( $subscription_id, '_subscrpt_order_id', true );
1421 1451 $order_item_id = get_post_meta( $subscription_id, '_subscrpt_order_item_id', true );
1422 1452
1423 - $can_user_cancel = in_array( get_post_meta( $subscription_id, '_subscrpt_user_cancel', true ), array( 1, '1', 'true', 'yes' ), true );
1453 + $can_user_cancel = self::can_user_cancel( get_post_meta( $subscription_id, '_subscrpt_user_cancel', true ) );
1424 1454
1425 1455 $start_datetime = (int) get_post_meta( $subscription_id, '_subscrpt_start_date', true );
1426 1456 $start_date = ! empty( $start_datetime ) ? gmdate( DATE_RFC2822, $start_datetime ) : null;
1427 1457