JavaScript API

liquidAjaxCart.processing

A boolean read-only property of the liquidAjaxCart object, which is true when there is a Shopify Cart API Ajax request in progress.

How it works

The liquidAjaxCart.processing property returns true when the Queue of requests is not empty, which means that Liquid Ajax Cart is currently executing Shopify Cart API Ajax requests until the Queue of requests is empty.

Use case

Check this property when you are building a custom control, and you want to initiate a Shopify Cart API Ajax request only when there is no any other request in progress:

document.querySelector("#my-control").addEventListener("click", function() {
  if (!window.liquidAjaxCart?.init)
    return;

  // Ignore the click if Liquid Ajax Cart is processing a request
  if (window.liquidAjaxCart.processing)
    return;

  // Run the custom request is there is no other request in progress
  window.liquidAjaxCart.add({…});
});