Skip to content

Instantly share code, notes, and snippets.

@krillo
Created December 22, 2017 15:28
Show Gist options
  • Save krillo/ba649ded28135031b851cad0af14ff42 to your computer and use it in GitHub Desktop.
Save krillo/ba649ded28135031b851cad0af14ff42 to your computer and use it in GitHub Desktop.
Magento2 catch ajax complete, add to cart
<script>
require(['jquery'], function ($) {
$(document).ajaxComplete(function (event, xhr, settings) {
if (settings.url.indexOf("customer/section/load/?sections=cart") > 0) {
cartObj = xhr.responseJSON;
console.log(cartObj);
cartPriceHtml = cartObj.cart.subtotal_excl_tax;
$(".cpa-cart-sum-sum").html(cartPriceHtml);
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment