php - Different email heading based on shipping methods in Woocommerce
So I want to send the same email with a slightly different heading in WooCommerce. It uses the argument$email_heading
variable to hold the value of that current email heading so I figure a simple replacement would work. It doesn't. I could be completely missing the mark here any help is much appreciated.
I want it to say Your Order is ready for pickup when they choose local pickup and then the default value (stored the email settings of woocommerce) when any other shipping is chosen.
add_filter( "woocommerce_email_heading_customer_completed_order", 'HDM_woocommerce_email_header', 10, 2 );
function HDM_woocommerce_email_header( $email_heading, $email ) {
if ('customer_completed_order' == $email->id && $order->has_shipping_method('local_pickup') ){
$order_id = $order->get_id();
$email_heading = '<h1>Your Order Is Ready For Pickup</h1>';
}
return $email_heading;
};
Answer
Solution:
There are some mistakes in your code like
$email
that is in fact$order
. Also you are already targetingcustomer_completed_order
in this composite hook, so you don't need it in yourIF
statement…So try instead:
Code goes in function.php file of your active child theme (or active theme). Tested and works.
Answer
Solution:
i'm wondering if this is valid for email subject: