Skip to content

Conversation

@malithsen
Copy link
Contributor

@malithsen malithsen commented Nov 3, 2025

Fixes STRIPE-743

Changes proposed in this Pull Request:

This PR improves the compatibility between Stripe Express Checkout (ECE) buttons and the WooCommerce One Page Checkout (OPC) plugin.

Problem:
When using the OPC plugin with ECE configured to show only on "checkout pages":

  1. ECE buttons don't appear on OPC pages because is_checkout() returns false (they're technically product pages)
  2. When buttons did appear with both locations enabled, they showed in the product section instead of the checkout section.
  3. ECE buttons displayed original product prices instead of discounted prices after applying coupon codes

Changes proposed:

  • Detect OPC pages using is_wcopc_checkout() and treat them as checkout context rather than product context
  • Skip product page restrictions for OPC pages when checkout buttons are enabled
  • Force frontend to use cart totals (which include discounts) instead of product pricing on OPC pages when checkout buttons are enabled

Testing instructions

Prerequisites

Test Case 1: ECE shows on OPC with checkout location enabled

  1. Go to WooCommerce > Settings > Payments > Stripe
  2. Under "Express Checkout", set button locations to "Checkout" only (uncheck Product and Cart)
  3. Create a product and mark it as One Page Checkout enabled (OPC meta field _wcopc = 'yes')
  4. View the product page
  5. Expected: Express Checkout buttons (Apple Pay, Google Pay, etc.) appear in the checkout section of the OPC
  6. Expected: No ECE buttons appear in the add-to-cart section

Test Case 2: Correct pricing with discount codes on OPC

  1. With the same setup as Test Case 1
  2. On the OPC product page, apply a coupon code in the checkout section
  3. Observe the ECE buttons
  4. Open an ECE (eg: Google Pay), the total in the payment modal should have the discount applied

Optional:
Test for regressions with OPC disabled.

CleanShot.2025-11-03.at.12.11.26.mp4

  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Changelog entry

  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Comment

Comment

Post merge

@malithsen malithsen marked this pull request as ready for review November 3, 2025 18:18
@malithsen malithsen requested review from a team, daledupreez and diegocurbelo and removed request for a team November 3, 2025 18:18
Copy link
Contributor

@daledupreez daledupreez left a comment

Choose a reason for hiding this comment

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

Functionally, this is working as described. I also tested the situation where express checkout is enabled in the product page and checkout, and confirmed that we're still showing only the express checkout buttons in the One Page Checkout section and not in the main product section. I also smoke tested loading an ECE modal from the button without One Page Checkout active, and that was clear, as were the related e2e tests -- there were some ACH failures, but those are being worked on in a dedicated PR.

However, I think there are some test-related improvements we can make, or at least discuss before we merge this PR.

@malithsen malithsen requested a review from daledupreez November 5, 2025 18:57
@malithsen malithsen requested a review from daledupreez November 7, 2025 19:34
Copy link
Member

@diegocurbelo diegocurbelo left a comment

Choose a reason for hiding this comment

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

The changes look good and work as described.

Copy link
Contributor

@daledupreez daledupreez left a comment

Choose a reason for hiding this comment

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

Thanks for the updates to the tests! 🚢

@malithsen malithsen enabled auto-merge (squash) November 10, 2025 14:18
@malithsen malithsen merged commit 7d4bf8f into develop Nov 10, 2025
40 checks passed
@malithsen malithsen deleted the fix/opc-compatibility branch November 10, 2025 14:51
@daledupreez daledupreez added this to the 10.1.0 milestone Nov 13, 2025
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.

4 participants