Meteen naar de content
Menu
FerroBellissimo
Shop
Alle bedframes
Moderno Chico bedframes
Classico Eleganza bedframes
Hemelbedden
Messing bedden
Matrassen
Lattenbodems
Boxsprings
Meubels
Koopjes
Over ons
Showroom
Blog
Blog
Bedverhalen
Contacteer ons
Meubels
Koopjes
FerroBellissimo
FerroBellissimo
Split topper (voor verstelbare bodems)
Split topper (voor verstelbare bodems)
Aantal
(
0
in winkelwagen)
Aantal verlagen voor Split topper (voor verstelbare bodems)
Aantal verhogen voor Split topper (voor verstelbare bodems)
Normale prijs
€60,00 EUR
Normale prijs
Aanbiedingsprijs
€60,00 EUR
Eenheidsprijs
/
per
Aanbieding
Uitverkocht
Belastingen inbegrepen.
Aan winkelwagen toevoegen
Kan beschikbaarheid voor afhalen niet laden
Vernieuwen
Alle details bekijken
Beschrijving
Technische informatie
Leveringsinformatie
Een selectie kiezen resulteert in het geheel verversen van de pagina.
Opent in een nieuw venster.
// 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] }, mattress: { type: 'Mattress', // Add your mattress product IDs here productIds: [heaven] } } }, // Initialize the upsell system init: function() { this.setupEventListeners(); this.checkCartAndApplyDiscount(); }, // 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(); let hasBedframe = false; let hasMattress = false; // Check if cart has both bed frame and mattress cart.items.forEach(item => { if (this.config.triggerProducts.bedframe.productIds.includes(item.product_id)) { hasBedframe = true; } if (this.config.triggerProducts.mattress.productIds.includes(item.product_id)) { 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(); });