Skip to content

fix: coupon removal button and duplicate field ID on checkout form (#76)#389

Merged
superdav42 merged 1 commit into
mainfrom
bugfix/issue-76-coupon-removal-rendering
Mar 24, 2026
Merged

fix: coupon removal button and duplicate field ID on checkout form (#76)#389
superdav42 merged 1 commit into
mainfrom
bugfix/issue-76-coupon-removal-rendering

Conversation

@superdav42

Copy link
Copy Markdown
Collaborator

Summary

Fixes two bugs reported in issue #76:

  1. Remove button does nothing — The "Remove" link in the order summary only set discount_code = '' but did not reset toggle_discount_code. This left the coupon input field visible and in an inconsistent state. The fix adds toggle_discount_code = false to the click handler so the coupon field collapses and the Vue watcher correctly triggers create_order() to recalculate totals.

  2. Coupon code does not render correctly — The toggle checkbox (discount_code_checkbox) had id = 'discount_code', the same as the text input field. This produced a duplicate id="field-discount_code" in the rendered HTML, breaking the <label for="..."> association and causing rendering issues. Fixed by giving the toggle its own unique id: discount_code_checkbox.

Changes

  • views/checkout/templates/order-summary/simple.php — extend click handler to also reset toggle_discount_code
  • inc/checkout/signup-fields/class-signup-field-discount-code.php — fix duplicate HTML id on the toggle checkbox

Closes #76

- Fix Remove button in order summary not working: the click handler now
  also resets toggle_discount_code to false, collapsing the coupon input
  field and properly clearing the applied coupon state (issue #76)
- Fix coupon code field not rendering correctly: the toggle checkbox had
  id='discount_code' (same as the text input), causing a duplicate HTML
  id='field-discount_code'. Changed toggle id to 'discount_code_checkbox'
  to eliminate the duplicate and fix label/field association (issue #76)

Closes #76
@coderabbitai

coderabbitai Bot commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@superdav42 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 18 minutes and 24 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f9c4eb40-40d9-4523-a298-065baab6395d

📥 Commits

Reviewing files that changed from the base of the PR and between 5b40ee7 and bb91be1.

📒 Files selected for processing (2)
  • inc/checkout/signup-fields/class-signup-field-discount-code.php
  • views/checkout/templates/order-summary/simple.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/issue-76-coupon-removal-rendering

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@superdav42 superdav42 merged commit c473670 into main Mar 24, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Impossible to remove coupon code once applied

1 participant