-
-
Save Sally165/813490651278ddaada97a2d6a6c98fa3 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', () => { | |
window.__pagefly_helper_store__ && | |
window.__pagefly_helper_store__.subscribe(function(c) { | |
theme.cart.getCartProductMarkup().then(html => { | |
var selectors = { | |
products: '[data-products]', | |
qtySelector: '.js-qty__wrapper', | |
subTotal: '[data-subtotal]', | |
}; | |
var markup = theme.CartForm.prototype._parseProductHTML(html); | |
var items = markup.items; | |
var count = parseInt(items.dataset.count); | |
var subtotal = items.dataset.cartSubtotal; | |
var savings = items.dataset.cartSavings; | |
var wrapper = $('#CartDrawerForm'); | |
var products = wrapper[0].querySelector(selectors.products) | |
var subtotals = wrapper[0].querySelector(selectors.subTotal) | |
theme.CartForm.prototype.updateCartDiscounts(markup.discounts); | |
theme.CartForm.prototype.updateSavings(savings); | |
if (count > 0) { | |
wrapper[0].parentNode.classList.remove('is-empty'); | |
} else { | |
wrapper[0].parentNode.classList.add('is-empty'); | |
} | |
theme.CartForm.prototype.updateCount(count); | |
// Append item markup | |
products.innerHTML = ''; | |
products.append(items); | |
// Update subtotal | |
subtotals.innerHTML = theme.Currency.formatMoney(subtotal, theme.settings.moneyFormat); | |
wrapper[0].querySelectorAll(selectors.qtySelector).forEach(el => { | |
var selector = new theme.QtySelector(el, { | |
namespace: '.cart-' + wrapper[0].dataset.location, | |
isCart: true | |
}); | |
}); | |
if (window.AOS) { AOS.refreshHard() } | |
}); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment