How to Send Different Order Emails to Admin and Customer in Magento 2

event-observermagento2transactional-mail

I want to send different transnational mail template for admin and customer. I know Magento gives the functionality for the CC transactional mail template. But in my case I want a different mail template for the administrator. So i want to create the functionality for the different mail template for the customer and admin after placing the order.

Best Answer

You may try pre-made extensions like:

or you can create a simple module, in which you may make use of observer or plugin feature of Magento 2 and write custom code to send additional email with your own template to the admin user.

Update: Modifications needed in some files as requested by @AkashPatel

File: app/code/Hiddentechies/Neworder/Observer/NewOrder.php

You can see that in the execute function, there are only admin_subject and cur_order_id are being passed as vars.

$vars = [
           'admin_subject' => $subject,
           'cur_order_id' => "#".$orderIncId,
        ];

You need to get more data in the observer function and pass it to the $vars array. Then you would need to get and show those vars in the following file.

app/code/Hiddentechies/Neworder/view/frontend/email/new_order_email.html

Please let me know if it helped.

Related Topic