Skip to content

Instantly share code, notes, and snippets.

@Sally165
Created April 24, 2023 01:46
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/9797856cceaca9289750f6dc57736d95 to your computer and use it in GitHub Desktop.
Save Sally165/9797856cceaca9289750f6dc57736d95 to your computer and use it in GitHub Desktop.
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- PAGEFLY CART HELPER - DO NOT DELETE -->
<script>
window.addEventListener('DOMContentLoaded',(event)=>{
$('[data-checkout="same"][data-pf-type="ProductATC"]').each((i,atc)=>{
$(atc).on('click',()=>{
console.log('clicked')
setTimeout(()=>{
$.getJSON('/cart.json').then(cart => {
fetch('/?section_id=cart-drawer').then(d=>d.text()).then(text=>{
const sectionInnerHTML = new DOMParser().parseFromString(text, 'text/html');
console.log('sectionInnerHTML',sectionInnerHTML)
const cartFormInnerHTML = sectionInnerHTML.getElementById('cart-drawer').innerHTML;
console.log('cartFormInnerHTML',cartFormInnerHTML)
$('#cart-drawer').html(cartFormInnerHTML)
$('[aria-controls="cart-drawer"]')[0].click()
$('.header__cart-count .count-bubble ').html(cart.item_count).css('opacity',1)
})
})
},1500)
})
})
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment