Answer the question
In order to leave comments, you need to log in
How to fix the problem with changing the number of products (not +1) added to the cart?
Good afternoon. Help to understand, please. For some reason, on the flowers-penza58.ru website, when changing the quantity of a variable product added to the basket, the + and - switches are added not one product at a time, but 2, 3 or more in one click. Where to dig? Maybe you know what the problem is? At what I noticed that it depends on the chosen variation of the product.
Here are the lines responsible for this field in the topic:
if ($('input[type=number][name=quantity]').length) {
var $input = $('input[type=number][name=quantity]');
$input.after('<span class="tm-qty-minus"></span><span class="tm-qty-plus"></span>');
$('.variations_form ').find('.single_variation').on('show_variation', function (event, variation) {
initQty();
});
$('.variations_form ').on('reset_data', function (event) {
$input.attr('min', '').val('1');
initQty();
});
initQty();
}
function initQty() {
var min = $input.attr('min'),
max = $input.attr('max');
if ('' !== min) {
$input.removeAttr('readonly');
$('.tm-qty-minus').on('click', function () {
if ($input.val() > min) $input.val($input.val() - 1);
});
$('.tm-qty-plus').on('click', function () {
if (typeof max === typeof undefined || $input.val() < max || '' === max) $input.val(parseInt($input.val()) + 1);
});
}
else {
$('.tm-qty-minus, .tm-qty-plus').off('click');
$input.attr('readonly', 'readonly');
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question