Basically, in woocommerce you have the option to input multiple email addresses (separated by commas) of who to send the completed order to, in WooCommerce -> Settings -> Em
I had a bit of trouble with helgatheviking's answer above and also a slightly different use case. My problems/needs were:
public function get_recipient() inside of class-wc-email.php expected a string but was getting an array.Here's what I did instead:
woocommerce_email_recipient_new_orderexplode() and array_push() with string concatenation $email .= ',' . $additional_email;.if( $order->get_payment_method() == "cod" ).Full example:
add_filter( 'woocommerce_email_recipient_new_order' , 'so_26429482_add_recipient', 20, 2 );
function so_26429482_add_recipient( $email, $order ) {
// !empty($order) prevents a fatal error in WooCommerce Settings
// !empty($email) prevents the duplicate email from being sent in cases where the filter is run outside of when emails are normally sent. In my case, when using https://wordpress.org/plugins/woo-preview-emails/
if(!empty($order) && !empty($email)) {
$additional_email = "isf@domain.co";
if( $order->get_payment_method() == "cod" ) {
$email .= ',' . $additional_email;
} else {
$email .= ',another@domain.co';
}
}
return $email;
}