Customize 'New Order' Email template in Magento

21 comments
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: app\design\frontend\default\default\template\<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!!!

21 comments

Nice post brother !!!

Keep up the good work !!!

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?

Is it possible to add custom product attributes to the transactional emails?

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.

Thanx man its working fine for me.. thanx again..

check this, this may work
http://blog.free-extension.com/2011/04/07/adding-attribute-to-the-new-order-notification-email-in-magento/

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.

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

@Fozla Alahi Bhuyain, I dont think anyone can see to this issue without having access to the actual code.

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?

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?

@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.

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.

ala lakhota upload kar ni

Thank you for your post!

This one seems much easier: http://shamimcse05.wordpress.com/2011/04/07/adding-attribute-to-the-new-order-notification-email-in-magento/

Nice post, I spent a lot of time looking for where to save a new email template. If you're looking for a way to create a better looking template for new order emails, we built a free template creator specifically for Magento. You can give it a try at http://www.klaviyo.com/magento-email-templates.

Nice post, I spent a lot of time looking for where to save a new email template. If you're looking for a way to create a better looking template for new order emails, we built a free template creator specifically for Magento. You can give it a try at http://www.klaviyo.com/magento-email-templates.

We spent a bunch of time figuring out these instructions, so nice to have them in one place.

If anyone's looking for an easy/free way to create a better looking new order template, we built a template creator you case use: http://www.klaviyo.com/magento-email-templates.

Very Nice Article

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.

We would love to hear from you...

back to top