Sir, I want to update the stock of the product when a user successfully completes payment. I have got a solution of your which you posted earlier. But now I cant implement this in the project. Can you please help me out here? I really need it done soon. Thank you for your time.

My git repo of this project:


for (const index in order.orderItems) {
const item = order.orderItems[index];
const product = await Product.findById(item.product);
product.countInStock -= item.qty;
await product.save();

Anik Asked question December 10, 2022