Hello Zenners,
Is there a way (in Zen Cart 1.5.8a) i can clear the whole shoppingcart with one button click?
Dirk
Hello Zenners,
Is there a way (in Zen Cart 1.5.8a) i can clear the whole shoppingcart with one button click?
Dirk
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.
Thanks Lat9 for you're quick response.
Helps me a lot.
Dirk
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:
HTML Code:<div class="nav-item"> <input class="ml-auto" type="checkbox" onchange="checkAll(this)" name="chk[]"> <i class="fas fa-trash-alt"></i> </div>Code:<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>
What about action=empty_cart ?
You can add a button or a link literally anywhere on the website:
or, if you prefer the correct way with php:Code:index.php?main_page=shopping_cart&action=empty_cart
Style it the way you like.Code:<a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, 'action=empty_cart'); ?>" class="buttonRow emptyCart">Empty Cart</a>