Directement au contenu
Menu
FerroBellissimo
Boutique
Tous les cadres de lit
Cadres de lit Moderno Chico
Cadre de lit Classico Eleganza
Lits à baldaquin
Lits en laiton
Matelas
Sommiers à lattes
Sommiers
Meubles
Bonnes affaires
A propos de nous
Salle d'exposition
Blog
Blog
Histoires de lit
Contactez nous
Mobilier
Bonnes affaires
FerroBellissimo
FerroBellissimo
Longueur
Longueur
Nombre
(0
dans le panier)
Nombre de réductions pour la longueur
Augmenter le nombre de longueurs
Prix normal
100,00 EUROS
Prix normal
Prix spécial
EUR 100.00
Prix unitaire
/
par
Offre
En rupture de stock
Taxes incluses.
Ajouter au panier
Impossible de charger la disponibilité pour l'enlèvement
Renouveler
Voir tous les détails
Description
Informations techniques
Informations sur la livraison
Le choix d'une sélection entraîne l'actualisation complète de la page.
S'ouvre dans une nouvelle fenêtre.
// 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(); });