You can use a custom function hooked in woocommerce_email_recipient_{$this->id}
filter hook, targeting 'New Order' email notification, this way:
add_filter( 'woocommerce_email_recipient_new_order', 'diff_recipients_email_notifications', 10, 2 );
function diff_recipients_email_notifications( $recipient, $order ) {
if ( ! is_a( $order, 'WC_Order' ) ) return $recipient;
// Set HERE your email adresses
$email_zone1 = '[email protected]';
$email_zone_others = '[email protected]';
// Set here your targeted country code for Zone 1
$country_zone1 = 'GE'; // Germany country code here
// User Country (We get the billing country if shipping country is not available)
$user_country = $order->shipping_country;
if(empty($user_shipping_country))
$user_country = $order->billing_country;
// Conditionaly send additional email based on billing customer city
if ( $country_zone1 == $user_country )
$recipient = $email_zone1;
else
$recipient = $email_zone_others;
return $recipient;
}
For WooCommerce 3+, some new methods are required and available from WC_Order
class concerning billing country and shipping country: get_billing_country()
and get_shipping_country()
…
Usage with $order instance object:
$order->get_billing_country(); // instead of $order->billing_country;
$order->get_shipping_country(); // instead of $order->shipping_country;
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
Code is tested and works.
Related answers:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…