0

I am trying to add a CC email specifically for a custom created WooCommerce status. But I can't figure out what email-id to use to attach the line that would know to send on that custom status.

I tried making a whole new email ID instead, using the code from this answer, but without success.

Any help is appreciated.

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
dyz
  • 31
  • 4

1 Answers1

0

The linked related code that you are using, still works perfectly in WooCommerce 7.8+, without throwing any errors...

As the custom order status uses WC_Email_Customer_Processing_Order email type, the required email ID will be customer_processing_order.

The code below will allow adding a CC email for "Shipped" custom order status email notification:

add_filter( 'woocommerce_email_headers', 'custom_cc_email_headers_shipped_order', 10, 3 );
function custom_cc_email_headers_shipped_order( $header, $email_id, $order ) {
    // Only for "Customer Processing Order" email and "Shipped" order status
    if( 'customer_processing_order' === $email_id && $order->has_status( 'shipped' ) ) {
        $email = 'some.user@gmail.com'; // Her set the email address

        // Add email address as Cc to headers
        $header .= 'Cc: '.$email .'\r\n';
    }
    return $header;
}

Code goes in functions.php file of your active child theme (or active theme). Tested and works.

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
  • I managed to fix the critical error, it was because I had an email template from a plugin. But after disabling my plugins, I am still unable to get my email CC'd into the shipped email. – dyz Jun 20 '23 at 15:49
  • For me, it works perfectly. You may have somewhere, something else that is making trouble. – LoicTheAztec Jun 20 '23 at 16:12