2

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 ?

1

2 Answers 2

6

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

2

You must create an extension:

  1. First of all you have to overwrite the customer account page layout in order to introduce the control (button) that links to a functionality.
  2. The button you added should link to a controller that does the job.
  3. Eventually you will need to add some blocks to render any output/intermediate interaction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.