Skip to content

Commit 72507f9

Browse files
committed
Declare gateway supported features so PayPal shows on block cart/checkout for multi-subscription carts
1 parent d8538b7 commit 72507f9

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

modules/ppcp-blocks/resources/js/checkout-block.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,23 @@ initCartFragmentSync();
2727

2828
let paypalScriptPromise = null;
2929

30-
const features = [ 'products' ];
30+
// Mirror the gateway's server-side (mode-aware) `supports` so WooCommerce Blocks
31+
// does not filter the PayPal method out when the cart requires a feature the
32+
// gateway actually supports — notably `multiple_subscriptions` when the cart holds
33+
// two or more subscriptions. Falls back to the previous hard-coded list.
34+
const features = Array.isArray( config.supportedFeatures )
35+
? [ ...config.supportedFeatures ]
36+
: [ 'products' ];
3137
let blockEnabled = true;
3238

3339
if ( cartHasSubscriptionProducts( config.scriptData ) ) {
3440
// Show the button only for subscription carts PayPal can process
3541
// (shared rule used by the classic cart and mini-cart as well).
3642
blockEnabled = paypalSubscriptionButtonAllowed( config.scriptData );
3743

38-
features.push( 'subscriptions' );
44+
if ( ! Array.isArray( config.supportedFeatures ) ) {
45+
features.push( 'subscriptions' );
46+
}
3947
}
4048

4149
if ( blockEnabled ) {

modules/ppcp-blocks/src/PayPalPaymentMethod.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ public function get_payment_method_data() {
259259
'placeOrderButtonText' => $this->place_order_button_text,
260260
'placeOrderButtonDescription' => $this->place_order_button_description,
261261
'enabledFundingSources' => $funding_sources,
262+
// The gateway's (mode-aware) supported features, so the block can
263+
// declare them to WooCommerce Blocks and not be filtered out when the
264+
// cart requires one (e.g. `multiple_subscriptions` for 2+ subscriptions).
265+
'supportedFeatures' => array_values( (array) $this->gateway->supports ),
262266
'ajax' => array(
263267
'update_shipping' => array(
264268
'endpoint' => WC_AJAX::get_endpoint( UpdateShippingEndpoint::ENDPOINT ),

0 commit comments

Comments
 (0)