Support » Plugin: WooCommerce » Trigger update_checkout without triggering form validation

  • Resolved norabrown212

    (@norabrown212)


    Hello,

    My checkout page is in the following order:

    1. coupon form
    2. cart
    3. checkout form and payment fields etc.

    I am doing a custom coupon submission to hook into an external API. On success, I call $('body').trigger('update_checkout'); which causes the order review area to update, showing coupon success messages as well as the updated cart totals — all good!

    However, it also triggers the checkout form validation, so that all the form fields show errors (having not been filled out when the customer submits the coupon).

    How can I either:

    • Cause only the order review area/cart to be updated
    • Call update_checkout without triggering form validation
    • This topic was modified 1 year, 7 months ago by norabrown212.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter norabrown212

    (@norabrown212)

    One further thing I noticed. Our custom coupon application code adds certain notices using, for example wc_add_notice( __( 'Coupon code applied successfully!', 'woocommerce' ), 'success' )

    But even a ‘success’ type notice causes the ‘result’ attribute of the wc-ajax=update_order_review call to be ‘failure’ and that is what seems to trigger the form validation. If I remove all notices, that call returns result: success and the form validation errors don’t appear. But, the user also doesn’t see a message about coupon success or failure, so it’s not a good solution.

    Plugin Support Mike a11n

    (@nixiack8)

    Hi there,

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.
    I can also recommend the following places for more development-oriented questions:

    1. WooCommerce Slack Community: https://woocommerce.com/community-slack/

    2. Advanced WooCommerce group on Facebook: https://www.facebook.com/groups/advanced.woocommerce/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Trigger update_checkout without triggering form validation’ is closed to new replies.