diff --git a/app/templates/shop/cart.html b/app/templates/shop/cart.html index 1c261914..f8d773f3 100644 --- a/app/templates/shop/cart.html +++ b/app/templates/shop/cart.html @@ -169,38 +169,47 @@ {% block extra_scripts %} {% endblock %} diff --git a/app/templates/shop/product.html b/app/templates/shop/product.html index 2515f2ff..b40625c5 100644 --- a/app/templates/shop/product.html +++ b/app/templates/shop/product.html @@ -216,47 +216,58 @@ window.PRODUCT_ID = {{ product_id }}; window.VENDOR_ID = {{ vendor.id }}; document.addEventListener('alpine:init', () => { - Alpine.data('productDetail', () => ({ - ...shopLayoutData(), + Alpine.data('productDetail', () => { + const baseData = shopLayoutData(); - // Data - product: null, - relatedProducts: [], - loading: false, - addingToCart: false, - quantity: 1, - selectedImage: null, - vendorId: window.VENDOR_ID, - productId: window.PRODUCT_ID, + return { + ...baseData, - // Computed properties - get canAddToCart() { - return this.product?.is_active && - this.product?.available_inventory > 0 && - this.quantity > 0 && - this.quantity <= this.product?.available_inventory; - }, + // Data + product: null, + relatedProducts: [], + loading: false, + addingToCart: false, + quantity: 1, + selectedImage: null, + vendorId: window.VENDOR_ID, + productId: window.PRODUCT_ID, - get totalPrice() { - const price = this.product?.sale_price || this.product?.price || 0; - return price * this.quantity; - }, + // Computed properties + get canAddToCart() { + return this.product?.is_active && + this.product?.available_inventory > 0 && + this.quantity > 0 && + this.quantity <= this.product?.available_inventory; + }, - get hasAdditionalDetails() { - return this.product?.marketplace_product?.gtin || - this.product?.condition || - this.product?.marketplace_product?.color || - this.product?.marketplace_product?.size || - this.product?.marketplace_product?.material; - }, + get totalPrice() { + const price = this.product?.sale_price || this.product?.price || 0; + return price * this.quantity; + }, - // Initialize - async init() { - console.log('[SHOP] Product detail page initializing...'); - console.log('[SHOP] Product ID:', this.productId); - console.log('[SHOP] Vendor ID:', this.vendorId); - await this.loadProduct(); - }, + get hasAdditionalDetails() { + return this.product?.marketplace_product?.gtin || + this.product?.condition || + this.product?.marketplace_product?.color || + this.product?.marketplace_product?.size || + this.product?.marketplace_product?.material; + }, + + // Initialize + async init() { + console.log('[SHOP] Product detail page initializing...'); + + // Call parent init to set up sessionId + if (baseData.init) { + baseData.init.call(this); + } + + console.log('[SHOP] Product ID:', this.productId); + console.log('[SHOP] Vendor ID:', this.vendorId); + console.log('[SHOP] Session ID:', this.sessionId); + + await this.loadProduct(); + }, // Load product details async loadProduct() { @@ -384,7 +395,8 @@ document.addEventListener('alpine:init', () => { this.addingToCart = false; } } - })); + }; + }); }); {% endblock %}