I am trying to either disable or change the subject line on the woocommerce confirmation email that goes to admins.
I want to do this for only one specific product category.
Any help is appreciated.
I am trying to either disable or change the subject line on the woocommerce confirmation email that goes to admins.
I want to do this for only one specific product category.
Any help is appreciated.
Update (related to your comment).
Using a custom function hooked in woocommerce_email_subject_new_order
filter hook will allow you to change the subject for "New Order" admin email notification, for a specific product category.
You will have to define in the code below the targeted product category and the custom subject:
add_filter( 'woocommerce_email_subject_new_order', 'custom_subject_for_new_order', 10, 2 );
function custom_subject_for_new_order( $subject, $order ) {
$found = $others = false;
// HERE define your product categories in the array (can be IDs Slugs or Names)
$categories = array('clothing'); // coma separated for multiples categories
// HERE define your custom subject for those defined product categories
$custom_subject = __("My custom subject goes here", "woocommerce");
// Loop through order items
foreach( $order->get_items() as $item ){
if( has_term( $categories, 'product_cat', $item->get_product_id() ) && $found )
$found = true; // Category is found
else
$others = true; // Other Categories are found
}
// Return the custom subject when targeted product category is found but not others.
return $found && ! $others ? $custom_subject : $subject;
}
Code goes in function.php file of the active child theme (or active theme).
Tested and works.