Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Sally165
Created April 24, 2023 02:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sally165/e0cba48f692997871f943ddc6581566a to your computer and use it in GitHub Desktop.
Save Sally165/e0cba48f692997871f943ddc6581566a to your computer and use it in GitHub Desktop.
<!-- 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