Using Advanced Custom Fields plugin, I have created a custom field in the WordPress options tab that allows my client to add an additional email which will receive Woocommerce new order email confirmation, as well as themselves.
The function below is working if i hardcode the email address. Although i want the additional email recipient to pull from the ACF options which the client can add/change etc. The email is pulling through correctly from options ACF. Although when i try to concatenate the email to the BCC the new email doesn't receive the new order email.
Can anyone point out where im going wrong with this please? Thanks
add_filter( 'woocommerce_email_headers', 'mycustom_headers_filter_function', 10, 2);
function mycustom_headers_filter_function( $headers, $object) {
$additional_order_email_recipient = get_field('manufacturer_email_recipient', 'options');
$manu_email = "<".$additional_order_email_recipient.">";
$email_header = "BCC: Manufacture " . $manu_email . "\r\n";
if ($object == 'new_order') {
$headers .= "BCC: New Order <[email protected]>" . "\r\n"; // This Works
$headers .= "BCC: New Order " . $manu_email . "\r\n"; // This doesnt work
$headers .= $email_header; // This doesnt work
}
return $headers;
}