feat(my-account): build v2 prototype scenarios + polish (Phase 7)#4683
Merged
thomasguillot merged 2 commits intoApr 28, 2026
Merged
Conversation
Wires the `?v2-demo=<scenario>` mechanism (11 scenarios), retires the `extras` subscription bucket in favour of a fixture registry, and sweeps the open-question polish backlog accumulated across Phases 3–6 (hash fragments, "The News Paper" hardcodes). Adds an inline Expired badge to the payment-methods table for the `expired-payment` scenario, mirroring v1's parse-MM/YY-then-emit-badge pattern. Empty scenarios surface a newspack-ui notice on the donations + subscriptions list pages. Brief gets a new Phase 8 — Documentation pass (reader's guide, architectural map, productionisation playbook) so the next person to touch the prototype has a single guide-shaped doc to start from.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Phase 7 scenario fixtures and polish for the My Account v2 demo prototype (?v2-demo=<scenario>), enabling deterministic fake-data variants for stakeholder review while keeping the default happy-path unchanged.
Changes:
- Introduces an allow-listed scenario system (
SCENARIOS,get_scenario(),apply_scenario()) and refactors subscription fixtures into a registry to support scenario swaps without duplication. - Adds empty-state UX for subscriptions/donations, plus an “Expired” badge for payment methods (to support the
expired-paymentscenario). - Polishes demo UI by scrubbing hash-fragment hrefs and replacing hardcoded site name copy with
get_bloginfo( 'name' ).
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/my-account/v2-demo/subscriptions.js | Updates wiring docstring to reflect Phase 7 scenario-driven expiring variant behavior. |
| src/my-account/v2-demo/donations.js | Updates billing-history Button Card stub comment to match Phase 7 scenario behavior. |
| includes/plugins/woocommerce/my-account/templates/v2-demo/subscriptions.php | Adds subscriptions empty-state notice; scrubs renew anchor hash to #. |
| includes/plugins/woocommerce/my-account/templates/v2-demo/subscription-details.php | Scrubs action-trigger hash hrefs to # for modal-trigger anchors. |
| includes/plugins/woocommerce/my-account/templates/v2-demo/payment-methods.php | Adds expired-card detection + inline “Expired” badge next to brand. |
| includes/plugins/woocommerce/my-account/templates/v2-demo/partials/restart-donation-modal.php | Replaces hardcoded site name with get_bloginfo('name') in fee-cover helper text. |
| includes/plugins/woocommerce/my-account/templates/v2-demo/partials/renew-subscription-modal.php | Replaces hardcoded site name with get_bloginfo('name') in fee-cover helper + success copy. |
| includes/plugins/woocommerce/my-account/templates/v2-demo/partials/modify-donation-modal.php | Replaces hardcoded site name with get_bloginfo('name') in fee-cover helper text. |
| includes/plugins/woocommerce/my-account/templates/v2-demo/partials/change-subscription-modal.php | Replaces hardcoded site name with get_bloginfo('name') in fee-cover helper text. |
| includes/plugins/woocommerce/my-account/templates/v2-demo/donations.php | Adds donations empty-state notice; scrubs billing-history anchor hash to #. |
| includes/plugins/woocommerce/my-account/class-my-account-ui-v2-demo.php | Implements scenario allow-list + scenario application; refactors subscription fixtures; adds empty-slice helpers. |
| docs/my-account-v2-prototype-devlog.md | Adds Phase 7 devlog entry and decision-log items covering scenarios/polish. |
| docs/my-account-v2-prototype-brief.md | Adds Phase 8 documentation-pass roadmap entry and definition-of-done bullet. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- empty_payment_methods() now returns [] (was [ 'cc' => [] ]) so no-payment-methods / empty scenarios surface WC core's "No saved methods found." notice instead of an empty-tbody table. - expired-payment falls back to index 0 when every card is default, so the scenario is deterministic regardless of the underlying card mix. - Expired-badge detection uses date_parse_from_format( 'n/y', … ) with parse-error checks, mirroring v1's payment-information template. Malformed values (02/ab, 13/27, 00/27, empty) no longer false-positive.
6 tasks
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:
Phase 7 of the My Account v2 prototype — scenario fixtures + polish. Targets
prototype/my-account-demo; umbrella tracker is #4679. See the brief and the devlog for the full context.Scenario fixtures (
?v2-demo=<scenario>)A
SCENARIOSallow-list constant +get_scenario()reader +apply_scenario()switch dispatcher merge a small set of overrides on top of the base happy-path fixture. Eleven scenarios:cancelled-subpreviousshrinks to one rowexpiringrenewedno-feesbilling-historyno-categoriesexpired-paymentExpiredbadge appears next to the brandemptyno-donationsno-subscriptionsno-payment-methodsEmpty scenarios surface a
__notice"You have no subscriptions / donations yet" on the matching list page; payment-methods reuses WC core's existingwc_print_notice( 'No saved methods found.' ).Internal refactor — fixture registry replaces the
extrasbucketget_fake_subscriptions()previously held three arrays (active,previous,extras) with row literals duplicated across them. Phase 7 extracts aget_subscription_fixtures()registry keyed by id (sub-001 / sub-cancelled / sub-expired / sub-expiring / sub-renewed / sub-active-no-fees); the default arrangement plus every scenario's swap pulls from the same pool.find_subscription_by_idnow only searchesactive+previoussince scenarios surface every variant via the active slot.Polish sweep — closes the open-question carryover from Phases 3–6
#change-subscription,#cancel-subscription,#renew-subscription,#update-payment-method,#renew,#billing-history) all collapsed tohref="#". URL bar stays clean; JS handlers already preventDefault.The News Paperhardcode swept toget_bloginfo('name')across the four modal partials (change-subscription, modify-donation, renew-subscription, restart-donation) and the renew success copy. Real site name in the demo on any environment.Brief: roadmap addition — Phase 8 (Documentation pass)
Adds a Phase 8 entry to brief §10 + a §12 definition-of-done bullet. Phase 8 produces
docs/my-account-v2-prototype-guide.mdcovering reader's guide / architectural map / productionisation playbook. Total estimate moves from ~8–8.5 to ~8.5–9 dev-days. No code in this PR; the doc itself is Phase 8 work.Cross-repo impact: none. The class + templates are gated behind
current_user_can('manage_options') && isset($_GET['v2-demo'])and behindis_account_page(). Non-admin readers see v1 unchanged.How to test the changes in this Pull Request:
git fetch && git checkout prototype/my-account-demo-phase-7. Runcomposer dump-autoload && npm run buildinrepos/newspack-plugin./my-account/?v2-demo=1, confirm sidebar isDashboard → Edit account → Newsletters → Donations → Subscriptions → Payment methodsand every section renders as on Phase 6./my-account/subscriptions/?v2-demo=expiring— active card has the inline error notice + "Expires on Sep 16, 2026" subtext + Renew button./my-account/subscriptions/?v2-demo=cancelled-sub— active card shows the cancelled state; previous section has a single Expired card./my-account/subscriptions/?v2-demo=renewed— active card shows the renewed state (visually identical to active; data differs)./my-account/subscriptions/?v2-demo=no-fees— detail page Amount breakdown collapses to a single Total row./my-account/donations/?v2-demo=billing-history— the Button Card at the bottom is replaced by an inline billing-history table./my-account/newsletters/?v2-demo=no-categories— three sections flatten to one ungrouped 11-row list./my-account/payment-methods/?v2-demo=expired-payment— Mastercard row's expiry is in the past; an inlineExpiredbadge appears next to the brand name (alongside the existing inline Default badge on Visa)./my-account/subscriptions/?v2-demo=no-subscriptions/my-account/donations/?v2-demo=no-donations/my-account/payment-methods/?v2-demo=no-payment-methods/my-account/?v2-demo=empty(visit each subpage; all three slices empty)./my-account/subscriptions/sub-001/?v2-demo=1→ "Change subscription" → confirm the cover-fees helper text reads "…so that receives 100% of your payment."). Repeat for the modify donation / renew subscription / restart donation modals. Renew success copy: "Thank you for supporting !".#(not#change-subscriptionetc.)./my-account/?v2-demo=foo-bar-not-real— page renders the happy-path fixture (acts like?v2-demo=1)./my-account/subscriptions/?v2-demo=expiring— bounces to v1 //edit-account/. No demo body class, no demo bundle in Network tab.n npm run lint:phpandn npm run lint:js -- src/my-account/v2-demo/andn npm run lint:scss -- 'src/my-account/v2-demo/**/*.scss'. All clean.n npm run build. Should complete with no v2-demo warnings.Other information:
wp eval-file; lint + build pass.