I am trying to add a BCC recipient to a specific type of mail sent by WooCommerce. This concerns the customers that receive a renewal mail. The type of the mail is ‘Completed Renewal Order’.
I am aware of this post: How to add BCC recipient to all emails sent by WooCommerce? which discusses adding a BCC to every mail sent by WooCommerce.
The solution for that problem was found as:
function add_bcc_all_emails( $headers, $object ) {
$headers = array(
$headers,
'Bcc: Me <[email protected]>' ."rn",
);
return $headers;
}
add_filter( 'woocommerce_email_headers', 'add_bcc_all_emails', 10, 2 );
I would like to edit this code, so we can add a BCC to the ‘Completed Renewal Orders’ only.
2
Answers
You can create a condition to send email only in a specific condition, so change your code to:
Use the following revisited code, to target Completed Renewal Order email notification, while adding a Bcc recipient:
Code goes in functions.php file of your child theme (or in a plugin). Tested and works.
Related: Target a specific email notification with the email id in WooCommerce