In Woocommerce, I would like to have a new order email sent to specific persons based on the selected shipping method ID.
Right now, I am only able to have every email address added to the new order email, but ultimately want to have the email be sent to one specific email based on the shipping method Id selected by the customer.
Here is my code coming from this answer that works for postal code:
add_filter( 'new_order' , 'so_26429482_add_recipient', 20, 2 );
function so_26429482_add_recipient( $email, $order ) {
$additional_email = "somebody@somewhere.net";
if( $order->shipping_postcode == "90210" ){
$email = explode( ',', $email );
array_push( $email, $additional_email );
}
return $email;
}
Instead I should need to target the shipping method Id.
My two shipping methods Ids are flat_rate:8
and flat_rate:9
.
Does anyone know how to do this?