fix(modal-checkout): suppress WooPayments express checkout when Stripe is active#2304
fix(modal-checkout): suppress WooPayments express checkout when Stripe is active#2304wil-gerken wants to merge 6 commits intotrunkfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the modal checkout’s WooPayments settings filter to avoid rendering duplicate express checkout (Apple Pay / Google Pay) buttons when both Stripe and WooPayments are active.
Changes:
- Disables WooPay (platform/hosted checkout) within modal checkout (existing behavior, now explicitly documented).
- When Stripe express checkout is enabled, removes WooPayments’
payment_requestmethod fromexpress_checkout_checkout_methodsto prevent duplicated express buttons in the modal.
Comments suppressed due to low confidence (1)
includes/class-modal-checkout.php:483
- The inline comment references
class-woocommerce-gateway-stripe.php, but that file doesn’t exist anywhere in this repository. Could you update the reference to the actual internal class/file in this codebase (or link to the upstream WooCommerce Stripe gateway source) so future readers can follow it?
// Stripe is preferred: Newspack already manages its express checkout behavior (see
// class-woocommerce-gateway-stripe.php), and WooPayments is already partially filtered
// above (platform_checkout). WooPayments is suppressed, not the reverse.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
includes/class-modal-checkout.php:486
- Relying on
class_exists( 'WC_Stripe' )here can fail depending on active plugin load order: if WooPayments reads its settings before the Stripe plugin has loaded its classes,class_exists()will be false and the duplicate express buttons won’t be suppressed. Consider detecting Stripe by checking whether the Stripe plugin is active (and ideally whether the gateway is enabled inwoocommerce_stripe_settings['enabled']) rather than checking for a loaded class.
if ( class_exists( 'WC_Stripe' ) ) {
$stripe_settings = get_option( 'woocommerce_stripe_settings', [] );
if ( isset( $stripe_settings['express_checkout'] ) && 'yes' === $stripe_settings['express_checkout'] ) {
includes/class-modal-checkout.php:483
- This comment references
newspack-plugin/includes/plugins/class-woocommerce-gateway-stripe.php, but that path/file doesn’t exist in this repository, so it’s not actionable for future maintainers. Please update the reference to a relevant location in this repo (or remove the parenthetical) to avoid confusion.
// Stripe is preferred: Newspack already manages its express checkout behavior (see
// newspack-plugin/includes/plugins/class-woocommerce-gateway-stripe.php), and WooPayments
// is already partially filtered above (platform_checkout). WooPayments is suppressed, not the reverse.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
includes/class-modal-checkout.php:483
- The inline comment references
newspack-plugin/includes/plugins/class-woocommerce-gateway-stripe.php, but that path doesn’t exist in this repository, making it hard for reviewers to follow the trail. Consider replacing it with a stable reference (e.g., a GitHub URL) or rewording to describe the relevant integration without pointing at a non-local path.
// Stripe is preferred: Newspack already manages its express checkout behavior (see
// newspack-plugin/includes/plugins/class-woocommerce-gateway-stripe.php), and WooPayments
// is already partially filtered above (platform_checkout). WooPayments is suppressed, not the reverse.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Hmm, this isn't working for me but I'm not sure if it's because of my specific testing site environment. When I log the output of get_option( 'woocommerce_stripe_settings', [] ); I see 'enabled' => 'yes' and 'express_checkout' => 'yes' but I don't see an express_checkout_checkout_methods key on the settings array. Subsequently, I still see the double express checkout buttons displayed in modal checkout.
It's possible the settings schema has changed in recent versions of the woocommerce-gateway-stripe plugin. I'm running v10.5.2—what version do you have?
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…bsent from DB Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
d548ef5 to
873a75d
Compare
Sorry for the slow reply on this, and thanks for catching it! The issue was that The original This revised fix initializes from the WooPayments default when the key is absent, so the suppression now applies regardless of the database state. I was able to reproduce your exact scenario locally by removing the key, and confirmed that the fix works in both cases: when the key is present and when it is absent. Could you please take another look when you get a chance? |
dkoo
left a comment
There was a problem hiding this comment.
Strangely, it's still not working for me! I verified that the settings are filtered by the filter_woocommerce_payments_settings callback with the expected values, too.
If I change the filtered value to the inline suggestion, it does successfully remove the WooPay express checkout buttons. However, I'm not sure if this might have any unintended side effects since it's a much farther-reaching settings change.
| // Always write the key — if it's absent from the DB, WooPayments falls back to its | ||
| // hardcoded default (['payment_request', 'woopay', 'amazon_pay']), bypassing this filter. | ||
| $methods = (array) ( $settings['express_checkout_checkout_methods'] ?? [ 'payment_request', 'woopay', 'amazon_pay' ] ); | ||
| $settings['express_checkout_checkout_methods'] = array_values( array_diff( $methods, [ 'payment_request' ] ) ); |
There was a problem hiding this comment.
| // Always write the key — if it's absent from the DB, WooPayments falls back to its | |
| // hardcoded default (['payment_request', 'woopay', 'amazon_pay']), bypassing this filter. | |
| $methods = (array) ( $settings['express_checkout_checkout_methods'] ?? [ 'payment_request', 'woopay', 'amazon_pay' ] ); | |
| $settings['express_checkout_checkout_methods'] = array_values( array_diff( $methods, [ 'payment_request' ] ) ); | |
| $settings['payment_request'] = 'no'; |
All Submissions:
Changes proposed in this Pull Request:
When both Stripe and WooPayments are active with express checkout enabled, the modal checkout
renders two sets of Apple Pay / Google Pay buttons — one from each gateway.
The fix extends the existing
filter_woocommerce_payments_settings()filter (which alreadysuppresses WooPay in the modal) to also remove
payment_requestfrom WooPayments'express_checkout_checkout_methodswhen Stripe is active, and its express checkout is enabled.Closes
NPPM-2652.How to test the changes in this Pull Request:
Before applying this PR:
woocommerce-gateway-stripeandwoocommerce-paymentswith express checkoutenabled on each.
Apply this PR:
"Or" divider and the card form below.
Regression Check:
WooPayments' express checkout buttons appear normally. This fix should only suppress when
both gateways are active.
Other information: