fix(modal-checkout): tiered donate URL trigger handles non-default frequency#202
Draft
miguelpeixe wants to merge 2 commits into
Draft
fix(modal-checkout): tiered donate URL trigger handles non-default frequency#202miguelpeixe wants to merge 2 commits into
miguelpeixe wants to merge 2 commits into
Conversation
…equency The tiered donate form renders a single hidden donation_frequency input locked to the block's default frequency, so triggerDonationForm's early guard rejected any URL whose frequency differed from the default and the modal never opened. Move the tiered branch ahead of the guard (only the non-tiered branches need that input) and scope the frequency-tab lookup to the form. Fixes NPPM-2815
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes URL-parameter-triggered modal checkout for Donate blocks using the tiered layout when the URL’s frequency differs from the block’s default frequency, by bypassing the non-tiered donation_frequency input guard and scoping the frequency-tab lookup to the current form.
Changes:
- Adjust
triggerDonationFormso the tiered layout no longer relies oninput[name="donation_frequency"][value="..."]existing/matching the URL frequency. - Scope tiered frequency-tab lookup to the current donation form to avoid cross-form interference on pages with multiple Donate blocks.
…gger Switch from .forEach() to for...of so the URL-trigger handler returns after the first form that matches, preventing duplicate submits on pages with multiple .wpbnbd--platform-wc forms. Addresses Copilot review feedback on #202.
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:
Fix URL-triggered modal checkout for Donate blocks using the tiered layout when the URL's
frequencyparameter differs from the block's default frequency tab.The tiered renderer emits a single hidden
donation_frequencyinput pinned to the block's default frequency, sotriggerDonationForm's early guardinput[name="donation_frequency"][value="\${ frequency }"]returned null for any non-default frequency and the function bailed silently before reaching the tiered branch. (The URL params still got stripped because that happens after the trigger runs, so the failure was invisible to readers.)The fix routes the tiered branch around that guard — only the frequency-based and untiered branches actually need that input — and scopes the frequency-tab lookup to the form (defensive against multiple donate blocks on a page).
Closes NPPM-2815.
How to test the changes in this Pull Request:
monthURLs worked:?checkout=1&type=donate&layout=tiered&frequency=month&amount=15→ $15.00 / month?checkout=1&type=donate&layout=tiered&frequency=month&amount=30→ $30.00 / month?checkout=1&type=donate&layout=tiered&frequency=once&amount=20→ $20.00 one-time?checkout=1&type=donate&layout=tiered&frequency=year&amount=360→ $360.00 / yearamountthat isn't one of the tier amounts (e.g.&amount=999) — modal should not open (no regression to silent-fail on invalid params).layout=frequency— confirm the frequency-based code path is unchanged.layout=untiered— confirm the untiered code path is unchanged.Other information: