How can I listen for checkout form submission? I’m trying to use custom code to trigger something based on submit.
Here’s what I’ve learned after a lot of searching:
- The checkout form is actually a bunch of different
formelements – one for customer info, one for payment info, one for shipping, etc.
- It has no submit button, i.e. an input where
type="submit". I’m assuming this is so that the button that looks like a submit button can be used to progammtically trigger submission of all the individual
formelements. But the Webflow JS file is so complicated I can’t really know for sure.
- Listening for a
submitevent doesn’t work because
submitevents are only created when the user directly triggers submission, e.g. by clicking a submit button. When forms are submitted programatically, there’s no
submitevent, and I don’t know of any other event that I could listen for. (I could listen for a button click, but that wouldn’t work when a user clicks the button but the form doesn’t submit because of some error.)
Does anyone know what to do in this case? It was easy in the case of the Add to Cart button, before checkout. In that case, the button is a submit button so it’s easy to listen for when the user submits the form. The same approach isn’t working here.