-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure the BNPL PMME doesn't appear on carts with subscriptions #9774
Conversation
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
Size Change: 0 B Total Size: 1.33 MB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that we already perform the check against subscription products early in the PMME initialization, which I initially thought would cover the use case addressed by this PR.
However, it turns out that global $product
is null
, so the product type isn’t recognized as expected. To avoid introducing workarounds within the init()
method, do you think it might make sense to integrate:
WC_Subscriptions_Cart::cart_contains_subscription();
Additionally, we could check if this type of subscription detection covers the use cases currently handled by WC_Subscriptions_Product::is_subscription( $product )
. If it does, we might consider fully replacing it.
By properly blocking the execution of init()
for PMME with subscriptions, we’ll also eliminate the redundant animation currently present:
Screen.Recording.2024-11-21.at.11.03.56.mov
What do you think of this approach?
Thanks @timur27! I was actually hoping to use something like the function you've mentioned,
This is because we're on the cart page in this case. That check is for product pages. We're initializing here for both scenarios, cart and product. I don't see a way around checking the page we're on here. What's more, there's a sneaky scenario where there might be a subscription in the cart, but the shopper is viewing a non-subscription product. In that case, With the above in mind, it's better to do these checks before the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you! 🚢
Fixes #9772
Changes proposed in this Pull Request
In an effort to fix an issue on PDPs, I made a change that caused the PMME to appear on the cart page when subscription products are in the cart. In fact, the cart page should indeed use
get_payment_method_ids_enabled_at_checkout()
which is a filtered list of enabled payment methods. The PDP still needs all enabled payment methods however, to solve the issue mentioned above. This PR adds adds some branching to ensure both page have the list of BNPL payment methods it needs.Testing instructions
npm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge