You have to insert a link or a submit button, that calls your cart with a parameter, e.g. emptycart=1. Now you could extend UpdateCart.xslt (or whatever you have to process changes to your cart):
- Check for emptycart parameter.
- If it exists, call CommerceLibrary:ClearBasket()
If you want to allow removing of single cart items, you have to place a check box for every single item and add the index of the item to its name. When user hits your update/refresh button, do the following:
- Loop through all items in cart and call CommerceLibrary:DeleteLineItem, when check box with the given index is set.
- I recommend to loop backwards, to prevent problems with index numbers (when removing an item, uCommerce reindexes immediately while your XSLT still uses the original item list).
Empty Shopping Cart
Hi,
Is there a way a i can put a link on the page to allow people to empty their cart?
Thanks
Chris
Sure, this is possible.
You have to insert a link or a submit button, that calls your cart with a parameter, e.g. emptycart=1. Now you could extend UpdateCart.xslt (or whatever you have to process changes to your cart):
- Check for emptycart parameter.
- If it exists, call CommerceLibrary:ClearBasket()
If you want to allow removing of single cart items, you have to place a check box for every single item and add the index of the item to its name. When user hits your update/refresh button, do the following:
- Loop through all items in cart and call CommerceLibrary:DeleteLineItem, when check box with the given index is set.
- I recommend to loop backwards, to prevent problems with index numbers (when removing an item, uCommerce reindexes immediately while your XSLT still uses the original item list).
Hope this helps.
Bye
Christian
Thanks for the suggestion.
Chris
Thanks for helping out, Christian. Always appreciated! :)
is working on a reply...