I am trying to send an email to the client when an order gets cancelled. By default, woocommerce only sends this email only to the admin of the site. This code has solved the issue for related posts on the web:
function wc_cancelled_order_add_customer_email( $recipient, $order ){
return $recipient . ',' . $order->billing_email;
}
add_filter( 'woocommerce_email_recipient_cancelled_order', 'wc_cancelled_order_add_customer_email', 10, 2 );
add_filter( 'woocommerce_email_recipient_failed_order', 'wc_cancelled_order_add_customer_email', 10, 2 );
However, it seems like woocommerce removed those filter hooks completely. Is there any way of doing this?
Thanks in advance!
In this custom function hooked in
woocommerce_order_status_changed
action hook, I am targeting "cancelled" and "failed" orders sending an the corresponding email notification to the customer (as admin will receive it on his side by WooCommerce automated notifications):Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
This should works in WooCommerce 3+
Related answer: Send an email notification when order status change from pending to cancelled