Forums / General Questions / Adding the ++ & -- operators to cart.

Adding the ++ & -- operators to cart.

Views: 486

Results 1 to 3 of 3
18 Apr 2015, 1:32 AM
#1
spacemonkey avatar

spacemonkey

Zen Follower

Join Date:
Nov 2013
Location:
Dorset, UK
Posts:
124
Plugin Contributions:
0

Adding the ++ & -- operators to cart.

Hi,

I am looking for a way to add the ++ & -- operators to my tpl_shopping_cart_default.php.

I have found this in file tpl_shopping_cart_default.php:

<td class="cartQuantity">
            <span class="mobile-only"><?php echo TABLE_HEADING_QUANTITY; ?>:</span>
            <?php echo $product['quantityField'] . '<span class="alert bold">' . $product['flagStockCheck'] . '</span>' . $product['showMinUnits'];
//              }
            ?>

Can anyone please help me turn this into working increment and decrement icons for my cart quantity.

Thanks

18 Apr 2015, 10:24 AM
#2
spacemonkey avatar

spacemonkey

Zen Follower

Join Date:
Nov 2013
Location:
Dorset, UK
Posts:
124
Plugin Contributions:
0

Re: Adding the ++ & -- operators to cart.

Hi everyone.

Ok have worked it a bit further.

Below is the whole of my table data for cart items. Note: some of the lines have been commented out to display the cart with the quantity box displayed and an editable and updateable value. I simply am looking for help to add increment and decrement icons as well as the update and remove.

Cart image:
Attachment #15191

<table id="cartContentsDisplay">
     <tr class="tableHeading">
        <th scope="col" id="scImageHeading"></th>
        <th scope="col" id="scProductsHeading"><?php echo TABLE_HEADING_PRODUCTS; ?></th>
        <th scope="col" id="scUnitHeading"><?php echo TABLE_HEADING_PRICE; ?></th>
        <th scope="col" id="scQuantityHeading"><?php echo TABLE_HEADING_QUANTITY; ?></th>
        <th scope="col" id="scTotalHeading"><?php echo TABLE_HEADING_TOTAL; ?></th>
     </tr>
         <!-- Loop through all products /-->
        <!-- <th scope="col" id="scRemoveHeading"> </th> -->
<?php
  foreach ($productArray as $product) {
?>
     <tr class="<?php echo $product['rowClass']; ?>">
        <td class="productImage">
            <a href="<?php echo $product['linkProductsName']; ?>"><span id="cartImage" class="back"><?php echo $product['productsImage']; ?></span></a>
        </td>
        <td class="cartProductDisplay">
            <span class="mobile-only"><?php echo TABLE_HEADING_PRODUCTS; ?>:</span>
            <a href="<?php echo $product['linkProductsName']; ?>"><span id="cartProdTitle"><?php echo $product['productsName'] . '<span class="alert bold">' . $product['flagStockCheck'] . '</span>'; ?></span></a>
            <?php
              echo $product['attributeHiddenField'];
              if (isset($product['attributes']) && is_array($product['attributes'])) {
              echo '<div class="cartAttribsList">';
              echo '<ul>';
                reset($product['attributes']);
                foreach ($product['attributes'] as $option => $value) {
            ?>

                      <li><?php echo $value['products_options_name'] . TEXT_OPTION_DIVIDER . nl2br($value['products_options_values_name']); ?></li>

            <?php
                }
              echo '</ul>';
              echo '</div>';
              }
            ?>
        </td>
       
        <td class="cartUnitDisplay">
            <span class="mobile-only"><?php echo TABLE_HEADING_PRICE; ?>:</span>
            <?php echo $product['productsPriceEach']; ?>
        </td>
        <td class="cartQuantity">
            <span class="mobile-only"><?php echo TABLE_HEADING_QUANTITY; ?>:</span>
            <?php
//              if ($product['flagShowFixedQuantity']) {
//                echo $product['showFixedQuantityAmount'] . '<span class="alert bold">' . $product['flagStockCheck'] . '</span>' . $product['showMinUnits'];
//              } else {
                echo $product['quantityField'] . '<span class="alert bold">' . $product['flagStockCheck'] . '</span>' . $product['showMinUnits'];
//              }
            ?>
            <div class="qty-btns">
                <?php
                  if ($product['buttonUpdate'] == '') {
                    echo '' ;
                  } else {
                    echo $product['buttonUpdate'];
                  }
                ?>

                <?php
                    if ($product['buttonDelete']) {
                ?>
                    <a href="<?php echo zen_href_link(FILENAME_SHOPPING_CART, 'action=remove_product&product_id=' . $product['id']); ?>">Remove</a>
                <?php
                    }
                    if ($product['checkBoxDelete'] ) {
                        // echo zen_draw_checkbox_field('cart_delete[]', $product['id']);
                    }
                ?>
            </div>
        </td>
        <td class="cartTotalDisplay">
            <span class="mobile-only label">
                <?php echo TABLE_HEADING_TOTAL; ?>:
            </span>
            <?php echo $product['productsPrice']; ?>
        </td>
    </tr>
    <?php
      } // end foreach ($productArray as $product)
    ?>
    <!-- Finished loop through all products /-->
</table>

Open to suggestions.

Thanks in advance.

18 Apr 2015, 10:31 AM
#3
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Adding the ++ & -- operators to cart.

Don't have "the" solution, but if you want the values to immediately change without page reload then will need to use something like javascript/jQuery, otherwise could use new buttons that upon click modify the values. By effectively performing an update/refresh operation of the page. This second option would be a bit "slower" for the user as the page would need to be reloaded on every click.

Regardless of the method, need to take into account things like minimum quantity, maximum quantity and intervals (units) like that must purchase in groups of two.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...