-
-
Save Sally165/9797856cceaca9289750f6dc57736d95 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
<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