You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

28 lines
911 B

window.initPlusMinusBox = function () {
/*----------------------------
Cart Plus Minus Button
------------------------------ */
var CartPlusMinus = $('.cart-plus-minus');
CartPlusMinus.prepend('<div class="dec qtybutton">-</div>');
CartPlusMinus.append('<div class="inc qtybutton">+</div>');
$(".qtybutton").on("click", function () {
var newVal;
var $button = $(this);
var oldValue = $button.parent().find("input").val();
if ($button.text() === "+") {
newVal = parseFloat(oldValue) + 1;
} else {
// Don't allow decrementing below zero
if (oldValue > 0) {
newVal = parseFloat(oldValue) - 1;
} else {
newVal = 1;
}
}
$button.parent().find("input").val(newVal).request();
});
};
(function ($) {
initPlusMinusBox();
})(jQuery);