I'm using addtocart.aspx to add an item to the cart....however, if people hit the back button and submit again....the item is added again.
How can I clear the cart before I add anything so I can be sure what I add is the only thing in there?
I'm using addtocart.aspx to add an item to the cart....however, if people hit the back button and submit again....the item is added again.
How can I clear the cart before I add anything so I can be sure what I add is the only thing in there?
We don't have any built-in methods to clear out the cart, but you could use a SQL query easily enough. Just get the customer's customerID and then delete that customer's rows from the ShoppingCart table.
I'd think pretty carefully before you decide to do that for sure though. What if it's a logged-in customer with 23 other items in their cart that they wanted to get as well? If suddenly their cart is empty, are they going to take the time to add it all again, or get irritated and leave?
Just another thought - are these just specific products that you only want them to have one of? If that's the case, just set the Restricted Quantity on those products to 1, and they can Back/Submit as many times as they want and they'll only get one, and other cart contents are safe.