-
-
Save Sally165/0e7725c5f9a1407ae34de92680be92ce 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 - DO NOT DELETE --> | |
<script> | |
try { | |
setTimeout(function () { | |
window.__pagefly_helper_store__ && | |
window.__pagefly_helper_store__.subscribe(function (res) { | |
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() } | |
}); | |
}); | |
}, 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