Woocommerce cancelled order e-mail notification for my clients
-
Hey,
I am looking for a function which change e-mail recipient of cancelled order. I would like to send automatically this e-mail to customer instead of admin.
Best,
Mat
-
These emails are for admin benefit to know that an order has been cancelled. Since cancellation is triggered by the user, they don’t really need one.
You could add your own custom email on the order status hooks outside of WooCommerce. e.g. custom code to listen for woocommerce_order_status_cancelled action then send mail.
Hey Mike, thank you for your response.
Unfortunatelly, I am using those notifications for customers because in my site orders will be cancelled by Shop Manager and that is why I would like to let customer know about this.
I will use this custom hook but can you please tell me if I can “call” random cancelled order template? (child theme / woocommerce / email / canceled-order.php ). I already adjust this page and it will be really nice if I will be able to use it.
Mat
Why not use a customer note instead? If you add one when you handle the cancellation, the user gets an email.
It’s because I would like to change order status also ??
You can do that as well, just takes two requests ?? Saves coding – if you need something built you’ll need to consider jobs.wordpress.net.
Ok, thank you very much ??
Greetings,
Mat
Mike Jolley: This is the third or fourth request that I’ve seen for this exact function (on WordPress and on StackOverflow). On the admin page, (https://yoursite.com/wp-admin/admin.php?page=wc-settings&tab=email§ion=wc_email_cancelled_order) right out of the box, “Customer” is on the email recipients list for an order cancelling. But then on the page that shows the settings for email (https://yoursite.com/wp-admin/admin.php?page=wc-settings&tab=email), customer is always removed. So “Customer” is saved on the back end but filtered out by the plugin authors choice. So it’s possible to do this by changing the filter for email recipient. A simple change if you are the author but complicated if you are one of the many WP users who is not a skilled PHP developer.
So in answer to the OP’s question, put this code in your site’s theme functions.php. It worked for me and I’m not even a plugin author.
/* * Add customer email to Cancelled Order recipient list */ 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 );
Hello pixelboy,
I added this code.But,no use.
Mail not send to customer…
You can try this plugin:
https://www.ads-software.com/support/plugin/woo-custom-emails/
Hi Guys, I worked on a solution for this.
Here in Brazil when an order is rejected by the payment gateway, Their plugin automatically cancel the order within the woo platform.
The customer is waiting for an email with the response of the process of his payment, so we must inform the status (canceled) When it happens.
And no. I cant do it 100 times on a day manually.
So here is the code:
Add it on your child theme, archive functions and have fun.
It would be so easier for add this functionality on the next versions of the platform.
/** * Adds the customer email on the receipient list for cancelled orders notifications. * */ function cancelled_order_add_customer_email($emails) { class My_WC_Email_Cancelled_Order extends WC_Email_Cancelled_Order { public function trigger($order_id) { $this->recipient .= (empty($this->recipient) ? '' : ',').wc_get_order($order_id)->billing_email; return parent::trigger($order_id); } } $emails['WC_Email_Cancelled_Order'] = new My_WC_Email_Cancelled_Order(); return $emails; } add_filter('woocommerce_email_classes', 'cancelled_order_add_customer_email', 10);
Hi Mike,
You said: “These emails are for admin benefit to know that an order has been cancelled. Since cancellation is triggered by the user, they don’t really need one.”
By that logic, the admin doesn’t really need an email when he cancels an order, yet that email is sent. After the admin cancels an order, the Notes section indicates:
“Cancelled order email notification manually sent.” Sadly, that really means it was only sent to the admin… the admin who just canceled it.In another thread (slightly different topic*) you said: “If unpaid, the user may cancel and restore the cart from the My Account page. Once its paid for, an admin needs to handle it.”
Conclusion: Since either the customer or the admin can cancel an order, BOTH should receive a confirmation email when an order is canceled.
I realize this is somewhat subjective, so I guess it’s not a bug. But, I’ll look forward to the improvement in a future release. Thanks in advance!
nancorrea, thanks for the code. It looks good. I’ll probably give it a try if woo decides not to make the change.
* https://ideas.woothemes.com/forums/133476-woocommerce/suggestions/2310400-edit-or-cancel-order
Hi guys,
Attaching a plugin which works great with emails and have an option to customize custom email templates for WooCommerce..
Plugin will be updated today with automatic “order canceled” email action as well.https://codecanyon.net/item/woocommerce-email-customizer-pro/18831495
Any question , problems or suggestion with this plugin you can contact to [email protected]
Thanks..
@nancorrea does your script work with woocommerce 2.4.10? I dried it but nothing happend.
- The topic ‘Woocommerce cancelled order e-mail notification for my clients’ is closed to new replies.