Skip to content

Instantly share code, notes, and snippets.

@Sally165
Created April 21, 2023 09:16
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/ec7499177b190e5b5c6e189d2e6fd217 to your computer and use it in GitHub Desktop.
Save Sally165/ec7499177b190e5b5c6e189d2e6fd217 to your computer and use it in GitHub Desktop.
<!-- PAGEFLY CART HELPER - DO NOT DELETE -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
try {
setTimeout(function () {
window.__pagefly_helper_store__ &&
window.__pagefly_helper_store__.subscribe(function (res) {
$.getJSON('/cart.json').then(cart => {
fetch('/?snippets_id=cart-drawer').then(d=>d.text()).then(text=>{
const sectionInnerHTML = new DOMParser().parseFromString(text, 'text/html');
const cartFormInnerHTML = sectionInnerHTML.getElementById('site-header-drawer-cart').innerHTML;
$('#site-header-drawer-cart').html(cartFormInnerHTML)
$('[data-header-drawer-toggle="cart"]')[0].click()
$('span.site-header-action-icon-cart-count').html(cart.item_count)
})
});
});
}, 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