I'm trying to get a custom attribute from an order into the new order transactional email template, BUT I need to pass it through some custom PHP for a bit of formatting first.
In the email template I use the following declaration:
{{block type='mymodule/myblock' area='frontend' template='mynamespace/mymodule/mytemplate.phtml'}}
With a block like this:
class Mynamespace_Mymodule_Block_Myblock extends Mage_Core_Block_Template
{
public function getValue()
{
return "Some value";
}
}
and mytemplate.php like this:
echo $this->getValue();
This all works and I get "Some value" appearing where I expect in the transactional email.
The problem I have is that I cannot get any information about the order within the block or template. Using code such as this:
$orderid = Mage::getSingleton('checkout/session')->getLastOrderId();
$order = Mage::getModel('sales/order')->load($orderid);
just gives me NULL. For some reason by the time it get to processing my block the session data has been cleared.
I've tried changing my block to extend Mage_Sales_Block_Items_Abstract as the core magento email template does, but then when I copy the code in app/design/frontend/base/default/template/email/order/items.phtml to my template the checkout process doesn't complete on step 5 and it just keeps showing the 'place order' button.