AJAX Refresh Codes For Common Themes

THEME CODE
Impulse
$("form.ajaxcart .js-qty__num").first().trigger("change");

or

document.dispatchEvent(new CustomEvent('cart:build'));
		
Streamline
theme.cart._updateCart();
$(".nudge-offer").fadeOut(400,function(){ $(".nudge-offer").remove() });

OR

document.dispatchEvent(new CustomEvent("cart:build"))
document.querySelector(".nudge-offer").remove();
InCartUpsell.prototype.findOfferWhenReady();
		
Brooklyn
ajaxCart.load();
		
Flex
Shopify.theme.jsAjaxCart.updateView();
		
Prestige
fetch('/cart?view=drawer&timestamp=' + Date.now(), {
  credentials: 'same-origin',
  method: 'GET'
}).then(function (content) {
  content.text().then(function(html){ 
    document.getElementById("sidebar-cart").innerHTML = html; 
    document.getElementById("sidebar-cart").children[0].setAttribute("aria-hidden", "false");
  }) 
})

OR


jQuery.get('/cart?view=drawer&timestamp=' + Date.now(), function(data, textStatus, jqXHR) {
    jQuery("#sidebar-cart").html(jQuery(jQuery.parseHTML(data)).filter("#sidebar-cart").html());
    jQuery("#sidebar-cart").attr("aria-hidden", false);
    jQuery("#sidebar-cart").attr("tabindex", "-1");
    if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
        if (browserRatio >= 1.5) {
            jQuery("#sidebar-cart").attr("style", "min-height: 360px;");
        } else {
            jQuery("#sidebar-cart").attr("style", "min-height: 555px;");
        }
    } else {
        jQuery("#sidebar-cart").attr("style", "height: 100vh !important;");
    }
});

OR

document.documentElement.dispatchEvent(new CustomEvent('cart:refresh', {bubbles: true}));
		
Zen
$('.mini-cart').addClass('mini-cart--reloading');

$.ajax('/cart?view=mini-cart-content').then(function(cartContent) {
  $('.mini-cart .mini-cart__content').html(cartContent);
  $('.mini-cart').removeClass('mini-cart--reloading');
});
		
Motion
var ajcresp = theme.cart.getCart();
try{
  (new theme.CartDrawer()).buildCart(ajcresp.responseJSON);
}
catch (e){
   var oa = 1;
}
		
Pipeline
Shopify.getCart(ajaxifyShopify.buildCart);

!Important: Change Line 1131 in Ajaxify.js.liquid

FROM

module = {
	init: init
};

TO

module = {
	init: init,
	buildCart: buildCart;
};
		
Debut
closeAjaxCart();
ajaxCartUpdate();
		

 Parallax
ajaxUpdateCart(1, $(this).val(), $(this).parents('#cart'));<br>
		

 Turbo
$("[data-cart-quantity-input]").first().clone(true,true).val(1).css("display","none").appendTo($("[data-cart-quantity-input]").first().closest(".product-quantity-box")).trigger("change");

OR

$("input.quantity").first().clone(true,true).val(1).css("display","none").appendTo($("input.quantity").first().closest(".product-quantity-box")).trigger("change");
		

Editorial
$.ajax({
	url: "/cart.js",
	type: "GET",
	_sellify: sellify,
	success: function(resp){ this._sellify.ucd.helpers.ajaxCart.buildCart(resp); }
});
		
Minimal
$.getJSON("/cart.js", function(cart) {
refreshCart(cart);
});
		
Supply
$(".nudge-offer").remove();
$("form.cart-form .ajaxifyCart--num").first().trigger("change");
setTimeout(function(){ InCartUpsell.prototype.findOfferWhenReady(); },3000);
		
Booster
HsCartDrawer.updateSlideCart();
		
Narrative
$(".nudge-offer").remove();
$("form.cart-drawer .cart-drawer__item-quantity").first().trigger("input");
		
Debutify
theme.ajaxCart.update()

------- OR -------

$(".nudge-offer").remove(); 
$("form.ajaxcart .ajaxcart__qty-num").first().trigger("change"); 
setTimeout(
    function(){ 
        InCartUpsell.prototype.findOfferWhenReady(); 
    },
3000);

------- OR --------

Look for the following line in theme.js.liquid (Get collab access) and change it

FROM

module = {
	init: init
};

TO

module = {
	init: init,
	__lcart: loadCart
};

Then the refresh code will be 

AjaxCart.__lcart();
$(".nudge-offer").remove();
		
Warehouse
document.documentElement.dispatchEvent(new CustomEvent('cart:refresh', {
bubbles: true
}));
		
SlideCart
window.SLIDECART_UPDATE();
OR
window.SLIDECART_UPDATE(function() {
window.SLIDECART_OPEN()
});
		


Full list of SlidecartHQ callbacks

https://apphq.co/documentation/slide-cart-callbacks-and-methods 

Atlantic
$('.nudge-offer').remove()
fetch('/cart?view=mini', {
  credentials: 'same-origin',
  method: 'GET'
}).then(function (content) {
  content.text().then(function(html){ 
$('.cart-mini-content').html(html.replace('<script class="cartFlagX"></script>','').replace('<template data-options>','').replace('{}','').replace('</template>','').replace('<template data-html="content">','').replace('<template data-html="footer">',''))
$('.cart-mini-content .cart-mini-subtotal').remove()
$('.cart-mini-content .cart-mini-actions').remove()
$('.cart-mini-content .cartdrawer-information-header').remove()
  }) 
})
$('.quantity .field').trigger('change');<br>
		
Cart.js
CartJS.getCart();
document.querySelector('.nudge-offer').remove();
InCartUpsell.prototype.findOfferWhenReady();<br>
		
Venture
document.querySelector(".nudge-offer").remove();
fetchCart();
InCartUpsell.prototype.findOfferWhenReady();
		
Broadcast Theme
document.querySelector(".nudge-offer").remove()
cart.getCart()
InCartUpsell.prototype.findOfferWhenReady()
Shella Theme
document.querySelector('.nudge-offer').remove();
theme.cart.updateData()
setTimeout(() => { theme.cart.updateCart(); }, 1000);		
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us