Files
torebki-fabiola.pl/wp-content/themes/dotspice/js/woocommerce-script.js
2026-03-05 13:07:40 +01:00

61 lines
1.2 KiB
JavaScript

"use strict";
(function ($) {
/**
* Document ready function
*/
$(document).ready(function () {
/**
* Woocommerce Plus/Minus
*/
$(document).on('click', '.quantity-buttons button', function () {
var btn = $(this),
qty = btn.closest('.quantity-buttons').prev().find('input.qty'),
val = parseInt(qty.val()),
max = parseInt(qty.attr('max')),
min = parseInt(qty.attr('min')),
step = parseInt(qty.attr('step'));
if (btn.is('.plus')) {
if (max && (max <= val)) {
qty.val(max);
} else {
qty.val(val + step);
}
}
else if (btn.is('.minus')) {
if (min && (min >= val)) {
qty.val(min);
} else if (val > 1) {
qty.val(val - step);
}
}
if ($('body').hasClass('woocommerce-cart')) {
qty.change();
}
return false;
});
/**
* Woocommerce widget_product_categories
*/
$(document).on('click', '.widget_product_categories .cat-parent', function (e) {
if (e.target == this) {
if (!$(this).is('.current-cat') && !$(this).is('.current-cat-parent')) {
$(this).toggleClass('active');
$(this).find('> .children').stop(true, true).slideToggle(300);
}
}
});
});
})(jQuery);