Magento 1.9 – Using Custom Variable Plain Value in Email Templates

custom-variableemail-templatesmagento-1.9

I'm aware that it's possible to call the HTML value by:
{{customVar code=custom_variable_code}}

Question is simple:
Is it possible to receive plain value of custom variable in email template (Magento 1.9.2.0) with some statement like:
{{customVar code=custom_variable_code|plain}}?
If it's not, are there any tips to get something like that to work?

Best Answer

It is but it'll require some coding.

In a nutshell this is how an email is sent

$template  = Mage::getModel('core/email_template')->loadDefault('[email identifier]');                                  

$template->send('email@domain.com','John Doe', array(
   'myvar' => 'foo',
   'myvar2' => 'bar',
));

now we can access the variables using {{var myvar}} and {{var myvar2}}

So to inject your values you'll need to make modifications to the array with variables injected into the send method.

It depends on what email you want to change