The following script is adding an extra email recipient when product id 9515 is bought. So WooCommerce sends 2 emails, 1 to default recipient and 1 to second @gmail.com.
What I need is to change this script to ONLY send to second @[login to view URL], so the default recipient does NOT receive any email.
I just want the changed code, no site access is necessary, you will work it locally.
--
add_filter( 'woocommerce_email_recipient_new_order', 'conditional_recipient_new_email_notification2', 15, 2 );
function conditional_recipient_new_email_notification2( $recipient, $order ) {
if( is_admin() ) return $recipient; // (Mandatory to avoid backend errors)
$targeted_id = 9515; // HERE define your targeted product ID
$addr_email = 'second @[login to view URL]'; // Here the additional recipient
// Loop through orders items
foreach ($order->get_items() as $item_id => $item ) {
if( $item->get_variation_id() == $targeted_id || $item->get_product_id() == $targeted_id ){
$recipient .= ', ' . $addr_email;
break; // Found and added - We stop the loop
}
}
return $recipient;
}
Hi,
Change:
$recipient .= ', ' . $addr_email;
To:
$recipient = $addr_email;
It's nice if you accept my proposal. (even though I already solved your problem)
Hello,
Good day. I have read your requirement. you want to send another mail for specific product id. I can able to fix this bug. Please hire me
Thanks
Mahmudul Hasan
Hi,
PHP, WordPress
You may review my profile for previous project and review rating as well.
https://www.freelancer.com/u/Rinkup0
Please send me message on chat. So we both can discuss on this.
Regards,
Rinku P.