I using Woocommerce and actually I receive order notifications only to one email. I would like to receive notifications about orders in 2 different emails depending on customer location:
- For customer from zone 1 (Germany) I would like to receive the email notifications at
Mail #1 (mail1@mail.com)
, - For all other zones like zone 2 (Mexico) I would like to receive the email notifications at
Mail #2 (mail2@mail.com)
.
I looking for some functions on net, but I was find only funtcions to send to two email adresses, but without any If condition.
What I will need is something like that:
if ($user->city == 'Germany') $email->send('mail1@mail.com')
else $email->send('mail2@mail.com')
Which hook can I use to get this working?
Thanks.
You can use a custom function hooked in
woocommerce_email_recipient_{$this->id}
filter hook, targeting 'New Order' email notification, this way: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: