Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2011
    Posts
    72
    Plugin Contributions
    0

    Default + or - to add qty to cart mod

    I'm using 1.5.6c and I see other Zen Cart sites with a + or - or arrows to increase/decrease qtys of an item.

    What is this mod or script? I tried a lot of variations to find it and i'm just striking out with my own search.

    Is it called something specific that is escaping me?

    Thanks!

  2. #2
    Join Date
    Jan 2013
    Posts
    811
    Plugin Contributions
    0

    Default Re: + or - to add qty to cart mod

    this is what is in my tpl_product_info_display.php
    Code:
    // show the quantity box
    							$the_button = '
    							<div class="max-qty">' . zen_get_products_quantity_min_units_display((int)$_GET['products_id']) . '</div>
    							<div class="crt-rw">  
    								<div class="qty-input-wra">
    									<span class="qty-text">' . PRODUCTS_QTY_TEXT . '</span>
    									<div class="qty-wra spplus-minus">
    										<span class="spplus-minus sp-minus"><i class="material-icons">remove</i></span>
    										<span class="qty-input cart-box">
    											<input type="text" name="cart_quantity" value="1" maxlength="6" size="4" />' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']).'
    										</span>
    										<span class="sp-plus"><i class="material-icons">add</i></span>
    									</div>
    								</div>'. 
    								'<div class="cart-btn">
    									<button class="submit_button button btn  button2"><i class="material-icons">shopping_cart</i><span class="text">'.BUTTON_IN_CART_ALT.'</span></button>
    								</div>
    								<div class="product-extra-link">'.(($wishlist_link!='' || $compare_link!='')? '<ul class="product-link">'.$wishlist_link.$compare_link.'</ul>' : '').'</div>
    							</div>
    							';
    							}
    							$display_button = zen_get_buy_now_button($_GET['products_id'], $the_button);

  3. #3
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: + or - to add qty to cart mod

    There's this plugin/module/code modification that has updates identified in the associated thread: https://www.zen-cart.com/downloads.php?do=file&id=1811

    It is more of a product listing type effect than a product information tool, but...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #4
    Join Date
    Dec 2007
    Location
    Payson, AZ
    Posts
    1,076
    Plugin Contributions
    15

    Default Re: + or - to add qty to cart mod

    Couple of ways to do the spinner, this is what my line looks like..

    Code:
                  // show the quantity box
             $the_button = '<div id="cartAdd-wrapper" class="btn-group"><span id="down" class="btn" onclick="updateSpinner(this);"><i class="fa fa-arrow-left"></i></span><input type="text" id="content" class="small" name="cart_quantity" value="' . (zen_get_buy_now_qty($_GET['products_id'])) . '" maxlength="3" size="3" /><span id="up" class="btn" onclick="updateSpinner(this);"><i class="fa fa-arrow-right"></i></span></div><br />' . zen_get_products_quantity_min_units_display((int)$_GET['products_id']) .  zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '';
    The problem with spinners is you can bypass the max and min quantities for the product. The answer is setting a small script at the top of the tpl_product_info.php page to prevent it and called from the onclick event..
    Stops it from going below 0 and grater than max product amounts..
    Code:
    <script type="text/javascript">
    function updateSpinner(obj)
    {
        var contentObj = document.getElementById("content");
        var value = parseInt(contentObj.value);
        if(obj.id == "down") {
            value--;
           if (value < 0) {
               value = 0;
           }
        } else {
            value++;
            if (value >= <?php echo $products_quantity; ?>) {
                value = <?php echo $products_quantity; ?>
                }
        }
        contentObj.value = value;
    }
    </script>
    I use Font Awesome arrows but you can change that to whatever you need..
    To make the Font Awesome to behave like buttons, you need some css for the class btn.
    in your stylesheet_TEMPLATE.css
    Code:
    .btn {color: #710505;
        cursor:pointer;
        }
    
    .btn i{
    font-size:170%;
    color:#520303;
    padding:1px;
    border:1px solid #520303;
    min-width:10px;
    background:#dbdbea;transition:background 2s ease;-webkit-transition:background 2s ease;-moz-transition:background 2s ease;-o-transition:background 2s ease;
    
    } 
    .btn i:hover{background:#171717;color:#fff;border:1px solid #171716;}
    The css is a bit old, beleave RGBA makes it allot easier now..
    Dave
    Always forward thinking... Lost my mind!

 

 

Similar Threads

  1. Replies: 2
    Last Post: 22 May 2011, 05:13 PM
  2. qty and add to cart
    By procella in forum Customization from the Admin
    Replies: 1
    Last Post: 30 Sep 2008, 07:50 AM
  3. Add to cart qty
    By dirtyweekender in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 18 Mar 2008, 02:49 PM
  4. add to cart vs. qty in shopping cart
    By cpk in forum Customization from the Admin
    Replies: 5
    Last Post: 5 Sep 2006, 03:53 AM

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