I am currently working on a marketplace but I cannot update the stocks when a new order is placed. I have 3 data types :
1. Product
Products added by store owners.
2. Ordered product
This includes a single ‘product’ + additional fields (quantity etc). Created by users when they add a product to their baskets.
3. Order
This includes a list of ‘Ordered products’ + additional fields
Basic workflow is :
1 A customer adds products to his basket
2 New ordered products are created and added to his current order
3 the customer pays and a new order is placed.
So, I have a list of ordered products in my cart, and each of them has its quantity. When the order is placed, I would like the quantity of each products from oredered products in the cart to be decreased by the amount of the ordered product quantity that contains current product.
I had tried something similar yesterday, telling myself that the logic behind would be to decrease the amount of the oredered product that contains the product but I always failed.
Update : the last sentence (quantity) is evaluated to a list of numbers. Maybe this will help
Update 2 : added :first item at the end of sentence. Sentence is correct, but not working. Quantities are not updated…