I want to send different order email to different recipients:
- If the shipping country is Israel the it email recipient should be abc@example.com
- If it is France, Spain, Italy, etc, the recipient should be def@example.com and ghi@example.com
- Otherwise it should be jkl@example.com
In WooCommerce > includes > emails > class-wc-email-new-order.php file, line no. 110 @version 2.0.0, I have changed the following code:
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
With this code:
if ($this->object->shipping_country == 'IL') {
$this->send( 'abc@example.com', $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
} elseif( $this->object->shipping_country == 'FR' || $this->object->shipping_country == 'BE' || $this->object->shipping_country == 'LU' || $this->object->shipping_country == 'NL' || $this->object->shipping_country == 'IT' || $this->object->shipping_country == 'PT' || $this->object->shipping_country == 'ESP' ) {
$this->send( 'def@example.com, ghi@example.com', $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
} else {
$this->send( 'jkl@example.com', $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
}
it worked, but I don't want to make changes in plugin's core file. How can I do that using hooks?
Also when the shipping country field is blank, the billing country should be used instead.