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/Frontend/Cart.php +15 -1 2.0.0 → 2.3.0 View file →
@@ -86,8 +86,22 @@
86 86 * @param int $product_id Product Id.
87 87 * @return array
88 88 */
89 89 public function validate_cart_items( $product_id ) {
90 + /**
91 + * Filters whether the cart may hold more than one subscription, or a
92 + * subscription alongside a normal product, bypassing the restriction below.
93 + *
94 + * @param bool $allow Whether to allow it. Default false.
95 + * @param int $product_id Product being added to the cart.
96 + */
97 + if ( apply_filters( 'subscrpt_allow_multiple_subscriptions_in_cart', false, $product_id ) ) {
98 + return [
99 + 'failed' => false,
100 + 'error_notice' => null,
101 + ];
102 + }
103 +
90 104 $cart_items = WC()->cart->cart_contents;
91 105
92 106 $product = Subscription::get_subs_product( $product_id );
93 107
@@ -369,9 +383,9 @@
369 383 'recurring_limit' => $price_data['recurring_limit'],
370 384 'time' => $time,
371 385 'type' => $type,
372 386 'description' => $description,
373 - 'can_user_cancel' => $cart_item['data']->get_meta( '_subscrpt_user_cancel' ),
387 + 'can_user_cancel' => Helper::can_user_cancel( $cart_item['data']->get_meta( '_subscrpt_user_cancel' ) ) ? 'yes' : 'no',
374 388 'max_no_payment' => ! empty( $cart_item['subscrpt_max_no_payment'] )
375 389 ? (int) $cart_item['subscrpt_max_no_payment']
376 390 : $cart_item['data']->get_meta( '_subscrpt_max_no_payment' ),
377 391 'split_total' => isset( $cart_item['subscrpt_split_total'] ) ? (float) $cart_item['subscrpt_split_total'] : null,