I am using Suivant ReadyTheme.
I have certain products that require a minimum quantity of 5.
For those products, I have created a custom filed (minqty) which I use as a conditional on the PROD page.
What I did was add a script right below the Quantity Incrementer in the js scripts file (see below)
On the PROD page, my conditional (if a product has a minimum of 5) does indeed call the #js-increase-quantity-5/#js-decrease-quantity-5 script.
However, the function (increase + or decrease -) on the PRODUCT page does not work.
Any reason for this not working?
ORIGINAL
// ---- Quantity Incrementer ---- //
$('#js-increase-quantity').on('click', function () {
var $qty = $(this).siblings('input'),
currentVal = parseInt($qty.val());
if (!isNaN(currentVal)) {
$qty.val(currentVal + 1).change();
};
});
$('#js-decrease-quantity').on('click', function () {
var $qty = $(this).siblings('input'),
currentVal = parseInt($qty.val());
if (!isNaN(currentVal) && currentVal > 1) {
$qty.val(currentVal - 1).change();
};
});
FOR PRODUCTS NEEDING 5 OR MORE
// ---- Minimum Quantity 5 Incrementer ---- //
$('#js-increase-quantity-5').on('click', function () {
var $qty = $(this).siblings('input'),
currentVal = parseInt($qty.val());
if (!isNaN(currentVal)) {
$qty.val(currentVal + 1).change();
};
});
$('#js-decrease-quantity-5').on('click', function () {
var $qty = $(this).siblings('input'),
currentVal = parseInt($qty.val());
if (!isNaN(currentVal) && currentVal > 5) {
$qty.val(currentVal - 1).change();
};
});
I have certain products that require a minimum quantity of 5.
For those products, I have created a custom filed (minqty) which I use as a conditional on the PROD page.
What I did was add a script right below the Quantity Incrementer in the js scripts file (see below)
On the PROD page, my conditional (if a product has a minimum of 5) does indeed call the #js-increase-quantity-5/#js-decrease-quantity-5 script.
However, the function (increase + or decrease -) on the PRODUCT page does not work.
Any reason for this not working?
ORIGINAL
// ---- Quantity Incrementer ---- //
$('#js-increase-quantity').on('click', function () {
var $qty = $(this).siblings('input'),
currentVal = parseInt($qty.val());
if (!isNaN(currentVal)) {
$qty.val(currentVal + 1).change();
};
});
$('#js-decrease-quantity').on('click', function () {
var $qty = $(this).siblings('input'),
currentVal = parseInt($qty.val());
if (!isNaN(currentVal) && currentVal > 1) {
$qty.val(currentVal - 1).change();
};
});
FOR PRODUCTS NEEDING 5 OR MORE
// ---- Minimum Quantity 5 Incrementer ---- //
$('#js-increase-quantity-5').on('click', function () {
var $qty = $(this).siblings('input'),
currentVal = parseInt($qty.val());
if (!isNaN(currentVal)) {
$qty.val(currentVal + 1).change();
};
});
$('#js-decrease-quantity-5').on('click', function () {
var $qty = $(this).siblings('input'),
currentVal = parseInt($qty.val());
if (!isNaN(currentVal) && currentVal > 5) {
$qty.val(currentVal - 1).change();
};
});
Comment