I use the cart transform expand operation to build custom bundles, e.g. select 18 cupcakes to get 10% off.
Let’s say the customer adds 10 chocolate cupcakes, but only 8 are available, the cart API error response will show:
The product ‘{{ parent-product.name }}’ is already sold out.
Can you give me the available quantity? I want to tell the customers to remove 2 chocolate cupcakes and continue, or I will remove 2 for her. Now, the error message will tell customers to leave, which is not satisfactory.
However, I see no way to get this quantity or even the bundle component name. Is there any feasible way? I need both the product variant name and the quantity
The storefront API may be able to do so. But it’s too heavyweight for this particular use case. Also, checking all item quantities may slow down the add to cart action.