Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2008
    Posts
    33
    Plugin Contributions
    0

    Default Add delete button in shopping cart

    I have installed the shopping cart with rewards side box and merged it with the images and checkout button in cart sidebox. Now, I am trying to add a remove from cart button after each product. I have the button showing but it doesn't work correctly. It returns teh user to the shopping cart page and at that time you can remove items from the sidebox but it only removes the last item added. I have changed the file name for the icon so that I could have a smaller icon.

    Code:
    $content .= '<a href="'.zen_href_link(FILENAME_SHOPPING_CART, 'action=remove_product&product_id=' . $product['id']). '">'. zen_image($template->get_template_dir(ICON_IMAGE_TINYTRASH, DIR_WS_TEMPLATE, $current_page_base,'images/icons'). '/'.ICON_IMAGE_TINYTRASH, ICON_TRASH_ALT).'</a></li>';

  2. #2

    Default Re: Add delete button in shopping cart

    I've managed to add a delete button beside each product in the shopping cart sidebox, using part of a script from an osCommerce mod.

    In templates/sideboxes/tpl_shopping_cart.php I added this script at the start before $content ="";

    PHP Code:
    ?>
    <script type="text/javascript">
    <!--
    function mark(pid) {
       document.forms["remove_product"].elements["cart_delete[]"][0].value=pid;
       document.forms["remove_product"].elements["products_id[]"][0].value=pid;
       document.remove_product.submit();
    }
    var sURL = document.URL.toString();
    if (sURL.indexOf("?") > 0){
     urlsplitter = '';
    } else {
     urlsplitter = '?';
    }
    document.write('<form ');
    document.write(' name="remove_product" ');
    document.write(' action="' + document.URL + urlsplitter + '&action=update_product"');
    document.write(' method="post">');
    //one element is not an array so add 2 of each!
    document.write('<input type="hidden" name="products_id[]">');
    document.write('<input type="hidden" name="cart_delete[]">');
    document.write('<input type="hidden" name="products_id[]">');
    document.write('<input type="hidden" name="cart_delete[]">');
    document.write('</form>');

    document.write('<form ');
    document.write(' name="cart_box" ');
    document.write(' action="' + document.URL + urlsplitter + '&action=update_product"');
    document.write(' method="post">');
       //-->
    </script>
    <?php
    I dropped a delete icon into my images folder and added the following line before <span class="cartNewItem"> and <span class="cartOldItem">:

    PHP Code:
    <div class="removeProduct"><a href="javascript:void(mark(\'' . $products[$i]['id'] . '\'));">' . '<img src="images/small_delete.gif" border="0" height="16" width="16"></a></div
    To make the delete icon display to the right of each product, I added this line to stylesheet.css:

    HTML Code:
    .removeProduct {float:right;margin:0px 0px 0px 2px;}
    Seems to be working OK... I'd like to get the delete icons to line up on the right, but I'm not sure how to do this ...

  3. #3

    Default Re: Add delete button in shopping cart sidebox

    Maybe my last suggestion isn't necessary. While the script works for me, I wonder is there an easier way to use the

    'action=remove_product&product_id='

    in the shopping cart sidebox without having the action revert to the shopping cart page?

  4. #4
    Join Date
    Nov 2008
    Posts
    33
    Plugin Contributions
    0

    Default Re: Add delete button in shopping cart

    Awesome! works great.

    as far as getting the icon to align to the right I just put align="right" in the <div> tag. as far as going back to the shopping cart page I have mine set up differently so that after items are added it just goes to the product added page. You can adjust this in the Admin>Configuration>My Store>Display Cart After Adding Product="false".

    once again thank you

 

 

Similar Threads

  1. Shopping Cart Summary Delete Item Button
    By mattk251285 in forum Templates, Stylesheets, Page Layout
    Replies: 9
    Last Post: 7 Mar 2016, 10:34 PM
  2. Changing update cart and delete button in shopping cart to text.
    By k1ra in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 28 Mar 2014, 10:52 PM
  3. Replies: 5
    Last Post: 10 Jun 2013, 06:13 PM
  4. Shopping Cart - Move "Delete" Button next to Qty Box
    By dave_nextexit in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 8 Feb 2009, 10:19 PM
  5. Delete button not showing the shopping cart
    By Simpleman in forum Managing Customers and Orders
    Replies: 1
    Last Post: 17 Nov 2006, 06:12 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR