Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want the admin to receive on hold order notification as well in WooCommerce. Right now, only customers get that notification.

I have tried the following codes but it doesn't seem to work.

Here is my code:

add_filter( 'woocommerce_email_headers', 'mycustom_headers_filter_function', 10, 2);
function mycustom_headers_filter_function( $headers, $object ) {
    if ($object == 'customer_on_hold_order') {
        $headers .= 'BCC: My name <my@email.com>' . "
";
    }
    return $headers;
}

What should be the correct filter/hook to use?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
572 views
Welcome To Ask or Share your Answers For Others

1 Answer

The correct $email_id for "on-hold" order status email notification is 'customer_on-hold_order'.

So your code is going to be:

add_filter( 'woocommerce_email_headers', 'custom_admin_email_notification', 10, 3);
function custom_admin_email_notification( $headers, $email_id, $order ) {

    if( 'customer_on-hold_order' == $email_id ){
        // Set HERE the Admin email
        $headers .= 'Bcc: My name <my@email.com>
';
    }
    return $headers;
}

Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

Code is tested and works.


Similar answers: How to get order ID in woocommerce_email_headers hook


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...