I want to send admin new order e-mail to cc, if order has items from a parent product category:
I am using the code below but this doesn't seem to work. The mail is being sent but I receive a notification for an undefined variable. The person in CC does not receive the message either
add_filter( 'woocommerce_email_headers', 'bbloomer_order_completed_email_add_cc_bcc', 9999, 3 );
function bbloomer_order_completed_email_add_cc_bcc( $headers, $email_id, $order ) {
$order = wc_get_order( $order_id ); // The WC_Order object
if ( 'new_order' == $email_id && $orderid['product_cat']== 69) {
$headers .= "Cc: Name <[email protected]>" . "\r\n"; // del if not needed
}
return $headers;
}
Someone who wants to take a closer look at this?
wc_get_order()
is not necessary, you can already access the$order
object via the parameters$orderid['product_cat']
does not existSo you could use