Skip to content

Instantly share code, notes, and snippets.

@Sally165
Created April 21, 2023 10:02
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/8b29ba47e0b3c1700f5b071e33f93e23 to your computer and use it in GitHub Desktop.
Save Sally165/8b29ba47e0b3c1700f5b071e33f93e23 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(data => {
var count, total_price;
total_price = theme.utils.formatMoney(data.total_price);
count = data.item_count;
$('.header--cart-number').attr('data-item-count', count);
$('.cart--root').attr('data-has-items', true);
$('.cart--external--total-price').text(total_price);
$('.cart--external--total-items').text(count);
var url
if (theme.partials.Cart.view === 'mobile') {
url = theme.partials.Cart.ajax_mobile_url
} else {
url = theme.partials.Cart.ajax_desktop_url
}
$.ajax({
url: url,
type: "GET",
dataType: "html"
}).done(function(data) {
var cart_html;
cart_html = $($.parseHTML(data));
$('.cart--root').html(cart_html[1]);
});
});
});
}, 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