Pergunta

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}}?

Foi útil?

Solução

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!

Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top