The amazing thing about WooCommerce is that you can override any setting with a few lines of code. In today’s example we will try to code a solution where the “New Order” WooCommerce email will be delivered to a custom recipient based on the billing country.
This could be helpful when the WooCommerce store is managed by multiple people, and you want to make sure that order notifications only go to the right manager. Enjoy!
![](https://www.businessbloomer.com/wp-content/uploads/2023/08/woocommerce-change-email-recipient-based-on-country-1024x520.png)
PHP Snippet: Change WooCommerce “New Order” Email Recipient Based on Billing Country
/**
* @snippet Switch New Order Email Recipient Based on Billing Country
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 8
* @community https://businessbloomer.com/club/
*/
// PART 1
// Lets define the array of 'country code' => 'email' pairs
function bbloomer_location_admin( $location ) {
$admins = array(
'US' => 'usamanager@test.com',
'CA' => 'canadamanager@test.com',
// etc
);
return $admins[$location];
}
// PART 2
// Lets set the new order email recipient
add_filter( 'woocommerce_email_recipient_new_order', 'bbloomer_dynamic_recipient', 9999, 3 );
function bbloomer_dynamic_recipient( $email_recipient, $order_object, $email ) {
if ( is_admin() ) return $email_recipient;
if ( $order_object && $location = $order_object->get_billing_country() ) {
$email_recipient = bbloomer_location_admin( $location );
}
return $email_recipient;
}
Very useful.Thank you
Cool!
Here’s one scenario I’m trying to solve. We sell digital sheet music. Normally very simple: the customer buys and receives the download link to a dynamically created watermarked copy in an email immediately. But one German publisher wants to fulfil the order themselves. So now we’re in an Amazon situation – fulfilled by Amazon or fulfilled by publisher. We need to send a New Order email to the customer saying his order has been taken and will be fulfilled by the publisher (brand taxonomy)and one to the publisher containing the order details. I’m looking at this as adding a Conditional statement to the New Order email, which I also need to amend anyway because we only sell downloads, which would send the New Order to the Publisher as well as the Customer and Admin. Would that be possible?
Rob, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!