I have a use case where I need to make back to back call to “add“ endpoint of AJAX api, but it is not adding items from the second “add“ call.
I am receiving “200” response for both the api calls.
interestingly, I can not see response from both the network calls in the Network tab of the browser.
I do not make both requests in parallel, the second api call is made after first one is complete.
At the moment, I am adding 2 seconds await in between these two ‘add‘ calls.
Any one else having such use case, and experiencing similar issue, or is there any technical part that I am missing.
Most likely it’s some kind of protection on Shopify’s side.
The Shopify Online Store AJAX cart API supports adding multiple line items in one API call: Cart API reference
Use the POST /{locale}/cart/add.js endpoint to add one or multiple variants to the cart.
What you could do is use a debounce on your app’s frontend logic to make sure that all selections are done by a customer in a reasonable amount of time before the Shopify Cart Add endpoint request.
This way you can improve performance and comply with rate limiting or the protection in place by Shopify on this endpoint.