How to get the $recipient (recipient) of Woocommerce emails

Asked

Viewed 58 times

1

I’m trying to get the email from the recipient of Woocommerce emails that go to Admin. I know there are other ways to do this but I need it to be by comparing the recipient to Admim WP.

////////// BCC EMAIL /////////////
function bcc_email_headers( $headers ){
   $recipient = get_from_address();
   $admin = get_option('admin_email');

    if ( $recipient == $admin ){
        $headers .= 'BCC: Name <[email protected]>' . "\r\n";
    }
    return $headers;
}
add_action( 'woocommerce_email_headers', 'bcc_email_headers', 10, 3 );

Or another way that suits me, would be through the order_status. I tried that:

////////// BCC EMAIL by Order Status /////////////
function bcc_email_headers( $headers, $order ){
   global $woocommerce;

    if ( wc_get_order() == 'meu_status' ){
        $headers .= 'BCC: Name <[email protected]>' . "\r\n";
    }
    return $headers;
}
add_action( 'woocommerce_email_headers', 'bcc_email_headers', 10, 3 );

But it doesn’t work either

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.