Update order status

When a product's status is changed to any value other than Processing and Cancelled, a PUT request to '/api/order/status/:shopId' will directly update the order in the database given the current user is the verified owner of the shop with the ordered product.

mern-marketplace/server/routes/order.routes.js:

router.route('/api/order/status/:shopId')    .put(authCtrl.requireSignin, shopCtrl.isOwner, orderCtrl.update)

The update controller method will query the Order collection and find the order with the CartItem object that matches the updated product, and set the status value of this matched CartItem in the products array of the order.

mern-marketplace/server/controllers/order.controller.js:

const update = (req, res) => { ...

Get Full-Stack React Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.