var bixgrowUrl = 'https://api.bixgrow.com'; let bgRefHashCode = bgGetParameterByName('bg_ref'); if(bgRefHashCode){ const payload = { shop: Shopify.shop, affiliate_id: bgRefHashCode, url: window.location.href, referral_site: document.referrer } bgUseFetch(`${bixgrowUrl}/api/v2/automatic-coupon-customer`,'GET', payload).then(responseData => { if(Object.keys(responseData).length > 0) { if(!responseData.is_dynamic_coupon){ createCustomerDiscountPopup(responseData.settings,false,responseData?.discount_code); autoAppliedCoupon(responseData?.discount_code); }else if(bgRefHashCode != bgGetCookie('bixgrow_affiliate_referral') ){ createCustomerDiscountPopup(responseData.settings,true,responseData?.discount_code); } } }) } let toolbarsRefHashCode = bgRefHashCode ? bgRefHashCode : bgGetCookie('bgaffilite_id'); if(toolbarsRefHashCode){ getStoreToolBars(toolbarsRefHashCode); } function getStoreToolBars(refHashCode){ const payload = { shop: Shopify.shop, affiliate_id: refHashCode, url: window.location.href } bgUseFetch(`${bixgrowUrl}/api/store-toolbar`,'GET', payload).then(obj => { if(Object.keys(obj).length>0) { var enableToolbar = obj.settings.enable_shopping_with_toolbar; var enableFloatWidget = obj.settings.enable_shopping_with_floating_widget; var shopping_with_toolbar = obj.settings.shopping_with_toolbar; var shopping_with_floating_widget = obj.settings.shopping_with_floating_widget; if(enableToolbar) { let existingToolbarElement = document.getElementById('__bixgrow_topbar'); if (existingToolbarElement) { existingToolbarElement.remove(); } let head = document.head || document.getElementsByTagName('head')[0]; let style = document.createElement('style'); let topBar = document.createElement("div"); topBar.style.width = '100%'; topBar.style.zIndex = '2157484649'; topBar.style.position = 'relative'; topBar.id='__bixgrow_topbar'; window.onscroll = function(){ if(document.body.scrollTop > 5 || document.documentElement.scrollTop > 5){ topBar.classList.add('bixgrow_fixed'); } else{ topBar.classList.remove('bixgrow_fixed'); } } document.body.insertBefore(topBar,document.body.firstChild); let css = ` #__bixgrow_topbar { text-align: ${shopping_with_toolbar.textAlign}; background-color: ${shopping_with_toolbar.bgColor}; color: ${shopping_with_toolbar.textColor}; width: 100%; } #__bixgrow_topbar_style { display: inline-block; line-height: 40px; } .bixgrow_fixed { position: ${shopping_with_toolbar.position} !important; top: 0; width: 100%; z-index: 2157484649; } .bixgrow-toolbar-special-text { color: ${shopping_with_toolbar.special_text}; } `; style.type = 'text/css'; if (style.styleSheet){ // This is required for IE8 and below. style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); } head.appendChild(style); let divContent = '