I have the plus minus on my website
includes/modules/pages/shopping_cart/header.php
Code:
// BOF changes using script for min max //
$quantityField = '<span style="border-top-left-radius: 2px;border-bottom-left-radius:2px;" class="min_' . str_replace(':', '', $products[$i]['id']) . ' button">-' .'</span>' . zen_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4" name="qty" maxlength="4" id="qty" class="cart_input_'.str_replace(':', '', $products[$i]['id']).' "'). '<span style="border-top-right-radius: 2px;border-bottom-right-radius:2px;" class="plus_' . str_replace(':', '', $products[$i]['id']) . ' button">+</span>';
// EOF changes using script for min max //
includes/templates/theme871/templates/tpl_shopping_cart_default.php
Code:
<!-- script for min max -->
<?php
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
?>
<script>jQuery(function(){
var j = jQuery; //Just a variable for using jQuery without conflicts
var addInput = '.cart_input_<?php echo str_replace(':', '', $products[$i]['id']); ?>'; //This is the unique class identified by product's id of the input you are changing
var n = <?php echo (empty($products[$i]['quantity']) ? '0' : $products[$i]['quantity']); ?>; //n is equal to the quantity in the cart
//Set default value to n (n = cart quantity)
j(addInput).val(n);
//On click add 1 to n
j('.plus_<?php echo str_replace(':', '', $products[$i]['id']); ?>').on('click', function(){
j(addInput).val(++n);
})
j('.min_<?php echo str_replace(':', '', $products[$i]['id']); ?>').on('click', function(){
//If n is bigger or equal to 1 subtract 1 from n
if (n >= 1) {
j(addInput).val(--n);
} else {
//Otherwise do nothing
}
});
});</script>
<?php
}
?>
<!-- eof script for max -->
includes/templates/your_template/templates/tpl_product_info_display.php
Code:
// show the quantity box
$the_button = '<div class="qty-wrapper">
<div class="qty-box" id="qty-box">
<a href="#" class="btn btn-descrease" id="btn-descrease"><span class="nmn-icon-minus"></span></a>
<input type="text" name="cart_quantity" id="cart_quantity" value="' . (zen_get_buy_now_qty($_GET['products_id'])) . '" maxlength="4" size="2" /><a href="#" class="btn btn-increase" id="btn-increase"><span class="nmn-icon-plus"></span></a></div>' . zen_draw_hidden_field('products_id', (int)$_GET['products_id']) . zen_image_submit(BUTTON_IMAGE_IN_CART, BUTTON_IN_CART_ALT) . '
</div>';
}
Bookmarks