Magento – Magento transactional email for new order sometimes using wrong output block

email-templatestemplatetransactional

In my new order email, i have the line:

"layout area=\"frontend\" handle=\"sales_email_order_invoice_items\" invoice=$invoice order=$order":"Invoice Items Grid",

The majority of the time the email formats correctly using the correct template I've created in themename/default/template/email/sales/order/totals.phtml. However, roughly 10% of the time, this template is not being used – I assume because $order is returning false and it's using "Invoice Items Grid" instead.

a) Is my assumption correct?

b) If so, what triggers $order to be false here? I can't find any common theme with the customers who have received the incorrectly formatted emails.

c) What generates "Invoice Items Grid" instead, is it the Mage_Adminhtml_Block_Sales_Order_View block?

Thanks in advance for any insight!

Best Answer

Use handle="sales_email_order_items" instead of handle="sales_email_order_invoice_items" because, some times invoice not be created automatically and you cannot use invoice items in your phtml. Invoice creation related to payment or your store payment configuration. New order email will sent when order state (not status) is changed to processing. Order state will be processing when payment approved or invoice created manually in the backend. See original email templates to figure out the situation.

Related Topic