When a seller decides to cancel the order for a product, a PUT request will be sent to /api/order/:shopId/cancel/:productId so the product stock quantity can be increased, and the order updated in the database.
mern-marketplace/server/routes/order.routes.js:
router.route('/api/order/:shopId/cancel/:productId') .put(authCtrl.requireSignin, shopCtrl.isOwner, productCtrl.increaseQuantity, orderCtrl.update) router.param('productId', productCtrl.productByID)
To retrieve the product associated with the productId parameter in the route, we will use the productByID product controller method.
The increaseQuantity controller method is added to product.controller.js. It finds the product by the matching ID in the Product collection ...