An event which is fired at the document when a Liquid Ajax Cart has executed
all the Shopify Cart API Ajax requests from the Queue and
it is switching back to the “idle” mode.
Liquid Ajax Cart doesn’t perform Shopify Cart API Ajax requests immediately, it adds them to the Queue.
When a request is executed, it is removed from the Queue.
If there is no other request to perform, Liquid Ajax Cart triggers the liquid-ajax-cart:queue-end event.
The detailed explanation on when each event is fired and what exactly happens before and after each event is in the “Lifecycle, events, API” guide.
document.addEventListener("liquid-ajax-cart:queue-end", function() {
console.log("A queue of requests is finished");
console.log("The current cart state is: ", window.liquidAjaxCart.cart);
});
If you want to send a Shopify Cart API request from a liquid-ajax-cart:queue-end event listener,
you have a chance to get into infinity loop of requests:
liquid-ajax-cart:queue-end event,liquid-ajax-cart:queue-end event …In order to prevent this, make sure that you have a strong condition that won’t let the loop happen:
let ranOnce = false;
document.addEventListener("liquid-ajax-cart:queue-end", function(event) {
// condition to prevent infinity loop:
if (!ranOnce) {
ranOnce = true;
// send your request
window.liquidAjaxCart.add(...);
}
});