Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2024
    Location
    Noord Holland
    Posts
    24
    Plugin Contributions
    4

    help question 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

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,892
    Plugin Contributions
    96

    Default 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.

  3. #3
    Join Date
    Sep 2024
    Location
    Noord Holland
    Posts
    24
    Plugin Contributions
    4

    Default Re: Clear cart with button click

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

    Dirk

  4. #4
    Join Date
    Sep 2012
    Location
    Upstate South Carolina
    Posts
    106
    Plugin Contributions
    2

    Default 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:

    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>

  5. #5
    Join Date
    Oct 2008
    Location
    Croatia
    Posts
    1,740
    Plugin Contributions
    22

    Default Re: Clear cart with button click

    What about action=empty_cart ?

    You can add a button or a link literally anywhere on the website:
    Code:
    index.php?main_page=shopping_cart&action=empty_cart
    or, if you prefer the correct way with php:
    Code:
    <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.

 

 

Similar Threads

  1. v156 Can Add to Cart Button be configured to add 2 product IDs to the cart with one click?
    By apogeerockets in forum Setting Up Categories, Products, Attributes
    Replies: 2
    Last Post: 15 Oct 2021, 02:53 AM
  2. i want to edit action when click add to cart button
    By vetri in forum General Questions
    Replies: 2
    Last Post: 14 May 2015, 03:07 PM
  3. blank page when I click on my add to cart button
    By cydgeno in forum General Questions
    Replies: 1
    Last Post: 21 Jul 2009, 05:11 PM
  4. Upgrading via host with click of a button?
    By LizzyB in forum Upgrading from 1.3.x to 1.3.9
    Replies: 4
    Last Post: 9 Mar 2009, 01:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg