This article will show you how to modify the cart page by adding a button that clears the cart of all products with a single click instead of manually removing each product.
- Go to your control panel and navigate to the CartContent.html panel file by navigating to Design -> Template files -> Panels -> CartContent.html. Add the following code at the bottom of the page:
<script type="text/javascript"> $("#RemoveAllProducts").click(function(){ if(config.ShopPath) { var cartrmpath = config.ShopPath + '/cart.php?action=update'; } $(".CartContents tbody tr select").each(function(){ var mcqty = $(this).attr("name"); cartrmpath = cartrmpath + "&" + mcqty + "=0"; }); $.get(cartrmpath, function() { window.location.reload(); }); return false; }); </script>
- Add the following code where you want the button to be displayed:
- Save your changes and navigate to the cart page. You should see a new button that says "Clear Cart". If you click the button it should remove all of the products from the cart automatically.
<button id="RemoveAllProducts">Clear Cart</button>