-
-
Save Sally165/e0cba48f692997871f943ddc6581566a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- PAGEFLY CART HELPER - DO NOT DELETE --> | |
<script> | |
try { | |
setTimeout(function () { | |
window.__pagefly_helper_store__ && | |
window.__pagefly_helper_store__.subscribe(function (res) { | |
$.getJSON('/cart.json').then(cart => { | |
this.selectorPopup = '.js-popup-cart-ajax'; | |
this.$counterDesktop = $('[data-js-cart-count-desktop]'); | |
this.$counterMobile = $('[data-js-cart-count-mobile]'); | |
this.$popup = $('.js-popup-cart-ajax'); | |
const getPopupContent=()=> { | |
return fetch("/cart?view=popup", { method: 'GET'}) | |
.then(response => response.text()) | |
.catch(error => console.error('Error:', error)); | |
} | |
getPopupContent().then(data => this.$popup.html($(data).find(this.selectorPopup).html())); | |
const count = cart.item_count; | |
this.$counterDesktop.attr('data-js-cart-count-desktop', count).html(`Bag (${count})`) | |
this.$counterMobile.attr('data-js-cart-count-mobile', count).html(count); | |
$('a[href="/cart"][data-js-popup-button="cart"]')[0].click() | |
}); | |
}); | |
}, 2500); | |
} catch (e) { | |
console.warn(e); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment