0

I would like to achieve the following in the New Order Email Template (Magento):

If (order amount > 300 EUR) echo "some example text" else echo nothing

Any ideas on how I can achieve this the most simple way?

I noticed that Magento uses {{depend}} in the template, but I can't really figure out on how to solve my case.

Thanks in advance!

1

I think the best way is to rewrite the Mage_Sales_Model_Order::sendNewOrderEmail()
What you need to change is the list of variables assigned to the template. So turn this :

$mailer->setTemplateParams(array(
        'order'        => $this,
        'billing'      => $this->getBillingAddress(),
        'payment_html' => $paymentBlockHtml
    )
);

Into this:

$customText = '';
if ($this->getBaseGrandTotal() > 300) {
    $customText = "Your 300E text here";
}
$mailer->setTemplateParams(array(
        'order'        => $this,
        'billing'      => $this->getBillingAddress(),
        'payment_html' => $paymentBlockHtml, 
        'custom_text'  => $customText
    )
);

After doing this you can add in your e-mail template just this line in the place you want the text to appear

{{var custom_text}}
| 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.