Customers able to add more items than available to cart including when out of stock.

Tourist
7 0 2

Hi, we're trying to use the /cart/update.js endpoint to change item quantities in the cart, however, this call is allowing users to add items to the cart even if there's no inventory, without returning a 422 error message as the documentation states. Item tracking is enabled for the product.

Conversely, when using the /cart/add.js endpoint, to initially add items, this will return the 422 error if adding more quantity than is available, but /cart/update.js does not do this.

 

The documentation states it should return a 422, but does not:
https://help.shopify.com/en/themes/development/getting-started/using-ajax-api#update-cart

 

Any Shopify Experts able to look into this? I emailed support, but of course they say they don't support the API.

Thanks.

0 Likes
Highlighted
Shopify Partner
1486 103 299

I'd use /cart/change.js instead as it is for and only for quantities. Or is there any specific reason you need update?

I turn coffee in to code - since 1998
0 Likes
Tourist
7 0 2

Hi Karl,

 

 Thanks for your response. /change.js seems to work, but doesn't return any error, just stop the limit at the available quantity, then the returned cart is capped/limited with the available numbers. That works, but leaves the user kind of confused. I suppose as a sort of hack I could check if the submitted quantity update differs from the returned number in the cart and suggest that the inventory is maxed out. Still think Shopify should fix /cart/update.js to work as the documentation describes!

 

1 Like
Shopify Partner
1486 103 299

Agreed 👍

I turn coffee in to code - since 1998
0 Likes