EPOOLSUPPLY - FROM OUR STORE TO YOUR DOOR

CCH Chemicals

View as

' + '' + '
' + '
' + '
' + '
' + '
' + '' + ''; 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 (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(); } var s = document.createElement('script'); s.setAttribute('src', "https://loyalty-admin.appstle.com/app/loyalty-widget.bundle.js?v=1737345605922"); 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=1737345605922"; 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);