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.


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()}}

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();
| improve this answer | |
  • Is it possible to make this a PHP file as I need to add some login/functionality in to this? I have a custom language translator class that I need to pass text in to. I guess I would need to override the getShippingDescription() function? – Ste Oct 31 '14 at 14:39
  • order.getShippingDescription() refers to the getShippingDescription() method of the order object, so it already is in it's own PHP class (Mage_Sales_Model_Order). You could rewrite this class and make the necessary changes to the method. – Jonathan Hussey Oct 31 '14 at 14:47
  • @JonathanHussey updated my answer and then saw your comment... Great minds think alike? :P – Sander Mangel Oct 31 '14 at 14:53

I suggest to create custom layout and and assign the your template file and with use of block type sales/order_email_items just like oorder item item is render thorh'

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

Step1:just create replicate of this code at email template

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

Step2:define handler for this layout at sales.xml

        <block type="sales/order_email_items" name="items" template="email/order/your.phtml">
      <block type="core/text_list" name="additional.product.info" />

On this phtml file you can get order object by $this->getOrder() now you can get all details of model

Now do all code here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.