If you have a WooCommerce store where you have specific products that are fulfilled by different departments or people, and you don’t want everyone to receive all of the order notifications (because that can be a lot of emails!), there is a bit of code that you can customize and add to your theme’s functions.php.

What are the use cases for this in WooCommerce?

  • You have a few products that are fulfilled by a separate person or entity
  • You want someone to get an email whenever a specific product is sold
  • You want to customize who gets order emails depending on the product

However, there is an issue. This is specifically for if you only want to do this for a few products. If you have a large store, or want to do this for several departments or products, it may be better to do this with product categories.

Here is a modified version of the code from StackOverflow and other code I’ve used for WooCommerce (be sure to substitute YOURPRODUCTID and the email addresses with your own values):

add_filter( 'woocommerce_email_recipient_new_order', 'custom_email_recipient_new_order', 10, 2 );
function custom_email_recipient_new_order( $recipient, $order ) {
    // Not in backend when using $order (avoiding an error)
    if( ! is_a($order, 'WC_Order') ) return $recipient;

    // Loop through order items
    foreach ( $order->get_items() as $item ) {
        if ( $item['product_id'] == YOURPRODUCTID ) { // substitute YOURPRODUCTID with the product ID
            $recipient .= ', EM****@EM***.COM, EM****@EM***.COM'; // substitute these email addresses
        }
        // repeat the if statement above if you want to do this for more than one product
    }
    return $recipient;
}

When you use this code, the order emails will still get sent to the default recipients. I have not tried it, but if you wanted to overwrite sending to the default recipients, you could try removing the period after $recipient in the if statement and the first comma so the content in the if statement looks like below:

$recipient = 'EM****@EM***.COM, EM****@EM***.COM'; // substitute these email addresses

Once you’ve saved and/or uploaded the changes to your theme’s functions.php file, try a test order to be sure that it works!