I am trying to modify my email template to generate different product information based on customer group. As in, if a customer belongs to Group A, load modified.phtml
, else load default.phtml
.
Specifically, I am working with the New Order email template where the base transactional email template calls {{layout handle="sales_email_order_items" order=$order}}
, which loads the template file in /app/design/frontend/rwd/default/template/email/order/items.phtml
.
This template eventually calls echo $this->getItemHtml($_item)
.
From what I can tell, this loads the template file /app/design/frontend/rwd/default/template/email/order/items/order/default.phtml
, which outputs the template information to print each item's content (SKU, Name, Price, etc) in the table.
This is what I'm trying to accomplish:
$customerGroupId = $this->getCustomerGroupId();
$customerGroupName = Mage::getModel('customer/group')->load($customerGroupId)->getCustomerGroupCode();
if($customerGroupName = 'A') {
// How to getItemHtml from different template?
} else {
echo $this->getItemHtml($_item)
}
I assume that I will need to add reference to my modified.phtml
in the /app/design/frontend/rwd/default/layout/sales.xml
file like so:
<sales_email_order_items>
<block type="sales/order_email_items" name="items" template="email/order/items.phtml">
<action method="addItemRender"><type>default</type><block>sales/order_email_items_order_default</block><template>email/order/items/order/default.phtml</template></action>
// modified.phtml reference here?
Can I make getItemHtml
specify a different template?
Or is there a different way I need to be approaching this?
I could replace the {{layout handle...}}
with a {{block...}}
call and put all of the template information within my if... else...
blocks, but this seems very hacky. Any thoughts or suggestions?