pass custom variable/parameter from email template to phtml file

笑着哭i 提交于 2019-12-04 12:47:54

Your problem here is that the 'test' value goes to the main block Mage_Sales_Block_Order_Email_Items that uses "email/order/items.phtml" tempalte.

In there you can find the data using:

<?php $test = $this->getTest(); // or $this->getData('test') ?>

You can then add this data into a registry.

But a better way is to send set this info onto the order items before the email. So, in email function before $mailer->setTemplateParams(); add a code like:

//$this = current order if you are in Mage_Sales_Model_Order
foreach ($this->getAllVisibleItems() as $item) {
    $item->setData('test', 'test_value_10');
}

To get variable in your email template

{{var test}}

Take a look @ Defining Transactional Variables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!