1

I need custom markup for payment method details in new order email.

There seems to be only a single variable available for payment method markup {{var payment_html}}

Wondering what's the best way to do it?

Is there a way to add custom variables in transactional email so that I can create custom ones like {{var payment_cc_type}} & {{var payment_cc_last4}}?

1 Answer 1

2

You would need to rewrite Mage_Core_Model_Email_Template_Mailer and you'll have to create a concrete method for the magic method setTemplateParams:

public function setTemplateParams($params)
{

    //you'll have to load your custom block and template - try it this way:
    $block = Mage::app()->getFrontController()->getLayout()->getBlock('custom/block');
    $block->setTemplate('custom/template.phtml');
    $html = $block->toHtml();

    $params['your_varname'] = $html;

    parent::setTemplateParams($params);

}

It's pretty simple - we're getting in between the magic method with a concrete method, injecting our template {{var your_varname}} handle for the email and then passing that up to the magic method!

Best of luck!

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.