Altering variables in Magento e-mail templates

You've now seen how and where to alter some of the basic HTML behind Magento's e-mail templates, but sometimes a little more customization is required.

Navigate to System | Transactional Emails and select the New Order v2 template you created in the previous section of this chapter to begin editing it to use the customer's first name, rather than their full name, as it is currently displayed:

Altering variables in Magento e-mail templates

In the Template Content field, locate the following line, which adds the customer greeting line:

<h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Hello, {{htmlescape var=$order.getCustomerName()}}</h1>

Magento Insert Variable pop up

Magento provides some variables in the pop up that is shown if you click on the Insert Variable button above the Template Content field as you can see in the following screenshot:

Magento Insert Variable pop up

Using the customer's first name only in e-mail templates

The customer's first name is not listed here, so you will manually need to change the code highlighted above to:

<h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Hello, {{htmlescape var=$order.getCustomerFirstname()}}</h1>

Once you have made this change, click on the Save Template button at the top-right corner of the screen. If you send the e-mail confirmation order again to test your change, you will see that only the customer's first name is displayed in the template, as shown in the following screenshot:

Using the customer's first name only in e-mail templates

Tip

Don't forget that you have to assign the new template by navigating to the System | Configuration | Sales Emails section of the Magento administration panel, if you haven't already, to see this template sent in place of the default template.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset