Open DennisdeBest opened 3 years ago
Hello,
I have checked the error out. Neither endpoints have any validation on those properties. This is the reason you are getting a 500 error from this endpoint. (Which is not optimal in the first place.) But the reason the add fails is that it uses the OrderModifier
that we created in the ShopApiPlugin (here)
This checks that the cart has sufficient stock and asserts otherwise. However, the logic in the ChangeItemQuantityHandler
just calls the Sylius core method (that does not check the stock) and is done with it.
So the easy solution would be to add validation on both cases (one validator and then just add the constraint everywhere). Otherwise we could also try to unify the logic with the cart modification so that it can be used in both instances.
Hello,
When I try to add a product with a bigger quantity than is available (
POST /carts/{token}/items
) I get the following response :That is great but when I update the quantity of the product,
PUT /carts/{token}/items/{identifier}
it always passes even if the quantity is much higher than the available stock.Looking into
vendor/sylius/shop-api-plugin/src/Controller/Cart/ChangeItemQuantityAction.php
I can see tht it is thevalidate
function fron theDefaultCommandProvider
that is called. There are no constraints passed to this function. What could we do to check the inventory when the quantity gets changed ?