Choosing the Best Reptile Habitat – Talis Us

\\n {% endraw %}\”,\”WIDGET_TYPE_5\”:\”{% raw %}

\\n {% endraw %}\”}”,

“bundle”: {},

“labels”: `{\”appstle.subscription.wg.cartHiddenAttributesSelectorV2\”:\”\”,\”appstle.subscription.wg.daysFrequencyTextV2\”:\”Days\”,\”appstle.subscription.wg.subscribeAndSaveSuccessV2\”:\”Subscription Selected\”,\”appstle.subscription.wg.addToShipmentSuccessTextV2\”:\”Success\”,\”appstle.subscription.wg.monthFrequencyTextV2\”:\”Month\”,\”appstle.subscription.wg.addToShipmentButtonTextV2\”:\”Add to Shipment\”,\”appstle.subscription.wg.onetimeDescriptionTextV2\”:\”\”,\”appstle.subscription.wg.oneTimePurchaseTextV2\”:\”One Time Purchase\”,\”appstle.subscription.wg.loyaltyPerkDescriptionTextV2\”:\”{{#isDiscountTypeFreeProduct}}

<\/img><\/div>

{{^isZeroBillingCycle}}After {{{billingCycleBlock}}} orders, {{\/isZeroBillingCycle}}{{#isZeroBillingCycle}}Get{{\/isZeroBillingCycle}}{{^isZeroBillingCycle}}get{{\/isZeroBillingCycle}} a FREE {{freeProductName}} {{#isZeroBillingCycle}}on your first order.{{\/isZeroBillingCycle}}<\/span><\/div>

{{\/isDiscountTypeFreeProduct}}{{#isDiscountTypePercentage}}After {{{billingCycleBlock}}}<\/span> order<\/span>, get {{{discount}}}% OFF your entire order<\/span><\/span>.{{\/isDiscountTypePercentage}}{{#isDiscountTypeShipping}}After {{{billingCycleBlock}}}<\/span> order<\/span>, get shipping at {{{formatDiscountedPrice}}}<\/span><\/span>.{{\/isDiscountTypeShipping}}{{#isDiscountTypeFixed}}After {{{billingCycleBlock}}}<\/span> order<\/span>, get {{{formatDiscountedPrice}}} OFF your entire order<\/span><\/span>.{{\/isDiscountTypeFixed}}{{#isDiscountTypeFixedPrice}}After {{{billingCycleBlock}}}<\/span> order<\/span>, get this product at {{{formatDiscountedPrice}}}<\/span><\/span>.{{\/isDiscountTypeFixedPrice}}\”,\”appstle.subscription.wg.bundleDiscountTextV2\”:\”bundle discount extra: {{bundleDiscount}} off\”,\”appstle.subscription.wg.atcButtonTextSelectorV2\”:\”\”,\”appstle.subscription.wg.oneTimeFrequencyTextV2\”:\”One Time\”,\”appstle.subscription.wg.allowFulfilmentCountViaPropertiesV2\”:\”true\”,\”appstle.subscription.wg.valdiateFormSelectorV2\”:\”\”,\”appstle.subscription.wg.monthsFrequencyTextV2\”:\”Months\”,\”appstle.subscription.wg.prepaidSaveBadgeTextV2\”:\”SAVE {{selectedDiscountPercentage}}\”,\”appstle.subscription.wg.manageSubscriptionButtonTextV2\”:\”Manage Subscription\”,\”appstle.subscription.wg.removeClassFromPriceElementV2\”:\”\”,\”appstle.subscription.wg.yearFrequencyTextV2\”:\”Year\”,\”appstle.subscription.wg.widgetPriceChangeListenerSelectorV2\”:\”\”,\”appstle.subscription.wg.atcButtonTextV2\”:\”\”,\”appstle.subscription.wg.noSubscriptionLabelTextV2\”:\”No Subscription\”,\”appstle.subscription.wg.cancelAnytimeLabelTextV2\”:\”Cancel Anytime\”,\”appstle.subscription.wg.addToShipmentErrorTextV2\”:\”Error\”,\”appstle.subscription.wg.weeksFrequencyTextV2\”:\”Weeks\”,\”appstle.subscription.wg.weeklyLabelTextV2\”:\”Weekly\”,\”appstle.subscription.wg.displayAddToExistingSubscriptionButtonForNotLoggedInV2\”:\”false\”,\”appstle.subscription.wg.addToShipmentProcessingV2\”:\”Processing…\”,\”appstle.subscription.wg.showWidgetStaticV2\”:\”false\”,\”appstle.subscription.wg.deliveryEveryFrequencyTextV2\”:\”Delivery Frequency\”,\”appstle.subscription.wg.subscribeAndSaveInitalV2\”:\”Subscribe and save\”,\”appstle.subscription.wg.allowRefreshOnCartPageV2\”:\”false\”,\”appstle.subscription.wg.prepaidLabelTextV2\”:\”Prepaid\”,\”appstle.subscription.wg.monthlyLabelTextV2\”:\”Monthly\”,\”appstle.subscription.wg.displayAddToExistingSubscriptionButtonToSubscribersOnlyV2\”:\”false\”,\”appstle.subscription.wg.yearsFrequencyTextV2\”:\”Years\”,\”appstle.subscription.wg.addToShipmentTooltipTextV2\”:\”Please avoid double delivery charges! Login to add this product to an upcoming delivery.\”,\”appstle.subscription.wg.weekFrequencyTextV2\”:\”Week\”,\”appstle.subscription.wg.unsubscribeFrequencyTextV2\”:\”One-time Purchase\”,\”appstle.subscription.wg.widgetVariantChangeListenerSelectorV2\”:\”\”,\”appstle.subscription.wg.atcButtonTextSelectorObserverV2\”:\”\”,\”appstle.subscription.wg.dayFrequencyTextV2\”:\”day\”,\”appstle.subscription.wg.showPrepidPerDeliveryProductPriceV2\”:\”false\”,\”appstle.subscription.wg.offFrequencyTextV2\”:\”Off\”,\”appstle.subscription.wg.prepayLabelTextV2\”:\”Prepay\”,\”appstle.subscription.wg.productPageUnitPriceSelectorV2\”:\”\”,\”appstle.subscription.wg.frequencyCombinedWidgetTextV2\”:\”Frequency\”,\”appstle.subscription.wg.sellingPlanTitleTextNonPrepaid\”:\”{{sellingPlanName}}\”,\”appstle.subscription.wg.selectDeliverOptionV2\”:\”Select Delivery Option\”,\”appstle.subscription.wg.yearlyLabelTextV2\”:\”Yearly\”}`,

“css”: {
“appstle_subscription_widget”: {
“margin-top”: “” ,
“margin-bottom”: “”,
},

“appstle_subscription_wrapper”: {
“border-width”: “”,
“border-color”: “”,
},

“appstle_circle”: {
“border-color”: “”,
},

“appstle_dot”: {
“background-color”: “”,
},

“appstle_select”: {
“padding-top”: “”,
“padding-bottom”: “”,
“padding-left”: “”,
“padding-right”: “”,
“border-width”: “”,
“border-style”: “”,
“border-color”: “”,
“border-radius”: “”,
},

“tooltip_subscription_svg”: {
“fill”: “”,
},

“appstle_tooltip”: {
“color”: “”,
“background-color”: “”,
},

“appstle_tooltip_border_top_color”: {
“border-top-color”: “”,
},

“appstle_subscription_final_price”: {
“color”: “”,
},
“appstle_widget_text_color”: {
“color”: “”,
},
“appstle_selected_background”: {
“background”: “transparent”,
},
“elementCSS”: “[]”,
“customCSS”: “”,
“customerPortalCss”: “”,
“externalStyleTag”: “”,
“themeCss”: “”,
}
};

window.AppstleSubscription = window.AppstleSubscription || JSON.parse(JSON.stringify(RS));

sessionStorage[‘appstleSubscriptionConfig’] = JSON.stringify(RS.Config);

var _RSConfig = _RSConfig || {};

_RSConfig.shop = ‘talis-us.myshopify.com’;






_RSConfig.shopMoneyFormat=”${{amount}}“;
_RSConfig.shopMoneyFormatWithCurrencyFormat=”${{amount}} USD“;




}






















`;
document.querySelector('body').insertAdjacentHTML('beforeend', snackBarHtml);

window.addEventListener('message', 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(message);
}
}

let 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 parseHtmlStringContent = (content) => {
if (typeof content !== 'string') return content;
try {
const htmlDecoded = content?.replace(/\\\//g, '/');
return JSON.parse(`"${htmlDecoded}"`);
} catch (error) {
console.error('Error parsing content:', error);
return content;
}
};

const loyaltyWidgetStyles = ``;
document.querySelector('body').insertAdjacentHTML('beforeend', loyaltyWidgetStyles);
const mainHTMLString = `
`;
document.querySelector('body').insertAdjacentHTML('beforeend', mainHTMLString);
window.addEventListener('message', 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.indexOf === 'function' && event?.data?.indexOf('appstle_widget_showHide') !== -1) {
document.querySelector('#appstle-loyalty-button')?.classList?.remove('appstle-loyalty-hidden');
toggleWidget();
} else if (event?.data && typeof event?.data.indexOf === 'function' && event?.data?.indexOf('refresh_appstle_loyalty_widget') !== -1 && _ALConfig?.widget_setting?.widgetType === 'LAUNCHER') {
loadAppstleLoyaltyWidget()
console.log("REFRESH WIDGET");
}
}

function removeAppstleLoyaltyWidget() {
document.querySelector('#appstle-loyalty-button')?.classList?.add('appstle-loyalty-hidden');
document.querySelector('#appstle_loyalty_iframe')?.classList?.add('appstle-loyalty-hidden');
}

(function checkForWidgetRestrictions() {
let isShowWidget = true;

if(_ALConfig?.customerLoyalty?.customerStatus === 'EXCLUDED') {
isShowWidget = false;
}
if (!_ALConfig?.customerId) {
isShowWidget = !(_ALConfig?.widget_setting?.restrictedCustomersTag || _ALConfig?.widget_setting?.allowedCustomersTag)
}
if (_ALConfig?.widget_setting?.allowedCustomersTag?.length && isShowWidget) {
let allowedTags = _ALConfig?.widget_setting?.allowedCustomersTag.split(',');
if (allowedTags?.length > 0 && !_ALConfig?.customerTags?.some((tag) => allowedTags?.some((allowedTag) => allowedTag?.trim()?.toLowerCase() === tag?.trim()?.toLowerCase()))) {
isShowWidget = false;
}
}
if (_ALConfig?.widget_setting?.restrictedCustomersTag?.length && isShowWidget) {
let restrictedTags = _ALConfig?.widget_setting?.restrictedCustomersTag?.split(',');
if (restrictedTags?.length > 0 && _ALConfig?.customerTags?.some((tag) => restrictedTags?.some((restrictedTag) => restrictedTag?.trim()?.toLowerCase() === tag?.trim()?.toLowerCase()))) {
isShowWidget = false;
}
}
if (_ALConfig?.widget_setting?.blockWidgetOnPages?.length && isShowWidget) {
let restrictedPages = _ALConfig?.widget_setting?.blockWidgetOnPages?.split(',');
const currentPage = window?.location?.pathname;
if (restrictedPages?.length > 0) {
if (restrictedPages?.includes('/homepage') && currentPage === '/') {
isShowWidget = false;
} else if (restrictedPages?.some((page) => currentPage?.includes(page))) {
isShowWidget = false;
}
}
}
if (_ALConfig?.widget_setting?.allowWidgetOnSpecificPages?.length && isShowWidget) {
let allowedPages = _ALConfig?.widget_setting?.allowWidgetOnSpecificPages?.split(',');
const currentPage = window?.location?.pathname;
if (allowedPages?.length > 0) {
if (allowedPages?.includes('/homepage') && currentPage === '/') {
isShowWidget = true;
} else if (allowedPages?.some((page) => currentPage?.includes(page))) {
isShowWidget = true;
} else {
isShowWidget = false
}
}
}
if (!_ALConfig?.customerId && _ALConfig?.widget_setting?.showToLoggedInCustomerOnly) {
isShowWidget = false;
}
if (isShowWidget) {
showAppstleLoyaltyWidget();
} else {
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);
}

function showAppstleLoyaltyWidget() {
document.querySelector('#appstle-loyalty-button')?.classList?.remove('appstle-loyalty-hidden');
document.querySelector('#appstle_loyalty_iframe')?.classList?.remove('appstle-loyalty-hidden');
}

document.querySelector('.appstle-loyalty-button').addEventListener('click', 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');

} else {
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 loyaltyButtonTitle = document.getElementById('loyalty-widget-title');
if(_ALConfig?.widget_setting?.widgetTitle){
loyaltyButtonTitle.innerHTML = parseHtmlStringContent(_ALConfig?.widget_setting?.widgetTitle);
}

const alIframeSrc=""
+ ' '
+ '

'
+ '

'
+ '

'
+ '' + 'body' + '>'
+ '';

function toggleWidget() {
loadAppstleLoyaltyWidget();
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', 'replace');
item.contentWindow.document.write(alIframeSrc);
item.contentWindow.document.close();
});
};

if (_ALConfig?.customerLoyalty && _ALConfig?.customerLoyalty?.availablePoints) {
document.querySelector('#appstle-loyalty-button')?.classList?.add('appstle_show_points');
document.querySelector('.loyalty_widget_available_points').innerHTML = _ALConfig?.customerLoyalty?.availablePoints?.toLocaleString();
}

if (_ALConfig?.widget_setting?.showTierName && _ALConfig?.customerLoyalty && _ALConfig?.customerLoyalty?.currentVipTier) {
document.querySelector('.loyalty_widget_available_points').innerHTML = _ALConfig?.customerLoyalty?.currentVipTier?.toLocaleString();
}

function handleDeepLink() {
const loyaltyDeepLinks = [
'#appstle-loyalty',
'#appstle-refer',
'#appstle-loyalty-earn-rewards',
'#appstle-loyalty-redeem-rewards',
'#appstle-loyalty-referrals',
'#appstle-loyalty-vip-program'
];
if (!_ALConfig?.widget_setting?.showWidget || !loyaltyDeepLinks.some(hash => location?.hash?.includes(hash))) {
return;
}
loadAppstleLoyaltyWidget();
enableWidget();
setTimeout(() => {
document.querySelector('#appstle_loyalty_iframe')?.classList?.add('show-close-icon');
}, 900);
}
handleDeepLink();

const widgetReferralUrl = new URL(window.location.href);
if (_ALConfig?.referralEnabled && widgetReferralUrl?.searchParams.get('appstle_referral') && _ALConfig?.widget_setting?.widgetType === 'LAUNCHER') {
let redirectURL = _ALConfig?.widget_setting?.referralRedirectUrl + window.location.search;
if (redirectURL && !window.location.pathname.includes(_ALConfig.widget_setting.referralRedirectUrl)) {
window.open(redirectURL, '_self');
}
setTimeout(() => {
loadAppstleLoyaltyWidget();
enableWidget();
}, 200);
}

(function observeURLChanges() {
let lastUrl = location.href;
const handleUrlChange = () => {
if (location.href !== lastUrl) {
handleDeepLink();
lastUrl = location.href;
}
};
new MutationObserver(handleUrlChange).observe(document.body, { subtree: true, childList: true });
window.addEventListener('popstate', handleUrlChange);
window.addEventListener('hashchange', 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.write(alIframeSrc);
item.contentWindow.document.close();
});
alDOMObserver.disconnect();
}
});
});
});
alDOMObserver.observe(document.querySelector('body'), { subtree: true, childList: true });


const dedicatedPageURL = new URL(window.location.href);
if (dedicatedPageURL?.searchParams?.get('appstle_referral') && _ALConfig?.widget_setting?.widgetType === 'DEDICATED_PAGE' && !window.location.href.includes(_ALConfig?.proxy_path_prefix)) {
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("REFRESH PAGE");
}
}
window.addEventListener('message', dedicatedPageEventListener, false);

function initiateAppstleLoyaltyPage() {
if (document.querySelector('#appstleLoyaltyPage')) {
const appstleLoyaltyPageElement = document.getElementById('appstleLoyaltyPage');
while (appstleLoyaltyPageElement.firstChild) {
appstleLoyaltyPageElement.firstChild.remove();
}

document.title = "";

setTimeout(() => {
let metaDescription = document.querySelector('meta[name="description"]');
if (metaDescription) {
metaDescription.content = "";
} else {
metaDescription = document.createElement('meta');
metaDescription.name = "description";
metaDescription.content = "";
document.head.appendChild(metaDescription);
}
}, 500)

var s = document.createElement('script');
s.setAttribute('src', "https://loyalty-admin.appstle.com/app/loyalty-widget.bundle.js?v=1747353408988");
s.setAttribute('defer', 'defer');
document.body.appendChild(s);

var head = document.head;
var link = document.createElement('link');

link.type="text/css";
link.rel="stylesheet";
link.href = "https://loyalty-admin.appstle.com/content/loyalty-widget.css?v=1747353408988";

head.appendChild(link);
} else {
setTimeout(() => {
initiateAppstleLoyaltyPage();
}, 2000);
}
}
const dedicatedPageReferralUrl = new URL(window.location.href)?.searchParams.get('appstle_referral');

const checkDedicatedPageForRestrictions = () => {
const { widget_setting, customerTags, customerLoyalty, customerId } = _ALConfig || {};
const { allowedCustomersTag, restrictedCustomersTag } = widget_setting || {};
const { customerStatus } = customerLoyalty || {};
if (customerStatus === 'EXCLUDED') {
return false;
}
if (!dedicatedPageReferralUrl && !customerId) {
return !(allowedCustomersTag || restrictedCustomersTag);
}
if (allowedCustomersTag?.length) {
const allowedTags = allowedCustomersTag.split(',');
if (!allowedTags.some(tag => customerTags?.some((customerTag) => customerTag?.trim()?.toLowerCase() === tag?.trim()?.toLowerCase()))) {
return false;
}
}
if (restrictedCustomersTag?.length) {
const restrictedTags = restrictedCustomersTag.split(',');
if (restrictedTags.some(tag => customerTags?.some((customerTag) => customerTag?.trim()?.toLowerCase() === tag?.trim()?.toLowerCase()))) {
return false;
}
}
return true;
};
if (_ALConfig?.widget_setting?.showWidget === true && checkDedicatedPageForRestrictions()) {
initiateAppstleLoyaltyPage();
}



(async function() {
const isAvailableVisitShop = _ALConfig?.pointEarnRules?.length > 0 && _ALConfig?.pointEarnRules?.find((rule) => rule?.type === 'VISIT_SHOP' && rule?.status === 'ACTIVE');
if (_ALConfig?.customerId && isAvailableVisitShop) {
if (!sessionStorage.getItem('syncVisitStore') && ((_ALConfig?.customerId && isAvailableVisitShop && isAvailableVisitShop?.id) || (_ALConfig?.referralEnabled && _ALConfig?.referralLoyalty?.referralType === 'VISIT_SHOP'))) {
try {
const response = await fetch(`/${_ALConfig?.proxy_path_prefix || 'apps/loyalty'}/cp/api/customer-visit-store`, { method: 'POST', headers: {'Content-Type': 'application/json'}, });
if (response?.ok) {
sessionStorage.setItem('syncVisitStore', 'true');
}
} catch (error) {
console.error('Error:', error);
}
}
}
})();



const loyaltyCustomStyles = ``;
document.querySelector('body').insertAdjacentHTML('beforeend', loyaltyCustomStyles);



Leave a Comment

Verified by MonsterInsights