function getCart(callback) { var data = null; var xhr = new XMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("readystatechange", function() { if (this.readyState === 4 && this.status == 200) { callback(JSON.parse(this.responseText)); } if (this.readyState === 4 && this.status != 200) { console.log("Error retrieving cart. Status: " + this.status); } }); xhr.open("GET", "/cart.js"); xhr.send(data); } function injectScript() { (function(w,d,s,v){var f=d.getElementsByTagName(s)[0],j=d.createElement(s); j.async=true;j.src='https://tags.rvere.com/tags/tagmanager.pwnage.myshopify.com.js?v='+v;f.parentNode.insertBefore(j,f); })(window,document,'script','12'); } function load () { if (!Shopify.checkout) { getCart(function(cart){ window.$ShopVariables = window.$ShopVariables || {}; $ShopVariables.cart = { variant_ids: [], product_ids: [], item_count: cart.item_count, total_price: cart.total_price/100, items: [] }; $ShopVariables.currency = Shopify.currency.active; $ShopVariables.email = ""; var items = cart.items; for (var i = 0; i < items.length; i++) { var item = items[i]; $ShopVariables.cart.variant_ids.push(item.variant_id); $ShopVariables.cart.product_ids.push(item.product_id); $ShopVariables.cart.items.push({ id: item.variant_id, product_id: item.product_id, title: item.title, product_type: item.product_type, price: item.price/100, quantity: item.quantity }); } injectScript(); }); } else { injectScript(); } } function init () { window.Shopify && window.Shopify.loadFeatures && window.Shopify.loadFeatures( [ { name: 'consent-tracking-api', version: '0.1', }, ] ); var trackingAllowed = !window.Shopify.customerPrivacy || window.Shopify.customerPrivacy.userCanBeTracked(); if (!trackingAllowed) { document.addEventListener('trackingConsentAccepted', function() { load(); }); } else { load(); } } if (!window.$CivilPixelsLoaded && !window.$ShopVariables) { if (document.readyState === 'complete') { init(); } else { window.addEventListener("load", init); } }