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 = '[email protected]';
$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
) );
}
You should better add the additional email address as Bcc using (for processing email notification):
Code goes in function.php file of your active child theme (or active theme). It should works.
This way is much more simpler and the additional email address will be hidden from customer.