[FIX] website_sale_aplicoop: step de cantidad correcto tras filtrar categoría. El JS ahora usa data-quantity-step generado por backend, evitando sobrescribir el step correcto en inputs de productos a peso/unidad.

This commit is contained in:
snt 2026-02-25 17:17:06 +01:00
parent 7b343ef198
commit 92b35ccd6d

View file

@ -682,31 +682,30 @@
// First, adjust quantity steps for all existing inputs
var unitInputs = document.querySelectorAll(".product-qty");
console.log("=== ADJUSTING QUANTITY STEPS ===");
console.log("=== ADJUSTING QUANTITY STEPS (from data-quantity-step) ===");
console.log("Found " + unitInputs.length + " quantity inputs");
for (var j = 0; j < unitInputs.length; j++) {
var form = unitInputs[j].closest(".add-to-cart-form");
var uomCategory = form.getAttribute("data-uom-category") || "Unit";
// If category is "Unit" (English) or "Units" (plural), use step=1 (no decimals)
// If other category (Weight, Volume, etc.), use step=0.1 (with decimals)
var step = form ? form.getAttribute("data-quantity-step") : null;
if (!step) step = "1";
unitInputs[j].step = step;
unitInputs[j].min = step;
unitInputs[j].value = "1";
// Para debug, también marcamos si es unidad o no
var uomCategory = form ? form.getAttribute("data-uom-category") : "";
var isUnitCategory = /^unit/i.test(uomCategory) || /^unidad/i.test(uomCategory);
if (isUnitCategory) {
unitInputs[j].step = "1";
unitInputs[j].min = "1";
unitInputs[j].value = "1";
unitInputs[j].dataset.isUnit = "true";
console.log("Input #" + j + ': UoM="' + uomCategory + '" → step=1 (integer)');
} else {
// Para peso, volumen, etc.
unitInputs[j].step = "0.1";
unitInputs[j].min = "0.1";
unitInputs[j].value = "1";
unitInputs[j].dataset.isUnit = "false";
console.log("Input #" + j + ': UoM="' + uomCategory + '" → step=0.1 (decimal)');
}
unitInputs[j].dataset.isUnit = isUnitCategory ? "true" : "false";
console.log(
"Input #" +
j +
": step=" +
step +
', UoM="' +
uomCategory +
'", isUnit=' +
unitInputs[j].dataset.isUnit
);
}
console.log("=== END ADJUSTING QUANTITY STEPS ===");