Skip to content

fix(checkout): sync repeat trial pricing in modal checkout#264

Open
rbcorrales wants to merge 5 commits into
mainfrom
fix/modal-checkout-repeat-trial-display
Open

fix(checkout): sync repeat trial pricing in modal checkout#264
rbcorrales wants to merge 5 commits into
mainfrom
fix/modal-checkout-repeat-trial-display

Conversation

@rbcorrales

Copy link
Copy Markdown
Member

All submissions:

  • Have you followed the Newspack contributing guidelines?
  • Does your code follow the WordPress coding standards and VIP Go coding standards?
  • Have you checked to ensure there are not other open Pull Requests for the same update or change?

Changes proposed in this Pull Request:

This fixes modal checkout pricing for anonymous shoppers whose email addresses belong to users who have already used a subscription trial.

Previously, the first modal step validated billing details without resolving the email to the matching existing user for trial eligibility. The payment step could still show trial pricing and a zero-due-today amount, while the completed order charged the subscription amount.

This change keeps the modal product summary and complete transaction button aligned with WooCommerce checkout recalculation and scopes the serialized email lookup to the modal checkout, so standard checkout behavior is not expanded.

Closes NPPM-2838.

How to test the changes in this Pull Request:

  1. Configure WooCommerce, WooCommerce Subscriptions, and a supported Stripe test gateway for modal checkout.
  2. Create a subscription product with a free trial and add it to a page using the Newspack modal checkout flow.
  3. Create or identify a user who already has a subscription to that product, so the user is no longer eligible for the free trial.
  4. Open the subscription page in an anonymous browser session.
  5. Start modal checkout with the email address for the user who has already used the trial.
  6. Continue to the payment step.
  7. Confirm that the "Complete transaction" button shows the amount due today, not zero.
  8. Confirm the transaction details show the paid amount due today and the recurring total.
  9. Return to billing details and repeat with a new email address that has not used the trial.
  10. Confirm that the "Complete transaction" button still shows zero due today for the eligible new trial user.
  11. Confirm that the standard WooCommerce checkout still shows trial pricing for anonymous shoppers and is not affected by the serialized modal checkout email lookup.

Other information:

  • Have you added an explanation of what your changes do and why you would like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?

rbcorrales and others added 3 commits June 9, 2026 15:06
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
@rbcorrales rbcorrales requested a review from a team as a code owner June 9, 2026 22:57
@rbcorrales rbcorrales requested a review from Copilot June 9, 2026 22:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a modal-checkout edge case where anonymous shoppers entering an email tied to an existing user (who has already consumed a subscription trial) could still see trial/“$0 due today” pricing in the modal UI, while the completed order correctly charged the non-trial amount. The change scopes “resolve user from serialized checkout email” behavior specifically to modal checkout, and keeps modal UI pricing in sync with WooCommerce’s recalculated order-review totals.

Changes:

  • Scope free-trial limiting email-to-user resolution to modal checkout only (avoids expanding behavior to standard checkout).
  • Update modal checkout JS to sync the static product summary and “Complete transaction” button amount with recalculated checkout totals.
  • Add/update unit tests and mocks to cover modal-vs-standard serialized email behavior and the new product summary helper.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
plugins/newspack-plugin/tests/unit-tests/plugins/woocommerce-subscriptions/class-woocommerce-subscriptions.php Adds a modal-checkout test double + unit tests ensuring serialized email is only resolved in modal checkout for trial limiting.
plugins/newspack-plugin/tests/mocks/wc-mocks.php Extends WC Subscriptions switcher mock to support new/used integration code paths.
plugins/newspack-plugin/includes/plugins/woocommerce-subscriptions/class-woocommerce-subscriptions.php Restricts serialized-email user resolution for trial limiting to modal checkout requests only.
plugins/newspack-blocks/tests/test-modal-checkout.php Adds blocks-level unit tests for parsing billing email (including serialized post_data) and sanitizing the cart product summary.
plugins/newspack-blocks/src/modal-checkout/index.js Syncs modal product summary and place-order button pricing with updated checkout/order-review totals (removes sync AJAX).
plugins/newspack-blocks/includes/class-modal-checkout.php Adds a sanitized cart product summary helper + AJAX endpoint; enhances email parsing to support Woo’s serialized post_data; limits subscription checks to modal checkout.

Comment thread plugins/newspack-blocks/tests/test-modal-checkout.php Outdated
Comment thread plugins/newspack-plugin/tests/mocks/wc-mocks.php Outdated
rbcorrales and others added 2 commits June 9, 2026 18:06
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants