Loading...

How To Remove All Products From Cart

Emilian F. Published on 11 August, 2014

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.

  1. 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>
    
    
  2. Add the following code where you want the button to be displayed:

  3. 
    <button id="RemoveAllProducts">Clear Cart</button>
    
    
  4. 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.
Emilian F. Published on 11 August, 2014