Customising Magento Transactional Emails

As part of a recent project customising Magento emails I discovered a few useful bits and pieces that make creating custom transactional emails a little easier.

Static Blocks

I am not sure why I hadn’t thought of this but you can use static blocks in your emails in the same way as you would a CMS page. This is great because it allows you to make blocks that you can include in every email such as:
- Header
- Footer
- Promotional Content Area
- Social Links
etc and centrally manage it or allow the client to manage it rather than editing every email individually. The code you need is as follows:

{{block type="cms/block" block_id="email-header" template="cms/content.phtml"}}

You can place this code either in the emails you have setup within “system/transactional emails” or within your site directory “app/locale/en-us/template/email/email-file-name.html” with en-us being whatever locale you happen to be using.

Another cool thing about this is that you can easily upload images and include them within the static block admin screen rather than including the images in your theme. This makes it easy for clients to refresh certain sections themselves or write promotional content.

Referencing Store Information

Magento as standard references a few of the fields in the admin to populate the email eg. Store Name. However it is useful to also know that you can reference a lot more of the store information. For example if you are creating an email footer to state the stores name, address, telephone number, vat number etc you can pull all this information in dynamically so that your emails are kept up to date. The code required is:

Copyright: {{config path='design/footer/copyright'}}
Address: {{config path='general/store_information/address'}}
VAT No: {{config path='general/store_information/merchant_vat_number'}}
Telephone Number: {{config path='general/store_information/phone'}}
Email: {{config path='trans_email/ident_support/email'}}

and if you require anything else the easiest way to see how the field would be called is to browse to the section in the admin and inspect the field for its “name”. You would then write the code as follows:

{{config path=’tab in admin/sub section in admin/field name’}}

Comments

Be the first to write a comment about Customising Magento Transactional Emails…

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>