Fix double-click cart/wishlist issue: prevent duplicate initialization
This commit is contained in:
@@ -388,6 +388,11 @@
|
||||
|
||||
// Initialize when DOM is ready
|
||||
const initializeComponents = () => {
|
||||
// Skip if shop-system.js already initialized
|
||||
if (window.ShopSystem?.isInitialized) {
|
||||
console.log("[cart.js] Skipping initialization - shop-system.js already loaded");
|
||||
return;
|
||||
}
|
||||
console.log("[cart.js] Initializing ShoppingCart and Wishlist components");
|
||||
new ShoppingCart();
|
||||
new Wishlist();
|
||||
|
||||
@@ -700,6 +700,9 @@
|
||||
|
||||
console.log("[ShopSystem] AppState compatibility layer installed");
|
||||
|
||||
// Mark as initialized to prevent cart.js duplicate initialization
|
||||
window.ShopSystem.isInitialized = true;
|
||||
|
||||
// Setup dropdowns when DOM is ready
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
|
||||
Reference in New Issue
Block a user