Cart Ajax API requests
It is highly recommended to use the following functions to make Shopify Cart Ajax API calls so Liquid Ajax Cart will keep the State, cart sections, body CSS classes and data-ajax-cart-bind-state
content up to date:
cartRequestGet
— sends a request to theGET /cart.js
endpoint;cartRequestAdd
— to thePOST /cart/add.js
endpoint;cartRequestChange
— to thePOST /cart/change.js
endpoint;cartRequestUpdate
— to thePOST /cart/update.js
endpoint;cartRequestClear
— to thePOST /cart/clear.js
endpoint.
Subscribe to requests
If you want to run your Javascript before or after a Shopify Cart Ajax API request, mutate or cancel a request before it is started — use the subscribeToCartAjaxRequests
function to add your callback.
Queues of requests
All Shopify Cart API requests don’t get performed immediately but get added to queues.