Magento – Shipping information in sales order email

email-templates

Is it possible to replace the shippingDescription string in the order email templates for a custom phtml file to add a login functionality and a text that has to be translated with a custom language translator class.

Best Answer

The easiest way is to rewrite the Mage_Sales_Model_Order class in your own extension adding the function getShippingDescription which is called in the email template (see below)

<td valign="top" style="font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;">
   {{var order.getShippingDescription()}}
   &nbsp;
</td>

The new getShippingDescription method would return a block instance from your module that has the modifications you want.

your rewritten Sales Order class app/code/[codepool]/[Namespace]/[Module]/Model/Sales/Order.php

class [Namespace]_[Module]_Model_Sales_Order extends Mage_Sales_Model_Order
{
   public function getShippingDescription()
   {
      return Mage::app()->getLayout()->createBlock('core/template')->setTemplate('path/to/your/file.phtml')->toHtml();
   }
}
Related Topic