Zen Cart Logo
Forums / Customization from the Admin / Clear cart with button click

Clear cart with button click

Views: 2,891

Results 1 to 5 of 5
27 Sep 2025, 18:26
#1
dirks avatar

dirks

New Zenner

Join Date:
Sep 2024
Location:
Noord Holland
Posts:
24
Plugin Contributions:
4

Clear cart with button click

Hello Zenners,

Is there a way (in Zen Cart 1.5.8a) i can clear the whole shoppingcart with one button click?

Dirk

27 Sep 2025, 19:39
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,065
Plugin Contributions:
56

Re: Clear cart with button click

Nope, there's not. Either all quantities need to be zeroed or each of the items' delete checkboxes clicked and then the overall "Update" icon clicked.

27 Sep 2025, 20:18
#3
dirks avatar

dirks

New Zenner

Join Date:
Sep 2024
Location:
Noord Holland
Posts:
24
Plugin Contributions:
4

Re: Clear cart with button click

Thanks Lat9 for you're quick response.
Helps me a lot.

Dirk

28 Sep 2025, 13:01
#4
chuckphillips avatar

chuckphillips

Zen Follower

Join Date:
Sep 2012
Location:
Upstate South Carolina
Posts:
106
Plugin Contributions:
1

Re: Clear cart with button click

I also had a need for this, so I added a javascript checkbox at the top of the shopping cart page that checks all the other boxes at once.

Two clicks to empty the cart:

<div class="nav-item">
         <input class="ml-auto" type="checkbox" onchange="checkAll(this)" name="chk[]"> <i class="fas fa-trash-alt"></i>
</div>
<script>
    
     function checkAll(ele) {
     var checkboxes = document.getElementsByTagName('input');
     if (ele.checked) {
         for (var i = 0; i < checkboxes.length; i++) {
             if (checkboxes[i].type == 'checkbox') {
                 checkboxes[i].checked = true;
             }
         }
     } else {
         for (var i = 0; i < checkboxes.length; i++) {
             console.log(i)
             if (checkboxes[i].type == 'checkbox') {
                 checkboxes[i].checked = false;
             }
         }
     }
 }
    
</script>
29 Sep 2025, 05:59
#5
balihr avatar

balihr

Totally Zenned

Join Date:
Oct 2008
Location:
Croatia
Posts:
1,768
Plugin Contributions:
20

Re: Clear cart with button click

What about action=empty_cart ?

You can add a button or a link literally anywhere on the website:

index.php?main_page=shopping_cart&action=empty_cart

or, if you prefer the correct way with php:

<a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, 'action=empty_cart'); ?>" class="buttonRow emptyCart">Empty Cart</a>

Style it the way you like.