I would like to programmically fire a new order email, so it looks the same as the standard Woo Commerce email template.
I am using the WC_Email_New_Order class, so I can made adjustment to the order object before the email is constructed from it.
Here in some test code, I am firing it the wp_head hook for now, just for testing purposes.
add_action('wp_head', function() {
include('wp-content/plugins/woocommerce/includes/emails/class-wc-email.php');
include('wp-content/plugins/woocommerce/includes/emails/class-wc-email-new-order.php');
$adminEmail = new WC_Email_New_Order();
$id = 1564; // order
$order = new WC_Order($id);
$adminEmail->trigger( null, $order );
});
This works partially... I get the email with the correct subject line, however the body of the email just says...
You’ve received the following order from Dave Peterson:
How do I get the rest of the email template to fire?