3

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

Thanks

4

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?

  • I cannot guarantee that it will be easy to directly copy and use them. But I think it will give you a good idea. And if you somehow get stuck, well, just add a new question here :) – Marjan Sep 4 '18 at 8:22
0

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
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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