Why does cart/add.js add available stock despite an error message?

Why does cart/add.js add available stock despite an error message?

Evgeniy-M
Shopify Partner
44 6 10

I've recently noticed when the cart/add.js endpoint receives a request to add more items to the cart than in stock, it returns an error but at the same time it adds all available stock to the cart!

 

So if you have an empty cart, and you have only 3 item in stock for a specific SKU, and you send a request to add 4 items of this variant to the cart, you'll get an error (which is expected), but at the same time all 3 available items will get into your cart!

 

It looks like a bug of the cart/add.js endpoint, as when an endpoint returns an error message, it shouldn't perform any actions.

 

This bug/feature isn't handled in the Dawn theme even.

 

Do we know if this is a bug of the add.js endpoint and it will be fixed soon, or it is a "feature" that will stay with us.

Liquid Ajax Cart — a Javascript library to build Shopify Ajax Carts using plain Liquid templates.
Reply 1 (1)

Evgeniy-M
Shopify Partner
44 6 10

The same thing is happening with the "change.js" endpoint!
If you set the new quantity to be higher than in stock, it will return an error but it will actually add all available quantity to the cart!

Liquid Ajax Cart — a Javascript library to build Shopify Ajax Carts using plain Liquid templates.