Skip to content

[WooCommerce Checkout] Coupon "Apply" button triggers full order submission (?wc-ajax=checkout) instead of applying discount #1334

Description

@POBrien333

Description

When using the Breakdance WooCommerce Checkout element, clicking the "Apply coupon" button (or pressing the Enter key inside the coupon input field) submits the entire checkout form (?wc-ajax=checkout) rather than firing the isolated coupon AJAX handler (?wc-ajax=apply_coupon).
Image

As a result, WooCommerce runs full validation on all required checkout fields (e.g., Billing First/Last Name, T&Cs acceptance) and returns validation errors instead of applying the discount code to the cart totals.

Steps to Reproduce

  1. Create a checkout page using the Breakdance WooCommerce Checkout element.
  2. Add any item to the cart and proceed to /checkout/.
  3. Leave all billing/shipping input fields blank.
  4. Enter a valid coupon code in the coupon field.
  5. Click Apply coupon (or press Enter while typing in the input box).

Expected Behavior
An AJAX request to ?wc-ajax=apply_coupon or ?wc-ajax=update_order_review should fire.
The cart totals should update dynamically without triggering form validation on billing/shipping fields or terms & conditions.

Actual Behavior
The form makes a POST request to ?wc-ajax=checkout.
WooCommerce attempts to place the order and returns validation errors in the response payload:
JSON
{ "result": "failure", "messages": "<ul class=\"woocommerce-error\" role=\"alert\"><li>Billing First name is a required field.</li><li>Please read and accept the terms and conditions...</li></ul>" }

Root Cause / Technical Details
Inspecting the rendered DOM shows that the coupon button is output with type="submit" inside the main <form class="checkout woocommerce-checkout">:
HTML
<button type="submit" class="button" name="apply_coupon" value="Apply coupon">Apply coupon</button>

Because event handlers on the button do not intercept and run preventDefault(), the browser treats it as a standard form submit button, dispatching the entire checkout payload.

I was able to fix it with some JavaScript, but suggest this should be fixed globally. Thanks.

You should also include the following information:

  • Breakdance version: 2.8.1
  • Browser & OS: Win11 and Firefox 153.0.3 (64-bit)
  • If you receive any kind of error message, you should also provide your PHP (8.3) and WordPress version (7.0.3)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions