I have tried several methods to add additional recipients to Woocommerce emails, but it only seems to work on test orders where the primary recipient is the admin.
These are the snippets I've tried. If the customer for the order is the admin, the email is sent both addresses. If the order contains a customer email address, it is only send to that email address and not the CC.
Here are the code snippets I've tried:
add_filter( 'woocommerce_email_recipient_customer_processing_order', 'my_email_recipient_filter_function', 10, 2);
function my_email_recipient_filter_function( $recipient ) {
$recipient = $recipient . ', [email protected]';
return $recipient;
}
.
add_filter( 'woocommerce_email_headers', 'woocommerce_email_cc_copy', 10, 2);
function woocommerce_email_cc_copy( $headers, $email ) {
if ( $email == 'customer_processing_order') {
$headers .= 'CC: Your name <[email protected]>' . "\r\n"; //just repeat this line again to insert another email address in BCC
}
return $headers;
}
.
This one works, but fires with every single email notification:
add_filter( 'woocommerce_email_headers', 'mycustom_headers_filter_function', 10, 2);
function mycustom_headers_filter_function( $headers, $object ) {
$headers .= 'CC: My name <[email protected]>' . "\r\n";
return $headers;
}
If I add the email $object
in, so it only fires for customer processing orders, it only cc's on the admin emails (cc only, not recipient), not customers (neither cc nor recipient).
add_filter( 'woocommerce_email_headers', 'mycustom_headers_filter_function', 10, 2);
function mycustom_headers_filter_function( $headers, $object ) {
if ( $object == 'customer_processing_order') {
$headers .= 'CC: My name <[email protected]>' . "\r\n";
}
return $headers;
}
I would appreciate any advice.