I'm trying to send an extra mail using the customer-processing-order.php
template, so when a User received the mail with the order details, another subject will receive a similar mail.
This is my trying, but when I click on the submit order button the program freeze in a loading page.
function email_processing_notification( $order_id ) {
$order = wc_get_order( $order_id );
// load the mailer class
$mailer = WC()->mailer();
$recipient = 'constantmail@gmail.com';
$subject = __('Some Subject', 'test');
$content = get_processing_notification_content( $order, $subject, $mailer );
$headers = "Content-Type: text/html\r\n";
$mailer->send( $recipient, $subject, $content, $headers );
}
add_action( 'woocommerce_email_order_details', 'email_processing_notification', 10, 1 );
function get_processing_notification_content( $order, $heading = false, $mailer ) {
$template = 'emails/customer-processing-order.php';
return wc_get_template_html( $template, array(
'order' => $order,
'email_heading' => $heading,
'sent_to_admin' => true,
'plain_text' => false,
'email' => $mailer
) );
}