(function () { // var scriptURL = 'https://sdks.shopifycdn.com/buy-button/latest/buy-button-storefront.min.js'; // var scriptURL = 'https://cdn.shopify.com/s/files/1/0538/4611/4476/files/new-buybutton.js?v=1652434242'; var scriptURL = 'https://cdn.shopify.com/s/files/1/0538/4611/4476/files/shopify-buybutton-new.min.js?v=1652862678'; if (window.ShopifyBuy) { if (window.ShopifyBuy.UI) { ShopifyBuyInit(); } else { loadScript(); } } else { loadScript(); } function loadScript() { var script = document.createElement('script'); script.async = true; script.src = scriptURL; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild( script); script.onload = ShopifyBuyInit; } function ShopifyBuyInit() { var client = ShopifyBuy.buildClient({ domain: 'store.coronatestcentre.com', storefrontAccessToken: '39613b1d6ece53cab6de8fd2beda3a7b', }); ShopifyBuy.UI.onReady(client).then(function (ui) { ui.createComponent('product', { id: '6677258764460', node: document.getElementById('product-component-'), moneyFormat: '%C2%A3%7B%7Bamount%7D%7D', options: { "product": { "styles": { "product": { "@media (min-width: 601px)": { "max-width": "calc(25% - 20px)", "margin-left": "20px", "margin-bottom": "50px" } }, "button": { "font-family": "Lato, sans-serif", "font-weight": "bold", "font-size": "18px", "padding-top": "17px", "padding-bottom": "17px", "border": "1px solid #2356f6", ":hover": { "background-color": "white", "color": "#2356f6", "border-color": "#2356f6" }, "background-color": "#2356f6", ":focus": { "background-color": "#1941D3", "border-color": "#1941D3", "color": "white" }, "border-radius": "4px", "padding-left": "60px", "padding-right": "60px" }, "quantityInput": { "font-size": "18px", "padding-top": "17px", "padding-bottom": "17px", } }, "contents": { "img": false, "button": false, "buttonWithQuantity": false, "title": false, "price": false }, "text": { "button": "Add To Cart" }, "googleFonts": ["Lato"] }, "productSet": { "styles": { "products": { "@media (min-width: 601px)": { "margin-left": "-20px" } } } }, "modalProduct": { "contents": { "img": false, "imgWithCarousel": false, "button": false, "buttonWithQuantity": false }, "styles": { "product": { "@media (min-width: 601px)": { "max-width": "100%", "margin-left": "0px", "margin-bottom": "0px" } }, "button": { "font-family": "Lato, sans-serif", "font-weight": "bold", "font-size": "18px", "padding-top": "17px", "padding-bottom": "17px", "border": "1px solid #2356f6", ":hover": { "background-color": "white", "color": "#2356f6", "border-color": "#2356f6" }, "background-color": "#2356f6", ":focus": { "background-color": "#1941D3", "border-color": "#1941D3", "color": "white" }, "border-radius": "4px", "padding-left": "60px", "padding-right": "60px" }, "quantityInput": { "font-size": "18px", "padding-top": "17px", "padding-bottom": "17px" } }, "googleFonts": ["Lato"], "text": { "button": "Add to cart" } }, "cart": { "iframe": false, DOMEvents: { 'click .shopify-buy__btn': function (evt, target) { // Initialize Variables var cart_obj = ui.components.cart[0].lineItemCache; var product_name = []; var product_category = []; var total = []; var price = []; var quantity = []; var subtotal = 0.0; // Loop through cart line items for (var i = 0; i < cart_obj.length; i++) { var item = cart_obj[i]; // INT/FLOAT Logic item_price = parseFloat(item.variant.price); item_quantity_float = parseFloat(item.quantity); item_quantity_int = parseInt(item.quantity); item_total = item_price * item_quantity_float; // Category Assignment if (item.title == "Antigen Fit to Fly Test") { product_category.push(["Antigen", "Departures"]); } else if (item.title == "PCR Test") { product_category.push(["PCR"]); } else if (item.title == "Antigen Test") { product_category.push(["Antigen"]); } else if (item.title == "Antigen USA Approved Test") { product_category.push(["Antigen", "Departures"]); } else if (item.title == "Antigen Test [4 Pack]") { product_category.push(["Antigen"]); } else if (item.title == "Antigen Test [6 Pack]") { product_category.push(["Antigen"]); } else if (item.title == "Antigen Observed Fit to Fly Test") { product_category.push(["Antigen", "Departures"]); } // Array Push product_name.push(item.title); total.push(item_total); price.push(item_price); quantity.push(item_quantity_int); subtotal = subtotal + item_total; } window.parent.parent.postMessage({ 'postMessageAuth': 'proceedPayment', 'product_name': product_name, 'total': total, 'price': price, 'quantity': quantity, 'subtotal': subtotal }, '*'); } }, "styles": { "button": { "font-family": "Lato, sans-serif", "font-weight": "bold", "font-size": "18px", "padding-top": "17px", "padding-bottom": "17px", "border": "1px solid #2356f6", ":hover": { "background-color": "white", "color": "#2356f6", "border-color": "#2356f6" }, "background-color": "#2356f6", ":focus": { "background-color": "#1941D3", "border-color": "#1941D3", "color": "white" }, "border-radius": "4px" }, "title": { "color": "#1c1c28", "font-size": "24px", "font-weight": "bold", "margin-bottom": "-20px", "border-bottom": "1px solid #D0CCD5" }, "header": { "color": "#1c1c28" }, "lineItems": { "color": "#1c1c28" }, "subtotalText": { "color": "#1c1c28", "font-weight": "bold", "font-size": "20px" }, "subtotal": { "color": "#1c1c28", "font-weight": "bold", "font-size": "20px" }, "notice": { "color": "#1c1c28" }, "currency": { "color": "#1c1c28" }, "close": { "color": "#2356F6", ":hover": { "color": "#1941D3" } }, "empty": { "color": "#555770", "font-size": "20px", "margin-top": "40px" }, "noteDescription": { "color": "#1c1c28" }, "discountText": { "color": "#1c1c28" }, "discountIcon": { "fill": "#1c1c28" }, "discountAmount": { "color": "#1c1c28" } }, "text": { "total": "Total", "empty": "Your cart is currently empty.", "notice": "", "button": "Proceed to Payment" }, "popup": false, "googleFonts": ["Lato"] }, "toggle": { "iframe": true, DOMEvents: { 'click': function (evt, target) { window.parent.parent.postMessage('openCart', '*'); ui.openCart(); } }, "contents": { "icon": false, }, "styles": { "toggle": { "font-family": "Lato, sans-serif", "font-weight": "bold", "background-color": "#E1EBFF", "background-image": "url('https://uploads-ssl.webflow.com/6221cc6b2ce3cc468aa5a27b/62389039f7a98330c96c8331_Icons%20(11).svg')", "background-repeat": "no-repeat", "background-position": "center", "background-size": "custom", "border-radius": "4px", "height": "50px", "width": "50px", "color": "#2356F6", "padding-top": "15px", ":hover": { "background-color": "#C2D6FF" }, ":focus": { "background-color": "#C2D6FF" } }, "count": { "font-size": "12px", "display": "flex", "position": "absolute", "right": "5", "top": "5" } }, "googleFonts": ["Lato"] }, "lineItem": { "styles": { "variantTitle": { "color": "#1c1c28" }, "title": { "color": "#1c1c28" }, "price": { "color": "#1c1c28", "font-size": "20px" }, "fullPrice": { "color": "#1c1c28" }, "discount": { "color": "#1c1c28" }, "discountIcon": { "fill": "#1c1c28" }, "quantity": { "color": "#1c1c28" }, "quantityIncrement": { "color": "#1c1c28", "border-color": "#93899E66", "height": "30px", "width": "30px" }, "quantityDecrement": { "color": "#1c1c28", "border-color": "#93899E66", "height": "30px", "width": "30px" }, "quantityInput": { "color": "#1c1c28", "border-color": "#93899E66", "height": "30px" } } } }, }); var shopifyBuyFrame = document.getElementsByClassName("shopify-buy-frame--cart"); for (var i = 0; i < shopifyBuyFrame.length; i++) { shopifyBuyFrame[i].classList.add('shopify-buy-frame--cart--custom'); shopifyBuyFrame[i].classList.add('is-active'); shopifyBuyFrame[i].classList.add('is-initialized'); } }); } })(); // Mixpanel Tracking - Nav Buttons document.getElementById("choosetestbtn").addEventListener('click', function () { mixpanel.track('choose_tests_button', { 'button_content': this.textContent }); }); //Mixpanel Tracking - Open Cart & Proceed To Payment window.addEventListener("message", function (e) { if (e.origin !== 'https://corona-test-centre-redesign.webflow.io') { return; } if (e.data.postMessageAuth == 'proceedPayment') { mixpanel.track('proceed_to_payment', { "currency_symbol": "£", "currency_ticker": "GBP", "product_name": e.data.product_name, "total": e.data.total, "price": e.data.price, "quantity": e.data.quantity, "subtotal": e.data.subtotal }); } if (e.data == 'openCart') { mixpanel.track('go_to_cart', { 'button_content': "cart" }) } }, false);