{% endraw %}\"}", "bundle":{}, "labels":`{\"appstle.subscription.wg.cartHiddenAttributesSelectorV2\":\"\",\"appstle.subscription.wg.daysFrequencyTextV2\":\"Days\",\"appstle.subscription.wg.subscribeAndSaveSuccessV2\":\"SubscribeAndSaveSuccessV2\":success\",\"appstle.subscription.wg.addToShipmentSuccessTextV2\":\"Framgång\",\"appstle.subscription.wg.monthFrequencyTextV2\":\"Månad\",\"appstle.subscription.wg.addToShipmentV2"toShipmentButton\" Leverans\",\"appstle.subscription.wg.onetimeDescriptionTextV2\":\"\",\"appstle.subscription.wg.oneTimePurchaseTextV2\":\"En gång Köp\",\"appstle.subscription.wg.loyaltyPerkDescriptionTextV2\":\"{{#isDiscountTypeFreeProduct}}
<\/img><\/div>
Efter {{{billingCycleBlock}}} beställningar får du en GRATIS {{freeProductName}} <\/span><\/div>
{{\/isDiscountTypeFreeProduct}}{{#isDiscountTypePercentage}}Efter {{{billingCycleBlock}}}<\/span> beställning<\/span> får du {{{discount}}} % RABATT på hela din beställning<\/span><\/span>.{{\/isDiscountTypePerTypePerDiscount}}{#isDiscountTypePerDipping} {{{billingCycleBlock}}}<\/span> beställ<\/span>, få frakt till {{{formatDiscountedPrice}}}<\/span><\/span>.{{\/isDiscountTypeShipping}}{{#isDiscountTypeFixed}}Efter {{{billingCycleBlock}}}}<{{count}beställningen\/span}> får du {{{billingCycleBlock}}}}<\/span}> AV hela din beställning<\/span><\/span>.{{\/isDiscountTypeFixed}}\",\"appstle.subscription.wg.atcButtonTextSelectorV2\":\"\",\"appstle.subscription.wg.oneTimeFrequencyTextV2\":\"One Tid\",\"appstle.subscription.wg.allowFulfilmentCountViaPropertiesV2\":\"false\",\"appstle.subscription.wg.valdiateFormSelector V2\":\"\",\"appstle.subscription.wg.monthsFrequencyTextV2\":\"Månader\",\"appstle.subscription.wg.prepaidSaveBadgeTextV2\":\"SPARA {{selectedDiscountPercentage}}\",\"appstle.subscription.wg.manageSubscriptionButtonTextV2\":\"Hantera Prenumeration\",\"appstle.subscription.wg.yearFrequencyTextV2\":\"År\",\"appstle.subscription.wg.widgetPriceChangeListenerS electorV2\":\"\",\"appstle.subscription.wg.atcButtonTextV2\":\"\",\"appstle.subscription.wg.noSubscriptionLabelTextV2\":\"Nej Prenumeration\",\"appstle.subscription.wg.cancelAnytimeLabelTextV2\":\"Avbryt Anytime\",\"appstle.subscription.wg.addToShipmentErrorTextV2\":\"Fel\",\"appstle.subscription.wg.weeksFrequencyTextV2 \":\"Veckor\",\"appstle.subscription.wg.weeklyLabelTextV2\":\"Veckovis\",\"appstle.subscription.wg.displayAddToExistingSubs criptionButtonForNotLoggedInV2\":\"false\",\"appstle.subscription.wg.addToShipmentProcessingV2\":\"Bearbetar...\",\"ap pstle.subscription.wg.showWidgetStaticV2\":\"false\",\"appstle.subscription.wg.deliveryEveryFrequencyTextV2\":\"Leverans Every\",\"appstle.subscription.wg.subscribeAndSaveInitalV2\":\"Prenumerera &save\",\"appstle.subscription.wg.allowRefreshOnCartPageV2\":\"false\",\"appstle.subscription.wg.prepaidLabelTextV2\":\"Prepaid\",\"appstle.subscription.wg.monthlyLabelTextV2\nthly",\"subscription"Monthly",\"subscription. ription.wg.displayAddToExistingSubscriptionButtonToSubscribersOnlyV2\":\"false\",\"appstle.subscription.wg.yearsFrequencyTextV2\":\"År\",\"appstle.subscription.wg.addToShipmentTool\"PleastToShipmentTool" undvik dubbla leveransavgifter! Logga in för att lägga till denna produkt till en kommande leverans.\",\"appstle.subscription.wg.weekFrequencyTextV2\":\"Vecka\",\"appstle.subscription.wg.unsubscribeFrequencyTextV2\":\"unsubscribe\",\"appstle.subscription.wg.widgetVariantChangeVariant"\2\"el:\" "appstle.subscription.wg.atcButtonTextSelectorObserverV2\":\"\",\"appstle.subscription.wg.dayFrequencyTextV2\":\"day\",\"appstle.subscription.wg.showPrepidPerDeliveryProductPrice\":\"appstle\":\"appstle\":\" ions \":\"Frequency\",\"appstle.subscription.wg.showNewLoyaltyUI\":\"false\",\"appstle.subscription.wg.sellingPlanTitleTextNonPrepaid\":\"{{sellingPlanName}}\",\"appstle.subscription.wg.select"DeliverOption:\"select"DeliverOption:\"select" leverera alternativ\",\"appstle.subscription.wg.yearlyLabelTextV2\":\"Årligt\"}`, "css":{ "appstle_subscription_widget":{ "margin-top":"" , "margin-bottom":"", }, "appstle_subscription"_wrapper ", "border" "border":färg "border":{101} }, "appstle_circle":{ "border-color":"", }, "appstle_dot":{ "background-color":"", }, "appstle_select":{ "padding-top":"", "padding-bottom":"", "padding-left":"", "padding-right"-", "padding-right"-", "bredd":"border":"stil" "border-color":"", "border-radius":"", }, "tooltip_subscription_svg":{ "fill":"", }, "appstle_tooltip":{ "color":"", "background-color":"", }, "appstle_tooltip_border_top_color" ",-}"färg:"bord:" "appstle_subscription_final_price":{ "color":"", }, "appstle_widget_text_color":{ "color":"", }, "appstle_selected_background":{ "background":"transparent", }, "elementCSS":"[]", "customCSS":"a.appsubstle_selected_background":{ "background":"transparent", }, "elementCSS":"[]", "customCSS":"a.appstle_selected_background" #A94500 !important;\n}", "customerPortalCss":"", "externalStyleTag":"", "themeCss":"", } }; window.AppstleSubscription =window.AppstleSubscription || JSON.parse(JSON.stringify(RS)); sessionStorage['appstleSubscriptionConfig'] =JSON.stringify(RS.Config); prova { window.appstle_build_a_box_labels ={"perDeliveryLabelTextV2":"\\/delivery","variantNotAvailable":"Inte tillgängligt","saveDiscountText":"{{discount}}","bundleSummaryTextV2":"Ditt paket för att se paketets sammanfattning är tom. här.","freeProductLabelTextV2":"Gratis","bundleDescriptionTextV2":"Vårt paket med alla paket, The Ultimate Superfood Bundle levererar precis vad det lovar - en komplett superfood-lösning med 7 superfoodblandningar som var och en har skapats för att stärka alla aspekter av din hälsa och välbefinnande - från immunitet och bättre fokus på tarmhälsa":" Details","failedToAddMsgText":"Din varukorg kan inte ha fler än {{maxProduct}} produkter","cart":"Cart","reviewBundleTextV2":"Review Bundle","addButtonText":"Add","minimumQuantityToCheckoutimV2"{:"QuantityToCheckoutimum}{:"Quantity checkout","buildBoxErrormsgV2":"Bygg en box-token är ogiltig, kontakta supporten.","continueShopping":"Fortsätt handla","failedToAddTitleText":"Det gick inte att lägga till","spendAmountGetDiscount":"Spendera {{amount}} få {{percent} rabatt","maxiumQuantityToCheckoutV2":"Maximal {{kvantitet}} kvantitet till kassan","contentsOnModalTextV2":"Innehåll","nextStepButtonTextV2":"Nästa steg","väljPlanLifeStyleTextV2 för att matcha din välja en plan":"C lifestyle","selectMinimumProductButtonText":"Välj {{minProduct}} minimiprodukt","subtotal":"Subtotal","buyQuantityGetDiscount":"Köp {{quantity}} få {{percent}}% rabatt","loyaltyTablePercentageTextV2":\billing"CycleTextV2":beställ<\\/span>, få {{rabatt}} % rabatt<\\/span><\\/span>.","loyaltyTablePriceTextV2":"Efter {{billingCycle}}<\\/span> beställning<\\/span>, få till {{price}}<\\/span><\\/span>.","mySelling"MyDeliveryText}{{selt"s:play} delivery","removeItem":"Ta bort","productsToProceedText":"Välj produkter för att fortsätta","previousStepButtonTextV2":"Föregående steg","loadMoreTextV2":"Ladda in mer","selectedFrequencyLabelText":"Selected FrequencyLabelText":"Selected Frequency"TextButton"ToCart"Add" Cart","basePriceFormatFieldV2":"{{unitPrice}}\\/{{quantityUnit}}","title":"Build-A-Box","productPriceFormatField":"{{price}}","reviewOrdeDescriptionTextV2":"Kontrollera dina varor och välj önskad frekvens plan","quantityLabelV2":"Quantity","minimumOrderAmountLabelTextV2":"Minsta beställningsbelopp {{minOrderAmount}}.","subscriptionNotAvailableButtonV2":"Abonnemanget är inte tillgängligt","shoppingCart":"Kundvagn","checkout"Skiftning och skatter":checkout.","discountPopupCheckoutMessageV2":"Rabatt","selectedButtonTextV2":"Selected","congratsMessageText":null,"okBtnText":"Ok","tieredDiscount":"Tiered Discount","chooseDescription"elvStyleTextav" måltider är midnatt på torsdagar (leveransschemat är som följer:Gold Coast - måndagar | Brisbane &Sunshine Coast - onsdagar)","orderNoteLabelTextV2":"Order Note","minimumToCheckoutV2":"Minimum {{quantity}} till kassan","loyalty"TextVterFixed":{{billingCycle}}<\\/span> beställ<\\/span>, få {{price}} rabatt<\\/span><\\/span>.","editQuantity":"Redigera kvantitet","chooseProductsTextV2":"Välj produkter","loyaltyTableFreeProductTextV2":\spann efter fakturering beställ<\\/span>, få GRATIS PRODUKT ({{productName}})<\\/span><\\/span>.","loyaltyTableShippingTextV2":"Efter {{billingCycle}}<\\/span> beställning<\\/span>, få frakt hos {{price}}<\\/span><\\/span>.","spentText":null,"quantityLabel":null,"addButtonV2":"Lägg till","loyaltyTableFreeTrailTextV2":"Få {{rabatt}} {{discountType}} <\\/span><\\/span><\\/ testversion.<\\/span>","bundleCheckoutTextV2":"Checkout","reviewOrderTextV2":"Granska beställning","goBackButtonText":"Gå tillbaka","selectPlanTextV2":"Välj plan","viewProduct":"Visa produkt","oneTimeV2":Tex Purchase","bundleOnModalTextV2":"Bundle","proceedToCheckoutButtonText":"Fortsätt till kassan","pleaseWaitLabelTextV2":"Vänta...","typeToSearchPlaceholderTextV2":"Skriv till search","selectedProgressLabelTextV2":"Selected","outOfStockTextV2":"Ej i lager"}; } catch (e) { console.error("Fel vid analys av build a box-etiketter:", e); } var _RSConfig =_RSConfig || {}; _RSConfig.shop ='petsmont.myshopify.com'; _RSConfig.shopMoneyFormat ='${{amount}}'; _RSConfig.shopMoneyFormatWithCurrencyFormat ='${{amount}} USD'; }
`; document.querySelector('body').insertAdjacentHTML('beforeend', snackBarHtml); window.addEventListener('meddelande', toasterEventListener, false); function toasterEventListener(event) { if (event?.data &&typeof event?.data.indexOf ==='function' &&event?.data?.indexOf('appstle_message_for_notification') !==-1) { var message =event?.data?.split('|')[1]; showAppstleLoyaltyToaster(meddelande); } } låt snackBarIndex =0; function showAppstleLoyaltyToaster(msg) { var snackBar =document.getElementById('snackbar'); snackBar.classList.add('show'); snackBar.insertAdjacentHTML('beforeend', ` `); const el =snackBarIndex; setTimeout(function() { if (document.getElementById(`elem${el}`)) document.getElementById(`elem${el}`).remove(); }, 5000); snackBarIndex++; } const closeSnackBar =(el) => document.getElementById(el).remove(); document.addEventListener('DOMContentLoaded', () => { }); const executeLoyaltyWidget =() => { const parseHtmlStringContent =(innehåll) => { if (innehållstyp !=='sträng') returnerar innehåll; prova { const htmlDecoded =content?.replace(/\\\//g, '/'); return JSON.parse(`"${htmlDecoded}"`); } catch (error) { console.error('Fel vid analys av innehåll:', fel); returnera innehåll; } }; const formatNumberByPointRoundType =num => { if (typ av num !=='number') return num; const roundType =_ALConfig?.pointRoundType || "NO_ROUND"; const rounded =roundType ==='ROUND_UP' ? Math.ceil(num) :roundType ==='ROUND_DOWN' ? Math.floor(num) :num; return (Number.isInteger(rounded) || avrundad % 1 ===0) ? rounded.toFixed(0) :rounded.toFixed(2); }; const loyaltyWidgetStyles =``; document.querySelector('body').insertAdjacentHTML('beforeend', loyaltyWidgetStyles); const mainHTMLString =``; document.querySelector('body').insertAdjacentHTML('beforeend', mainHTMLString); window.addEventListener('meddelande', widgetEventListener, false); function widgetEventListener(event) { if (event?.data &&typeof event?.data.indexOf ==='function' &&event?.data?.indexOf('appstle_message_for_showWidget') !==-1) { } else if (event?.data &&typeof event =&data. event?.data?.indexOf('appstle_widget_showHide') !==-1) { toggleWidget(); } else if (event?.data &&typeof event?.data.indexOf ==='function' &&event?.data?.indexOf('refresh_appstle_loyalty_widget') !==-1 &&_ALConfig?.widget_setting?.widgetType ==='LAUNCHER') {yalloadAppWidle(yalloadAppWidle)); console.log('REFRESH WIDGET'); } else if (event?.data &&typeof event?.data.indexOf ==='function' &&event?.data?.indexOf('show_appstle_loyalty_widget') !==-1) { loadAppstleLoyaltyWidget(); enableWidget(); } } funktion removeAppstleLoyaltyWidget() { document.querySelector('#appstle-loyalty-button')?.classList?.add('appstle-loyalty-hidden'); document.querySelector('#appstle_loyalty_iframe')?.classList?.add('appstle-loyalty-hidden'); } (funktion checkForWidgetRestrictions() { let isShowWidget =true; if (_ALConfig?.customerLoyalty?.customerStatus ==='EXCLUDED') { isShowWidget =false; } if (!_ALConfig?.customerId) { isShowWidget =!(_ALConfig?.widget_setting?.restrictedCustomersTag || _ALConfig?.widget_setting?.allowedCustomersTag); _ALConfig?.widget_setting?.allowedCustomersTag.split(','); if (allowedTags?.length> 0 &&!_ALConfig?.customerTags?.some((tag) => allowedTags?.some((allowedTag) =>Lower()Tag(.)? tag?.trim()?.toLowerCase()))) { isShowWidget =false } } if (_ALConfig?.widget_setting?.restrictedCustomersTag?.length &&isShowWidget) { let restrictedTags =_ALConfig?.widget_setting?.Cliters?.restricted; (restrictedTags?.length> 0 &&_ALConfig?.customerTags?.some((tag) => restrictedTags?.some((restrictedTag) => restrictedTag?.trim()?.toLowerCase() ===tag?.trim()?.toLowerCase } is.)W (_ALConfig?.widget_setting?.blockWidgetOnPages?.length &&isShowWidget) { let restrictedPages =_ALConfig?.widget_setting?.blockWidgetOnPages?.split(','); (restrictedPages?.includes('/homepage') &¤tPage ==='/') { isShowWidget =false } else if (restrictedPages?.some((page) => currentPage?.includes(page))) { isShowWidget =false; (_ALConfig?.widget_setting?.allowWidgetOnSpecificPages?.length &&isShowWidget) { let allowPages =_ALConfig?.widget_setting?.allowWidgetOnSpecificPages?.split(','); (allowedPages?.includes('/homepage') &¤tPage ==='/') { isShowWidget =true } else if (allowedPages?.some((page) => currentPage?.includes(page))) { isShowWidget =true } else =}false; (!_ALConfig?.customerId &&_ALConfig?.widget_setting?.showToLoggedInCustomerOnly) fönster { isShowWidget =false; removeAppstleLoyaltyWidget(); function enableWidget() { document.querySelector('#appstle_loyalty_iframe')?.classList?.add('open'); document.querySelector('#appstle_loyalty_iframe')?.classList?.remove('appstle-loyalty-hidden'); setTimeout(function() { document.querySelector('#appstle_loyalty_iframe')?.classList?.toggle('show-close-icon'); }, 900); } funktion showAppstleLoyaltyWidget() { const launcherAllowed =fönster?.['__APPSTLE_LOYALTY_LAUNCHER_ALLOWED'] !==false; document.querySelector('#appstle_loyalty_iframe')?.classList?.remove('appstle-loyalty-hidden'); const btn =document.querySelector('#appstle-loyalty-button'); if (!btn) returnera; if (launcherAllowed) { btn.classList.remove('appstle-loyalty-hidden'); } annat { btn.classList.add('appstle-loyalty-hidden'); } } document.querySelector('.appstle-loyalty-button').addEventListener('klick', toggleWidget); if (_ALConfig?.widget_setting?.widgetPosition ==='LEFT') { document.getElementById('appstle_loyalty_iframe')?.classList?.add('appstle-loyalty-left'); document.querySelector('.appstle-loyalty-button')?.classList?.add('appstle-loyalty-left'); document.getElementById('appstle_loyalty_iframe')?.classList?.add('appstle-loyalty-left'); document.getElementById('snackbar')?.classList?.add('left_snackbar'); } annat { document.getElementById('appstle_loyalty_iframe')?.classList?.add('appstle-loyalty-right'); document.querySelector('.appstle-loyalty-button')?.classList?.add('appstle-loyalty-right'); document.getElementById('snackbar')?.classList?.add('right_snackbar'); } const alIframeSrc =``; function toggleWidget() { loadAppsleLoyaltyWidget(); if (_ALConfig?.widget_setting?.widgetType?.toUpperCase() ==='LAUNCHER' &&_ALConfig?.widget_setting?.forceRedirectDedicatedPage ===true) { window.open(`/${_ALConfig?.proxy_path_prefix}`); } else { document.querySelector('#appstle_loyalty_iframe')?.classList?.toggle('open'); showAppstleLoyaltyWidget(); setTimeout(function() { document.querySelector('#appstle_loyalty_iframe')?.classList?.toggle('show-close-icon'); }, 900); } } const loadAppstleLoyaltyWidget =() => { var iframe =document.querySelectorAll('#appstle_loyalty_iframe'); iframe.forEach(function(item) { item.contentWindow._ALConfig =_ALConfig; item.contentWindow.document.open('text/html', 'ersätt'); item.contentWindow.document.write(alIframeSrc); item.contentWindow.document}.close(); }; const launcherDataType =_ALConfig?.widget_setting?.launcherDataType || 'POÄNG'; const loyaltyButtonTitle =document.getElementById('loyalty-widget-title'); if (_ALConfig?.shop_labels?.widgetTitle) { loyaltyButtonTitle.innerHTML =parseHtmlStringContent(_ALConfig?.shop_labels?.widgetTitle); } (function() { const { customerLoyalty, widget_setting } =_ALConfig || {}; if (!customerLoyalty) return; const showTier =widget_setting?.showTierName; const launcherButtonElement =document.querySelector('#appstle-loyalty-button ='); document.querySelector('.loyalty_widget_available_points'); if (!pointsEl) returnerar Intl.NumberFormat( const { storeCreditBalance =0, currentVipTier ='' } =kundLoyalty; 'STORE_CREDITS') { const n =Number(storeCreditBalance) || 0 displayValue =fmt.format(formatNumberByPointRoundType(n)); Number(availablePoints) ||. displayValue =fmt.format(formatNumberByPointRoundType(n) } pointsEl.textContent =displayValue.add('appstle_show_points'); function handleDeepLink() { const loyaltyDeepLinks =[ '#appstle-loyalty', '#appstle-refer', '#appstle-loyalty-earn-rewards', '#appstle-loyalty-redeem-rewards', '#appstle-loyalty-referralty-referralty', 'pstle-loyalty-referralty', 'pstle-loyalty-referralty-vi'; if (!_ALConfig?.widget_setting?.showWidget || !loyaltyDeepLinks.some(hash => plats?.hash?.includes(hash))) { return; } loadAppstleLoyaltyWidget(); enableWidget(); setTimeout(() => { document.querySelector('#appstle_loyalty_iframe')?.classList?.add('show-close-icon'); }, 900); } handleDeepLink(); const widgetReferralUrl =ny URL(window.location.href); if (_ALConfig?.referralEnabled &&widgetReferralUrl?.searchParams.get('appstle_referral') &&_ALConfig?.widget_setting?.widgetType ==='LAUNCHER') { let referralRedirectUrl =_ALConfig_referral?.rlrget; let redirectURL =referralRedirectUrl + window.location.search; if (referralRedirectUrl) { låt referralUrlObj; försök { referralUrlObj =ny URL(referralRedirectUrl, window.location.origin); } catch { referralUrlObj =null; } låt referralPath =referralUrlObj ? referralUrlObj.pathname.replace(/\/+$/, '') :referralRedirectUrl.replace(/\/+$/, ''); låt aktuellPath =window.location.pathname.replace(/\/+$/, ''); if (referralPath &¤tPath !==referralPath) { window.open(redirectURL, '_self'); } } setTimeout(() => { loadAppstleLoyaltyWidget(); enableWidget(); }, 200); } (funktion observeURLChanges() { let lastUrl =location.href; const handleUrlChange =() => { if (location.href !==lastUrl) { handleDeepLink(); lastUrl =location.href; } }; new MutationObserver(handleUrlChange.body, childobserve; window.addEventListener('popstate', handleUrlChange); const alDOMObserver =new MutationObserver(function(mutations_list) { mutations_list.forEach(function(mutation) { mutation.addedNodes.forEach(function(added_node) { if (added_node.id ==='appstle_loyalty_iframe') { var iframe =document.querySelectorAll('#appstle_loyalty_iframe'); iframe.forEach(function(item) { item.contentWindow._ALConfig =_ALConfig; item.contentWindow.document.open('text/html', 'replace'); item.contentWindow.document.I; item.contentWindow.document.close( }); alDOMObserver. alDOMObserver.observe(document.querySelector('body'), { subtree:true, childList:true });
} prova { const versionUrl =`${location.origin}/${_ALConfig?.proxy_path_prefix || 'apps/loyalty'}/app-loyalty-version'; fetch(versionUrl) .then(res => res.json()). widgetCssUrl.searchParams.set('v', data); _ALConfig.widgetJsPath =widgetJsUrl.toString(); executeLoyaltyWidget( }); } catch (fel) { executeLoyaltyWidget(); } const storeCreditMismatch =_ALConfig?.customerId &&_ALConfig?.customerStoreCreditBalance>=0 &&_ALConfig?.customerLoyalty?.storeCreditBalance>=0 &&_ALConfig?.customer.storeCredit=Credit? _ALConfig?.customerStoreCreditBalance; if (storeCreditMismatch &&_ALConfig.shop ==='olineloyalty27.myshopify.com') { const updateCustomerUrl =`/${_ALConfig?.proxy_path_prefix || 'apps/loyalty'}/cp/api/update-customer'; prova { fetch(updateCustomerUrl, { method:'POST' }) .then((response) => { if(response.ok) {} }) .catch(() => {}); } fånga (fel) {} }
const dedicatedPageURL =ny URL(window.location.href); const decodeUrl =(innehåll) => { if (innehållstyp !=='sträng') returnerar innehåll; prova { const htmlDecoded =content?.replace(/\\\//g, '/'); return JSON.parse(`"${htmlDecoded}"`); } catch (error) { console.error('Fel vid analys av innehåll:', fel); returnera innehåll; } }; if (dedicatedPageURL?.searchParams?.get('appstle_referral') &&_ALConfig?.widget_setting?.widgetType ==='DEDICATED_PAGE') { const customUrl =decodeUrl(_ALConfig?.widget_settingtom?.referralCus); if (customUrl) { const normalizedCustomPath =customUrl.startsWith('/') ? customUrl :`/${customUrl}`; if (window.location.pathname !==normalizedCustomPath) { const redirectUrl =new URL(window.location.href); redirectUrl.pathname =normalizedCustomPath; window.open(redirectUrl.toString(), '_self'); } } else if (dedicatedPageURL?.searchParams?.get('appstle_referral') &&_ALConfig?.widget_setting?.widgetType ==='DEDICATED_PAGE' &&!window.location.href.includes(_ALConfig_prefix)_path window.open(`/${_ALConfig?.proxy_path_prefix}${window.location.search}`, '_self'); } } const dedicatedPageEventListener =(event) => { if (event?.data &&typeof event?.data.indexOf ==='function' &&event?.data?.indexOf('refresh_appstle_loyalty_page') !==-1) { initiateAppstleLoyaltyPage(); console.log('UPPDATERA SIDAN'); } }; window.addEventListener('meddelande', dedicatedPageEventListener, false); function initiateAppstleLoyaltyPage() { if (document.querySelector('#appstleLoyaltyPage')) { const appstleLoyaltyPageElement =document.getElementById('appstleLoyaltyPage'); while (appstleLoyaltyPageElement.firstChild) { appstleLoyaltyPageElement.firstChild.remove(); } if (appstleLoyaltyPageElement) { const executeDedicatedPageScript =() => { const s =document.createElement('script'); s.setAttribute('src', _ALConfig?.widgetJsPath); s.setAttribute('defer', 'defer'); document.body.appendChild(s); const huvud =dokument.huvud; const länk =document.createElement('länk'); link.type ='text/css'; link.rel ='stilmall'; link.href =_ALConfig?.widgetCssPath; head.appendChild(länk); } prova { const versionUrl =`${location.origin}/${_ALConfig?.proxy_path_prefix || 'apps/loyalty'}/app-loyalty-version'; fetch(versionUrl).then(res => res.json()).then(data => { if (data) { const widgetJsUrl =new URL(_ALConfig.widgetJsPath); const widgetCssUrl =new URL(_ALConfig.widgetCssPath); widgetsearchParam.set,'vrams.data; widgetCssUrl.searchParams.set('v', data); _ALConfig.widgetJsPath =widgetJsUrl.toString(); }); } catch (fel) { executeDedicatedPageScript(); } } } else { setTimeout(() => { initiateAppstleLoyaltyPage(); }, 2000); } } const dedicatedPageReferralUrl =ny URL(window.location.href)?.searchParams.get('appstle_referral'); if (_ALConfig?.widget_setting?.showWidget ===true) { initiateAppstleLoyaltyPage(); }
(async function() { const isAvailableVisitShop =_ALConfig?.pointEarnRules?.length> 0 &&_ALConfig?.pointEarnRules?.find((rule) => regel?.typ ==='VISIT_SHOP' &&rule?.status ==='ACTIVE'Configd; isAvailableVisitShop) { if (!sessionStorage.getItem('syncVisitStore') &&((_ALConfig?.customerId &&isAvailableVisitShop &&isAvailableVisitShop?.id) || (_ALConfig?.referralEnabled &&_ALtyerref.Tyreferfig? ==='VISIT_SHOP'))) { prova { const response =await fetch(`/${_ALConfig?.proxy_path_prefix || 'apps/loyalty'}/cp/api/customer-visit-store`, { method:'POST', rubriker:{'Content-Type/j)son:{'application/j)'ok:sessionStorage.setItem('syncVisitStore', 'true'); } } catch (error) { console.error('Error:', error } } })();
`; document.querySelector('body').insertAdjacentHTML('beforeend', loyaltyCustomStyles);