fix(checkout): sync repeat trial pricing in modal checkout#264
Open
rbcorrales wants to merge 5 commits into
Open
fix(checkout): sync repeat trial pricing in modal checkout#264rbcorrales wants to merge 5 commits into
rbcorrales wants to merge 5 commits into
Conversation
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Contributor
There was a problem hiding this comment.
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. |
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All submissions:
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:
Other information: