# Send New Order Emails to a Supplier by Category

> Adds an extra recipient to the "New order" email when the order contains products from a category, so suppliers or warehouse teams only get the orders they fulfil.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, email, dropshipping, categories
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-new-order-email-by-category/

## Code

```php
$wpide_category_recipients = array( // Category slug => email address.
    'furniture' => 'warehouse@example.com',
    'prints'    => 'printshop@example.com',
);

add_filter( 'woocommerce_email_recipient_new_order', function ( $recipient, $order ) use ( $wpide_category_recipients ) {
    if ( ! $order instanceof WC_Order ) {
        return $recipient;
    }

    $extra = array();

    foreach ( $order->get_items() as $item ) {
        foreach ( $wpide_category_recipients as $slug => $email ) {
            if ( has_term( $slug, 'product_cat', $item->get_product_id() ) && is_email( $email ) ) {
                $extra[] = $email;
            }
        }
    }

    return $extra ? implode( ',', array_unique( array_merge( array_filter( array_map( 'trim', explode( ',', (string) $recipient ) ) ), $extra ) ) ) : $recipient;
}, 10, 2 );
```

## Notes

Map category slugs to email addresses; the usual recipients still receive every new order email.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Send New Order Emails to a Supplier by Category" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
