Skip to content

Insonsistent PayPal button behavior for subscriptions on cart (6639)#4542

Merged
Dinamiko merged 2 commits into
dev/developfrom
dev/PCP-6639-insonsistent-pay-pal-button-behavior-for-subscriptions-on-cart
Jul 21, 2026
Merged

Insonsistent PayPal button behavior for subscriptions on cart (6639)#4542
Dinamiko merged 2 commits into
dev/developfrom
dev/PCP-6639-insonsistent-pay-pal-button-behavior-for-subscriptions-on-cart

Conversation

@Dinamiko

Copy link
Copy Markdown
Collaborator

The PayPal button behaved inconsistently for subscription carts. On the block cart it showed for one subscription product but appeared then disappeared when a second (free-trial) one was added; on the classic cart the opposite happened (hidden for one, shown for two). Separately, emptying the block cart left the mini-cart still showing products.

PR Changes

  • Centralized the button-display rule into a single shared decision SubscriptionHelper::paypal_subscription_button_allowed() (PHP) and paypalSubscriptionButtonAllowed() (JS), exposed as one subscription_button_allowed server flag. It covers both modes: PayPal Subscriptions requires a single item with a PayPal plan; vaulting requires vaulting enabled; non-subscription carts are always allowed.
  • All three cart paths (classic, block, mini-cart) now consume this one rule, so they behave identically.
  • The button is decided before rendering and the wrapper is withheld server-side for unsupported carts (no flicker), and truly hidden rather than greyed.
  • The mini-cart now subscribes to wc/store/cart, clearing the button when the block cart empties and re-applying the same subscription rule.

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can be previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

🔗 Test this pull request with WordPress Playground

What's included:

  • ✅ WordPress (latest)
  • ✅ WooCommerce (latest)
  • ✅ PayPal Payments plugin v4.1.1-pr4542-29812514245-g6caf077 (built from this PR)

Login credentials:

  • Username: admin
  • Password: password

Plugin Details:

  • Version: 4.1.1-pr4542-29812514245-g6caf077
  • Commit: 5207862
  • Artifact: woocommerce-paypal-payments-4.1.1-pr4542-29812514245-g6caf077

💡 The demo environment resets each time you refresh. Perfect for testing!

🔄 This link updates automatically with each new commit to the PR.

⚠️ This URL is valid for 30 days from when this comment was last updated.


🤖 Auto-generated for commit 5207862 • Last updated: 2026-07-21T08:02:43.087Z

@Narek13 Narek13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this. Left a small suggestion

debounce( () => {
this._handleStoreCartChange();
}, 300 )
);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fires on every store change, not just wc/store/cart.
subscribe() accepts an optional storeNameOrDescriptor second argument to scope the listener to one store like wp.data.subscribe(callback, 'wc/store/cart')

@Dinamiko
Dinamiko merged commit 27c1895 into dev/develop Jul 21, 2026
13 checks passed
@Dinamiko
Dinamiko deleted the dev/PCP-6639-insonsistent-pay-pal-button-behavior-for-subscriptions-on-cart branch July 21, 2026 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants