-
-
Save Sally165/f8fab62646848f85781a8070bcc6a2ce 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
<!-- PageFly cart helper custom. Please DONT DELETE --> | |
<script> | |
window.addEventListener('load', () => { | |
var pfATCs = $('#__pf').find('[data-pf-type="ProductATC"]'); | |
pfATCs.click(e => { | |
var checkoutAction = e.currentTarget.getAttribute('data-checkout'); | |
if (checkoutAction === 'same') { | |
window.__pagefly_helper_store__ && window.__pagefly_helper_store__.subscribe(function() { | |
$.getJSON('/cart.json').then(cart => { | |
var count = cart.item_count | |
$('.cart--external--total-items').text(count); | |
if (count > 0) { | |
$('.cart--external--total-items').css('display', 'inline-block'); | |
return $('.cart--external--total-items').parent().show(); | |
} else { | |
$('.cart--external--total-items').not('.header--mobile-cart-count').hide(); | |
return $('.cart--external--total-items').not('.header--mobile-cart-count').parent().hide(); | |
} | |
}); | |
$.ajax({ | |
url: theme.classes.FrameworkCart.prototype.getAjaxUrl(), | |
type: "GET", | |
dataType: "html" | |
}).done(function(data) { | |
var cart_html; | |
cart_html = $($.parseHTML(data)); | |
$('.cart--root').attr('data-has-items', true) | |
$('.cart--root').find('.cart--form').replaceWith(cart_html.find('.cart--form')); | |
}); | |
}) | |
} | |
}) | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment