Magento – Magento 2 : Is it possible to add order cancellation functionality in frontend

edit-ordermagento2order-statussales-order

I want to give the order cancellation functionality in frontend to user in case of order not shipped.
What would be the step to achieve this functionality ?

Best Answer

This is more complicated than it sounds.

Cancellation while pending is easy. The method is described in Cancel Order from magento 2 frontend? and I've implemented it in a module with the template tweaks needed (and confirmation dialogues).

https://github.com/lingwooc/cancel-magento2

You should note this only works for pending orders. Most orders (especially online payments) won't go into pending, they will go into processing. For online payments this means the money will have been taken and will need to be refunded. Magento doesn't allow cancellation at this stage, only shipping or refund. I would think carefully about whether you want your customers to be able to generate a refund automatically. There is the potential you may ship refunded goods if you don't have a robust process. I would implement this as a refund request which should generate a support ticket. The module above has the templates/layouts that you would need to change to add such a button.

This chart shows the status change flow of a mangeto2 order.

Magento2 order status flowchart

Source question: New order status staying "pending" instead of processing in Magento 2

Source: https://www.mexbs.com/magento-blog/magento-order-statestatus-flow

Related Topic