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