fix(modal-checkout): always show deal-accurate order details#453
fix(modal-checkout): always show deal-accurate order details#453miguelpeixe wants to merge 10 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Newspack Blocks modal checkout UI so the user always sees the real (deal-/coupon-accurate) WooCommerce order review inline, instead of a static price summary plus a collapsible “Transaction details” section.
Changes:
- Removes the “Transaction details” collapse/expand UI and always renders the WooCommerce order review table inline.
- Removes the static price summary injection in the Reader Activation auth/registration modal flow.
- Keeps a hidden
#modal-checkout-product-detailscarrier and adjusts JS insertion points to anchor to it.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| plugins/newspack-blocks/src/modal-checkout/templates/form-checkout.php | Removes the “Transaction details” toggle markup and renders order review directly. |
| plugins/newspack-blocks/src/modal-checkout/modal.js | Stops injecting the static price summary into the auth/registration modal. |
| plugins/newspack-blocks/src/modal-checkout/index.js | Removes toggle logic and anchors checkout-details rendering after #modal-checkout-product-details. |
| plugins/newspack-blocks/src/modal-checkout/checkout.scss | Removes collapse/expand styles and adds spacing for always-visible order review. |
| plugins/newspack-blocks/includes/class-modal-checkout.php | Makes order details always eligible to render for non-empty carts; replaces the visible summary card with a hidden data carrier. |
Resolve conflicts with PR #264 (repeat-trial pricing sync) in class-modal-checkout.php and modal-checkout/index.js: - render_before_checkout_form(): keep this PR's hidden data-carrier (visible price-summary card removed); main's tested get_cart_product_summary* helpers + backend repeat-trial fix retained. - index.js: drop the now-obsolete static-summary sync and the removed Transaction Details toggle; preserve getCheckoutPostData(), which the retained Place Order total sync depends on.
dkoo
left a comment
There was a problem hiding this comment.
@miguelpeixe Reviewed + manually QA'd on an integrated env (WCS 9.0 + Stripe test, #453 built into newspack-blocks). Approving — the core change is sound: the stale, non-deal-aware price-summary card is gone, and the real WooCommerce order-review table is now always shown for any non-empty cart (including the single-item/donation case that previously showed nothing), with amounts driven by the cart total so they reflect the actual charged amount (engine deal or coupon).
On the deal disclosure (the thing I most wanted to confirm): it's preserved. The always-visible order-review table is WooCommerce's standard review-order.php, which fires the same woocommerce_cart_item_name / woocommerce_cart_item_subtotal filters the engine uses — so the rule name + regular→adjusted strikethrough render right there. Verified live (a publicized deal on a subscription shows the badge + ~~$10.00~~ $4.00 in the modal). Removing the card doesn't lose the disclosure.
A few non-blocking follow-ups (none gate merge):
- Dead
price_summaryplumbing —modal.js:171still assignscheckoutData.price_summaryto a<strong>that no longer exists (still built at:339); the engine'snewspack_modal_checkout_price_summarybridge is now a no-op for the modal. Worth removing the dead JS/PHP and letting the engine side know. - Pre-existing escaping gap —
thankyou.php(not touched by this PR) emitsdata-checkoutvia rawwp_json_encodewith noesc_attrin a single-quoted attribute, so an apostrophe in a product name breaks it. This PR addeddata_checkout_attr()(esc_attr+ENT_QUOTES) for exactly this — worth applying it to that caller too. - Nits: an orphaned
woocommerce_checkout_before_order_review_headinghook; and the new escaping helper could use a test. - #446 coupling: both PRs edit
checkout-button/view.php— likely a merge conflict to resolve, but the behavior composes fine.
Nice cleanup — the always-visible order table is a real improvement. Thanks!
All Submissions:
Changes proposed in this Pull Request:
The modal checkout showed a static price summary at the top that did not reflect dynamic-pricing deals, while the real order total was tucked behind a collapsible "Transaction details" toggle. This PR makes the modal present the real, deal-accurate order summary inline and always visible:
checkout_completedanalytics still fire.How to test the changes in this Pull Request:
checkout_completedevent still fires with product details (the hidden#modal-checkout-product-detailscarrier).Other information: