Direkt zum Inhalt
Menü
FerroBellissimo
Shop
Alle Bettrahmen
Moderno Chico Bettrahmen
Classico Eleganza Bettrahmen
Himmelbetten
Betten aus Messing
Matratzen
Lattenroste
Boxspringbetten
Möbel
Schnäppchen
Über uns
Showroom
Blog
Blog
Bettgeschichten
Kontakt
Möbel
Schnäppchen
FerroBellissimo
FerroBellissimo
Länge
Länge
Nummer
(0
im Warenkorb)
Anzahl der Kürzungen für Länge
Nummer für Länge erhöhen
Normaler Preis
88,40 EUR
Normaler Preis
Sonderpreis
88,40 EUR
Preis pro Einheit
/
pro
Angebot
Ausverkauft
Inklusive Steuern.
In den Warenkorb legen
Verfügbarkeit zur Abholung kann nicht geladen werden
Erneuern Sie
Alle Details anzeigen
Beschreibung
Technische Informationen
Informationen zur Lieferung
Die Auswahl einer Auswahl führt dazu, dass die Seite vollständig aktualisiert wird.
Wird in einem neuen Fenster geöffnet.
// This code should be added to your theme.liquid or appropriate template file const ShopifyUpsell = { // Configuration config: { // Discount code to apply when conditions are met discountCode: '4MQM5MDKETA4', // Product types that trigger the discount triggerProducts: { bedframe: { type: 'Metal Bed Frame', // Add your bed frame product IDs here productIds: [brackley, capileira] }, mattress: { type: 'Mattress', // Add your mattress product IDs here productIds: [heaven] } } }, // Initialize the upsell system init: function() { console.log('Initializing upsell system...'); this.setupEventListeners(); this.checkCartAndApplyDiscount(); console.log('Upsell system initialized'); }, // Set up event listeners for cart changes setupEventListeners: function() { // Listen for cart updates document.addEventListener('cart:updated', this.handleCartUpdate.bind(this)); // Listen for items being added to cart document.addEventListener('product:added', this.handleProductAdded.bind(this)); }, // Handle cart updates handleCartUpdate: async function(event) { await this.checkCartAndApplyDiscount(); }, // Handle when products are added to cart handleProductAdded: async function(event) { await this.checkCartAndApplyDiscount(); }, // Check cart contents and apply discount if conditions are met checkCartAndApplyDiscount: async function() { try { // Get current cart contents const response = await fetch('/cart.js'); const cart = await response.json(); console.log('Cart contents:', cart.items); console.log('Checking cart for bundle products...'); let hasBedframe = false; let hasMattress = false; // Check if cart has both bed frame and mattress cart.items.forEach(item => { console.log('Checking product:', item.product_id); console.log('Product type:', item.product_type); if (this.config.triggerProducts.bedframe.productIds.includes(item.product_id)) { console.log('Found bedframe'); hasBedframe = true; } if (this.config.triggerProducts.mattress.productIds.includes(item.product_id)) { console.log('Found mattress'); hasMattress = true; } }); // If both products are present, apply discount if (hasBedframe && hasMattress) { await this.applyDiscount(); } else { await this.removeDiscount(); } } catch (error) { console.error('Error checking cart:', error); } }, // Apply the discount code applyDiscount: async function() { try { const response = await fetch('/discount/' + this.config.discountCode); if (!response.ok) { throw new Error('Failed to apply discount'); } // Refresh the cart display this.refreshCart(); } catch (error) { console.error('Error applying discount:', error); } }, // Remove the discount code removeDiscount: async function() { try { const response = await fetch('/discount/clear'); if (!response.ok) { throw new Error('Failed to remove discount'); } // Refresh the cart display this.refreshCart(); } catch (error) { console.error('Error removing discount:', error); } }, // Refresh the cart display refreshCart: async function() { try { const response = await fetch('?section_id=cart'); const html = await response.text(); // Update cart section with new HTML const cartSection = document.getElementById('cart'); if (cartSection) { cartSection.innerHTML = html; } } catch (error) { console.error('Error refreshing cart:', error); } } }; // Initialize the upsell system when the page loads document.addEventListener('DOMContentLoaded', function() { ShopifyUpsell.init(); });