I want to display a line only when the customer selects payment method checkout money order. When a customer select money order as payment method, I want to display a <li> additional line to the transaction e-mail.

If the customer selects an other payment method, the additional <li> should be hidden.

I tried this code, but that does not work:

{{depend order.getPayment().getMethod() == "checkmo"}}
    <li>payment check</li>

How can I achieve that?

3 Answers 3


In this case you can mange this by handler.

Use Handler:

Create handler and define it at layout file:

create a handler and using this handler rendered a phtml file . On local.xml at app/design/frontend/YOUR_PAackage/YOUR_template/layout define handler.

Layout file code like:

    <?xml version="1.0"?>
    <layout version="0.1.0">
<!-- add new handler -->
            <block type="core/template" name="addNewLi" template="sales/showcheckmo.phtml" />

Call this handler at email template

Then on email html call this handler(locale/YourLANG/template/email/)

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

phtml file code:

Then on phtml file put code like to show extra li

  <?php if($this->getOrder()->getPayment()->getMethodInstance()->getCode()=='checkmo'):?>
      <li>payment check</li>
     <?php endif;?>

Edit: location of phtml file is: app/design/frontend/YOUR_PAackage/YOUR_template/template/sales/

OR: Without call of handler:

call a block file without layout handler and ans parameter for

 {{block type='core/template' area='frontend' template='sales/showcheckmo.phtml' order=$order}}

In this case,need set to mangento area as frontend as phtml file calling from here

  • Hi Amit, where can I find the file showcheckmo.phtml or where do I need to create it?
    – JGeer
    Apr 23, 2015 at 14:11
  • updated,please check
    – Amit Bera
    Apr 23, 2015 at 14:14
  • Tried it, but that does not work. The line is not displayed inside the e-mail.
    – JGeer
    Apr 23, 2015 at 14:20
  • Try to put some static content on phtml. And CKD the text comming or not
    – Amit Bera
    Apr 23, 2015 at 14:23
  • No also with static content it does not work. What am I doing wrong?
    – JGeer
    Apr 23, 2015 at 14:27
order.getPayment().getMethodInstance().getCode() == 'banktransfer'
  • Tried that, but that did also not work :(
    – JGeer
    Apr 4, 2015 at 10:00

I'l try to answer on your initial question - how to use directive with condition. For debug I use xDebug. And in my opinion its very hard to debug emails. In that case I show you an example with the same structure in another part of magento.

On sales/order/view there is same structure. The address output structure determined in Mage/Core/etc/config.xml in default/customer/address_templates/text.

Our task will be add any condition to show or not to show 'company name'. Directives such as var, depend, if parse in Varien_Filter_Template in method filter($value). In this method there is iteration of all $constructions (if/depend/var) and every $construction used in this call:

$replacedValue = call_user_func($callback, $construction);

For each if/depende/var there is its own method. Lets look at public function ifDirective($construction)

public function ifDirective($construction)
    if (count($this->_templateVars) == 0) {
        return $construction[0];

    if($this->_getVariable($construction[1], '') == '') {
        if (isset($construction[3]) && isset($construction[4])) {
            return $construction[4];
        return '';
    } else {
        return $construction[2];

Now lets look at protected method _getVariable. I'd like to draw your attention on one row:

} elseif (isset($stackVars[$i-1]['variable']) && $stackVars[$i-1]['variable'] instanceof Varien_Object) {

and look at the comment below:

// If object calling methods or getting properties

So to make condition our $stackVars should be an object and be an instace of Varien_Object (most of models extends from Mage_Core_Model_Abstract, which extends from Varien_Object). Lets climb a few steps above. We need to add to stackVars and object.

In my example in class Mage_Customer_Block_Address_Renderer_Default magento calls method filter($value), which I mentioned above.

Here I provide a solution. Warning! This solution is not very clean. It's purpose to show magento behavior. Please do all rewrites yourself.

public function render(Mage_Customer_Model_Address_Abstract $address, $format=null)

    //parsing $data array


    $format = !is_null($format) ? $format : $this->getFormat($address);

    return $formater->filter($format);

In this method we will add an order object to $data array. According to my task lets add order object to this array. Do it before '$formater->setVariables($data);'

$data['order_object'] = $address->getOrder();

After this magento will parse this object and call any it's method. For example we add new method getPaymentOutput(). Put simple functionality into Order class:

public function isPrinted()
    if ($this->getPayment()->getMethod() == 'checkmo') {
        return true;
    } else {
        return false;

and only after that we make changes in xml directive with this:

{{if order_object.isPrinted()}}{{var smth}}<br />{{/if}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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