Dieses Dokuwiki verwendet ein von Anymorphic Webdesign erstelltes Thema.

Add Plus and Minus Buttons

A fairly simple mod which will add a plus and minus button with a quanitity box to your product info page.


  • Cut and paste the following code into a text editor and save as plusminus.js and put it in a folder called javascript in your catalog folder.

function TextBox_AddToIntValue(targetId,addToValue)
    var input = document.getElementById(targetId);
    var textInt = parseInt(input.value);
        textInt = 0;
    input.value = textInt + addToValue;
    if (input.value <= 0) {
        input.value = 0;


  • Add this code to your catalog/templates/<your template>/content/product_info.tpl.php file.
  • You will need some images for the plus and minus buttons - try here ... (the ones by famfam under Icons are very good)

                <!-- ADDED PLUS AND MINUS BUTTONS PGM -->
                <script type="text/javascript" src="javascript/plusminus.js"></script>
                    <td class="main" align="right" width="250">
                            <table width="200" border="0" cellpadding="0">
                                  <tr height="0">
                                    <td width="25"></td>
                                    <td width="25"></td>
                                    <td width="150">
                                    <td align="center"><img src="<?php echo DIR_WS_IMAGES .'icons/plus.png' ?>" onclick="TextBox_AddToIntValue('product-quantity-{{product.id}}',+1)" /></td>
                                    <td rowspan="2" align="center"><input name="quantity" type="text" class="moduleRow" id="product-quantity-{{product.id}}" style="text-align:center" onkeyup="changeQty('field');" value="1" size="2" maxlength="2" /></td>
                                    <td rowspan="2" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>
                                    <td align="center"><img src="<?php echo DIR_WS_IMAGES .'icons/minus.png' ?>" onclick="TextBox_AddToIntValue('product-quantity-{{product.id}}',-1)" /></td>
                <!-- ADDED PLUS AND MINUS BUTTONS PGM -->

Change to application_top.php

Open catalog/includes/application_top.php and find the case 'add_product' and change the +1 to +$HTTP_POST_VARS['quantity']

  • Final code should look like this:
Please note the +$HTTP_POST_VARS['quantity'] right at the end of the code below - without this it will not work!

// customer adds a product from the products page
// BOF: MOD - QT Pro
//    case 'add_product' :    if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
//                              $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);
      case 'add_product' :    if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id']) && ($HTTP_POST_VARS['products_id']==(int)$HTTP_POST_VARS['products_id'])) {
        if (isset($HTTP_POST_VARS['attrcomb']) && (preg_match("/^d{1,10}-d{1,10}(,d{1,10}-d{1,10})*$/",$HTTP_POST_VARS['attrcomb']))) {
          foreach ($attrlist as $attr) {
            list($oid, $oval)=explode('-',$attr);
            if (is_numeric($oid) && $oid==(int)$oid && is_numeric($oval) && $oval==(int)$oval)
        if (isset($HTTP_POST_VARS['id']) && is_array($HTTP_POST_VARS['id'])) {
          foreach ($HTTP_POST_VARS['id'] as $key=>$val) {
            if (is_numeric($key) && $key==(int)$key && is_numeric($val) && $val==(int)$val)
              $attributes=$attributes + $HTTP_POST_VARS['id'];
        $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $attributes))+$HTTP_POST_VARS['quantity'], $attributes);
// EOF: MOD - QT Pro

  • Bookmark at
  • Bookmark "Add Plus and Minus Buttons" at Reddit
  • Bookmark "Add Plus and Minus Buttons" at Google
  • Bookmark "Add Plus and Minus Buttons" at Facebook
  • Bookmark "Add Plus and Minus Buttons" at Twitter
  • Bookmark "Add Plus and Minus Buttons" at Slashdot
plus_and_minus_buttons.txt ยท Last modified: 2009/12/03 12:37 by pgmarshall
You are here: startplus_and_minus_buttons
Dieses Dokuwiki verwendet ein von Anymorphic Webdesign erstelltes Thema.
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0