How to Configure Email Notifications for Cancelled Orders in WooCommerce

If you are someone who operates a WooCommerce-powered online store, you may need to cancel orders from time to time for a variety of reasons. When you cancel an order, it is critical to notify the customer and provide a reason for the cancellation. Unfortunately, WooCommerce sends the order cancellation email to the WooCommerce admin rather than the customer. In this tutorial, we will walk through the process of delivering Customize Cancel Order Notification Emails.
Configure Email Notifications for Cancelled Orders in WooCommerce – Methods
There are two main methods to configure email notifications for cancelled orders in WooCommerce.
- WooCommerce Order Cancellation Email to Customer by KoalaApps
- Configure Email Notifications for Cancelled Orders in WooCommerce Programmatically
Method #1: WooCommerce Order Cancellation Email to Customer by KoalaApps
In WooCommerce, an order cancellation email is an email sent to the customer when they cancel their order. This email is sent by the admin, who has configured WooCommerce to automatically send an order cancellation email when a customer cancels a purchase. The customer will be the recipient of this email, which will include their particular email address. When this email is sent, it will include details about their canceled purchase, such as the products ordered and any refunds or credits that were applied. This sort of communication keeps customers updated on the status of their orders in a Woocommerce store.
Installation
- Download the .zip file available in your WooCommerce account.
- Go to WordPress Admin > Plugins > Add New and upload the file you downloaded, using Choose File.
- Install and activate the plugin now.
Setup and Configuration
After activating the WooCommerce plugin, you can enable and customize order cancellation email.
Email Settings
Go to WooCommerce > Settings > Email and select the order cancellation email to customer option. This plugin supports the following customization options:
- Email subject
- Email heading
- Extra text to be added in email
Method #2: Configure Email Notifications for Cancelled Orders in WooCommerce Programmatically
Below is the program-based implementation to configure email notifications for cancelled orders in WooCommerce. Implementing this program will help you achieve the desired results.
public function trigger( $order_id, $order = false ) {
$this->setup_locale();
if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
$order = wc_get_order( $order_id );
}
if ( is_a( $order, 'WC_Order' ) ) {
$this->object = $order;
$this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() );
$this->placeholders['{order_number}'] = $this->object->get_order_number();
$this->placeholders['{order_billing_full_name}'] = $this->object->get_formatted_billing_full_name();
$this->recipient = $this->object->get_billing_email();
}
if ( $this->is_enabled() && $this->get_recipient() ) {
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
}
$this->restore_locale();
}
Wrapping Up
You can provide a better customer experience by notifying them of canceled orders and providing them with the details for the order cancellation using the simple steps discussed above. If you need help understanding it further, do let us know in the comments below.
Leave a Reply