Clear the value while adding to Add to cart

salu
Mega Guru

Hello All,

I need to clear the of the catalog form while clicking on add to cart.I wrote a script in on submit to clear the value.But it will not store in the table.Can you please suggest a solution for this?

Thanks

1 ACCEPTED SOLUTION

andrew_lawlor
Giga Expert

So, it sounds like you want to clear all form fields onSubmit, when a user clicks the add to cart button? It also sounds like, since you're clearing form values onSubmit, before the RITM is added to the user's cart, all of the variable values are empty in the cart.



I think a simple way around this would be to redirect the user on the client-side with an onSubmit client script. You could redirect the user to the current catalog item - grab its unid dynamically - using window.location = x; This will add the item to the user's cart and reload the current form.


View solution in original post

8 REPLIES 8

Hello Adrew,


It was a perfect solution.Thank you very very much for your help


Hi Andrew, this is a fine workaround to prevent accidental duplicate requests!



I defined a Catalog Client Script, attached it to a particular item and it works.



However, this means I have to define an onSubmit script for each item in the catalog...Is there a way to enable this for all the items in the catalog at once?


After a little bit of thinking I went this way: I created a new Variable Set and added the Script to that set. Then I can add the Variable Set to any item I need to without defining a catalog script for each item.


This worked for me with one caveat.I get a message that says 'Changes you made may not be saved.', even though they are saved. 

find_real_file.png

How can i prevent or change the verbiage?