You're looking at the documentation for Liquid Ajax Cart v1. Go to Liquid Ajax Cart v2


State is a Javascript object where Liquid Ajax Cart keeps the information related to user’s cart.


State gets updated after each Shopify Cart API request.

Always use the functions from the Cart Ajax API requests reference instead of direct Cart API calls and Liquid Ajax Cart will make sure that the State is up to date.



Contains JSON versions of the Shopify cart liquid object.

The property data is getting loaded from the data-ajax-cart-initial-state script.

The property gets updated after each successful Shopify Cart API request.


Contains a JSON object that was in the cart property before the cart was updated due to the last successful Shopify Cart API request.

The cart and the previousCart properties are not always different. If the previous Shopify Cart API request didn’t make any changes in the cart but returned Shopify cart JSON-data, for example a “Get” request or an empty “Update” request, the cart and the previousCart will be 100% same.


The status.cartStateSet is true if the cart property is loaded.

The js-ajax-cart-set CSS class will be added to the body tag if the property is true.


The status.requestInProgress is true if there are one or more Shopify Cart API requests in Queues.

If the property is true:


Use the getCartState function to get the current state.

If you want to run your Javascript code each time when the state is get updated — use the subscribeToCartStateUpdate function.