5

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.

2

1 Answer 1

6

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.

10
  • I have installed extension it's working for simple mail template but when i load new order template its not working.Please see the screen shot. awesomescreenshot.com/image/3416086/…
    – sky
    Commented Jun 13, 2018 at 9:47
  • Sorry, I could not understand. Can you please explain a bit more about your problem? Commented Jun 13, 2018 at 9:49
  • Generally if we want to add custom template for suppose new order functionality then we customize it and assign it from admin side. so i follow the same procedure. My Client requirement is he wants two different mail for customer order and merchant order confirmation. So i have installed one extension which you gave me. What i do is create a copy of sales order template in my custom template and assign it from admin. but when i place order in my mail(merchent mail) only get static data i dont get any dynamic data like "Billing Address and all" as per screen shot.
    – sky
    Commented Jun 13, 2018 at 10:00
  • @AkashPatel, Since the module is available free, it has limited features. You need to modify some functionality. Please check my updated answer. Commented Jun 13, 2018 at 10:13
  • 1
    How to pass the order item table (order review table) in the $var array? sales_email_order_item does not work if i put this code directly in the mail template. Commented Jun 13, 2018 at 11:32

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.