How can I add BCC or CC to the woo commerce, new order email?
I think this is the code that is running the new order emails: http://codepad.org/kPTpSIM0 I cant seem to find what I need on Google. Thank you in advance.
I found this but I do not know where it goes:
add_filter( 'woocommerce_email_headers', 'add_bcc_all_emails', 10, 2);
function add_bcc_all_emails($headers, $object) {
$headers = array();
$headers[] = 'Bcc: Name <[email protected]>';
$headers[] = 'Content-Type: text/html';
return $headers;
}
Well it looks like you have already read this answer as that is the recommended code, though I believe it will add the BCC on all emails and not just new orders.
Instead I would suggest the following:
add_filter( 'woocommerce_email_headers', 'add_bcc_all_emails', 10, 3);
function add_bcc_all_emails( $headers, $email_id, $order ) {
if( 'new_order' == $email_id ){
$headers .= "Bcc: Name <[email protected]>" . "\r\n";
}
return $headers;
}
As for "where the code goes", it should be made into a plugin. Depending on how easily you would like to be able to disable this code in the future you could write it as a regular plugin (disable from Plugins overview) or as a site-specific snippets plugin (permanent until you delete file via FTP).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With