How can one serum match every skin tone?
Tested & Approved
Our Bestsellers
85,000+ Glowing Reviews
From Woman Like You
Try it Risk-Free for 30 Days
FAQ
. Une fois. ============================================================ */ (function () { if (window.hlyAtcPublisherLoaded) return; window.hlyAtcPublisherLoaded = true; var DEBUG = true; /* logs [hly-atc] dans la console ; false en prod */ function log(msg, extra) { if (DEBUG) console.log('[hly-atc] ' + msg, extra || ''); } function currency() { try { if (window.Shopify && Shopify.currency && Shopify.currency.active) { return Shopify.currency.active; } } catch (e) {} return 'USD'; } /* Publie vers la couche Evenements client (le pixel personnalise ecoute). Shopify.analytics peut arriver apres nous : petite file d'attente. */ var queue = []; function publish(payload) { if (window.Shopify && Shopify.analytics && typeof Shopify.analytics.publish === 'function') { try { Shopify.analytics.publish('hly_add_to_cart', payload); log('evenement publie', payload); } catch (e) { console.warn('[hly-atc] publish en echec :', e); } } else { queue.push(payload); log('Shopify.analytics pas encore pret, mis en attente'); } } setInterval(function () { if (!queue.length) return; if (window.Shopify && Shopify.analytics && typeof Shopify.analytics.publish === 'function') { var q = queue.splice(0, queue.length); q.forEach(publish); } }, 500); /* Transforme la reponse de /cart/add.js (un item ou {items:[...]}) en payload propre : variantes, quantites, valeur totale */ function payloadFromResponse(data) { var items = []; if (data && data.items && data.items.length) { items = data.items; } else if (data && (data.id || data.variant_id)) { items = [data]; } if (!items.length) return null; var out = []; var total = 0; items.forEach(function (it) { var priceCents = (it.final_price != null ? it.final_price : it.price) || 0; var qty = it.quantity || 1; var price = priceCents / 100; total += price * qty; out.push({ variantId: String(it.variant_id || it.id || ''), productId: String(it.product_id || ''), title: it.product_title || it.title || '', quantity: qty, price: price }); }); return { items: out, value: Math.round(total * 100) / 100, currency: currency() }; } function handleJsonText(text) { try { var data = JSON.parse(text); var payload = payloadFromResponse(data); if (payload) publish(payload); } catch (e) { /* reponse non JSON : ignore */ } } var ADD_RE = /\/cart\/add(\.js)?([?#]|$)/; /* ---- Interception fetch (se chaine proprement avec les wrappers existants) ---- */ var origFetch = window.fetch; if (origFetch) { window.fetch = function (input) { var url = ''; try { url = (typeof input === 'string') ? input : ((input && input.url) || ''); } catch (e) {} var p = origFetch.apply(this, arguments); if (ADD_RE.test(url)) { p.then(function (res) { if (res && res.ok) { try { res.clone().text().then(handleJsonText).catch(function () {}); } catch (e) {} } return res; }).catch(function () {}); } return p; }; } /* ---- Interception XHR (certaines apps l'utilisent encore) ---- */ var origOpen = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function (method, url) { this._hlyAtcUrl = url; return origOpen.apply(this, arguments); }; var origSend = XMLHttpRequest.prototype.send; XMLHttpRequest.prototype.send = function () { if (this._hlyAtcUrl && ADD_RE.test(String(this._hlyAtcUrl))) { this.addEventListener('load', function () { if (this.status >= 200 && this.status < 300 && this.responseText) { handleJsonText(this.responseText); } }); } return origSend.apply(this, arguments); }; /* ---- Secours : formulaire classique (ajout avec navigation) ---- */ document.addEventListener('submit', function (e) { var form = e.target; if (!form || !form.action || !ADD_RE.test(form.action)) return; try { var fd = new FormData(form); var vid = fd.get('id'); var qty = parseInt(fd.get('quantity'), 10) || 1; if (vid) { publish({ items: [{ variantId: String(vid), productId: '', title: '', quantity: qty, price: 0 }], value: 0, currency: currency() }); } } catch (err) {} }, true); log('publisher pret (fetch + XHR + formulaire)'); })();