[FIX] website_sale_aplicoop: save-cart-btn listener was never attached
The save-cart-btn event listener was placed after a return statement in _attachEventListeners(), so it was never executed. Moved it to the correct location inside the _cartCheckoutListenersAttached block alongside the other cart/checkout buttons (reload-cart-btn, confirm-order-btn, etc.).
This commit is contained in:
parent
b07b7dc671
commit
267059fa1b
1 changed files with 12 additions and 17 deletions
|
|
@ -652,6 +652,18 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Button to save cart as draft (in My Cart header - shop pages)
|
||||||
|
var saveCartBtn = document.getElementById("save-cart-btn");
|
||||||
|
console.log("[_attachEventListeners] save-cart-btn found:", !!saveCartBtn);
|
||||||
|
|
||||||
|
if (saveCartBtn) {
|
||||||
|
saveCartBtn.addEventListener("click", function (e) {
|
||||||
|
console.log("[CLICK] save-cart-btn clicked");
|
||||||
|
e.preventDefault();
|
||||||
|
self._saveCartAsDraft();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this._cartCheckoutListenersAttached = true;
|
this._cartCheckoutListenersAttached = true;
|
||||||
console.log("[_attachEventListeners] Checkout listeners attached (one-time)");
|
console.log("[_attachEventListeners] Checkout listeners attached (one-time)");
|
||||||
}
|
}
|
||||||
|
|
@ -784,23 +796,6 @@
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Button to save cart as draft (in My Cart header)
|
|
||||||
// Only attach ONCE
|
|
||||||
if (!this._cartCheckoutListenersAttached) {
|
|
||||||
console.log("[_attachEventListeners] Attempting to attach checkout listeners...");
|
|
||||||
|
|
||||||
var savCartBtn = document.getElementById("save-cart-btn");
|
|
||||||
console.log("[_attachEventListeners] save-cart-btn found:", !!savCartBtn);
|
|
||||||
|
|
||||||
if (savCartBtn) {
|
|
||||||
savCartBtn.addEventListener("click", function (e) {
|
|
||||||
console.log("[CLICK] save-cart-btn clicked");
|
|
||||||
e.preventDefault();
|
|
||||||
self._saveCartAsDraft();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_addToCart: function (productId, productName, productPrice, quantity) {
|
_addToCart: function (productId, productName, productPrice, quantity) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue