How to match add-on product quantities with main product in app development?

tnet1399
Shopify Partner
4 0 1

I am developing an app that facilitates customers in buying a main product along with some add on products attached to it. For instance, when they add product A to the cart, product B is automatically added with the same quantity. However, I am facing some particular issues: 

- When the stock for product B is limited, let's say only 3 units available, and a customer tries to add 4 of A to cart, the cart ends up with 4 of A and only 3 of B. This creates a mismatch in quantities. In such a scenario, I would like the app to add only 3 of A to the cart.

- If a customer already has 3 of A and 3 of B in the cart, I want to prevent them from adding more A when clicking the "+" quantity button.

I am seeking advice and possible solutions to address these issues. Any help would be greatly appreciated. Thank you.

Replies 0 (0)