When I send out my transactional email programatically, I'm not getting any items in a table like I do when the email is sent automatically.
Looking into the templates, the information is pulled across via:
{{layout handle="sales_email_order_items" order=$order}}
This is sending directive:
$emailTemplate = Mage::getModel('core/email_template')->loadByCode("More Information Required");
$emailTemplate->setSenderEmail(Mage::getStoreConfig('trans_email/ident_general/email', Mage::app()->getStore()->getStoreId()));
$emailTemplate->setSenderName(Mage::getStoreConfig('trans_email/ident_general/name', Mage::app()->getStore()->getStoreId()));
$emailTemplate->send($order->getCustomerEmail(), $order->getCustomerName(), [
'order' => $order,
'customer' => $order->getCustomerName(),
'dateAndTime' => $order->getCreatedAt()
]);
All the data is filled correctly, except the order items grid. Nothing is displayed for this.
Update
To answer the question in the comments, the $order
variable is generated as a result of an observer action on an event (in this case, sales_order_save_after
). The variable that eventually becomes $order
(when passed into a function) is formed as follows:
$observer->getEvent()->getData('data_object')
This contains a standard order object, of the following class: Mage_Sales_Model_Order
$emailTemplate->send
, is that pseudo-code? See your third argument. You can't construct an array in PHP with brackets like that ([]
) - it would throw an exception.