Customize ‘New Order’ Email template in Magento

Customizing the ‘New Order Confirmation Email‘ template in Magento may be a havoc for the first time if you do not know the write way. But it is as easy as anything. Recently I needed to customize the item information in the ‘New Order Confirmation Email’. I googled a number of links but found nothing useful. Then I decided to find my own way, and after 2 hours of hard work I found a simple way. Here are the steps to customize the email template:

1. In the Magento Admin panel go to ‘System > Transactional Emails’ and click on ‘Add New Template’.
2. In the ‘Load default template’ container select ‘New Order‘ in the ‘Template’ dropdown. Alse select our desired ‘Locale‘.
3. Click on ‘Load Template’. It will load the Default email template to edit for you. Now you can edit the ‘Template Subject’ and ‘Template Content’ to suit your needs. See the following screenshot:

Here we want to edit the item information in the order email. The email template calls a layout file as:

{{layout handle="sales_email_order_items" order=$order}}

for the item information. So we will replace this line so that we can call our own custom template in place of the default layout file.
Replace

{{layout handle="sales_email_order_items" order=$order}}

with

{{block type='core/template' area='frontend' template='<module_name>/orderemail.phtml' order=$order}}

where template='<module_name>/orderemail.phtml’ tells Magento the path of template file to be called. We have also passed order variable in the call as order=$order, so the $order variable is available to us in the template file that holds the current order information.
Save the template.

4. Now create orderemail.phtml in the template directory of your custom module.
Full file path: appdesignfrontenddefaultdefaulttemplate<module_name>orderemail.phtml
In this template file we have $order available to user. You can access the order id from $order variable as:

$order_id = $this->getData('order')->getRealOrderId();

Now you can access all order information here and write your custom HTML format to be shown in the email. You can change the way the item information is shown or add more item information in the email template.

5. Now in Magento Admin panel go to ‘System > Configuration > Sales Emails’. In the ‘Order‘ tab select your newly created template in the ‘New Order Confirmation Template’ dropdown. Save the options.

And you are ready to send the customized email template!!!

Written by Arvind Bhardwaj

Arvind is a certified Magento 2 expert with more than 10 years of industry-wide experience.

Website: http://www.webspeaks.in/

23 thoughts on “Customize ‘New Order’ Email template in Magento

  1. Nice post!
    However I cannot make it to work.
    Strange thing – the block is loaded into template (I can see it in email when debugger is on).
    But no content is loading from this block.
    Do you know what issue this may be?

    1. This is so strange, but suddenly i am having this problem too. i know this is old, but can you tell me how you fixed it?

    2. This is so strange, but suddenly i am having this problem too. i know this is old, but can you tell me how you fixed it?

    3. @Igor, Blogger
      Your issue seems to be a coding glitch. I dont think anyone can guess it without diving into the code. Otherwise it works absolutely fine.

      Thanks.

  2. It is not necessary to set up a new module. Simply copy

    /app/design/frontend/base/default/template/email/order/items.phtml

    and

    /app/design/frontend/base/default/template/email/order/items/order/default.phtml

    to your custom theme folder.

  3. You save my lot of time and found great knowledge which is helpful to many projects.
    Thanks for sharing such a great knowledge with us.

  4. everything was ok since the site went live, suddenly there are some order confirmation email are not sending, 4/5 out of 10 order the confirmation email not sending, struggling to solve this issue, can any one help me out please
    Thanks

  5. Hi,
    How can we send automatically an email to the suppliers whose order has been placed by the customer. For example: suppose i have three suppliers A, B and C.
    A supplier has one product. B has also one product. But C has more than 5 products. Now suppose as a client i give an order for the products from Supplier A (one item) and C (3 items). Now what i want that suppliers will receive mails (Supplier A will receive one mail and Supplier C will receive 3 mails for 3 different products) for theirs products automatically. I will be thankful to you if you can help me out.

  6. Please address the following:

    I have used this method similarly to add

    block type=’core/template’ area=’frontend’ template=’email/order/shipment/track.phtml’ shipment=$shipment order=$order

    for the purpose of adding the tracking number with a hyperlink using PHP in my track.phtml file located in my custom theme. All settings are correct in System->Configuration->Design in the Current Package Name.

    I am trying a couple third-party shippers using Magento API. They post the tracking number back to the order and change the status to Complete.

    The problem is that for some reason they are triggering some “default” or “base” files that refuse to use my custom payment.phtml and track.phtml files in the Transactional Email.

    I even backed up and then changed the payment and track files in the base/default and default/default folders just to see if that would change anything and it does not.

    When I manually add the tracking number and save it, the Shipment Transactional Email the track.phtml file is included fine, but NOT when the tracking number is delivered through the API for either 3rd-party shipping software.

    Please give me any feedback possible.

Comments are closed.