Question

Hi is it also possible to get email notification for cancelled orders?

Thanks

Was it helpful?

Solution

You can always write your own module that will do that.

You will need few ingredients for that:

  1. Have an observer that listens on the sales_order_save_after event.

    This link explains it well

    catch order place after event magento2

    In this observer you will get the order object by $order= $observer->getData('order'); and you could check if the new status is canceled

  2. If condition from point 1 above is true you can proceed to send an email programatically. This link offers good idea of how to do that

    How to send mail programmaticlly in magento2?

OTHER TIPS

You will need to create a separate functionality for sending the email on order cancellation.

You can use the order_cancel_after event for writing your email function.

You can get the order details using the order object as given below

<?php

namespace Vendor\Module\Observer;

use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;

class OrderCancellationEmail implements \Magento\Framework\Event\ObserverInterface
{
    /**
     *
     * @param \Magento\Framework\Event\Observer $observer
     * @return $this
     */
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $order = $observer->getData('order');
        // Write your email function here
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top