Send customer email when order is manually cancelled by admin
-
Currently, WooCommerce only sends cancellation emails to the store admin when an order is manually cancelled (status = cancelled), but not to the customer.
This is highly impractical in real-world B2C scenarios – especially when the order cannot be fulfilled (e.g. due to production limitations in 3D printing).
There should be an option to send a cancellation email to the customer as well.
Ideally, the email could include a custom reason and a refund confirmation.
Please add this feature to the core, or allow customer as an email recipient for cancelled orders.The page I need help with: [log in to see the link]
-
Hello @crusader445!
This is highly impractical in real-world B2C scenarios – especially when the order cannot be fulfilled (e.g. due to production limitations in 3D printing).
Yes, but in that case, you’d be issuing a refund for the customer, correct? In that case, the refund email will also serve as the cancellation email. 🙂
I’m not sure if the cancelled email contains information that you might not want to disclose to the customer, however, you can use this snippet to CC the customer to the same email sent to you:
https://www.businessbloomer.com/woocommerce-send-cancelled-order-email-to-customer/Hope this helps!
This code sends a customer email when the order is manually refunded.
add_action('woocommerce_order_refunded', function ($order_id, $refund_id) {
$order = wc_get_order($order_id);
if (!$order) {
return;
}
$to = $order->get_billing_email();
if (empty($to)) {
return;
}
$subject = 'Your order has been refunded';
$headers = ['Content-Type: text/html; charset=UTF-8'];
$message = '<p>Dear ' . esc_html($order->get_billing_first_name()) . ',</p>';
$message .= '<p>Your order #' . esc_html($order->get_order_number()) . ' has been refunded.</p>';
$message .= '<p>If you have any questions, feel free to contact us.</p>';
$message .= '<p>Thank you,<br>' . get_bloginfo('name') . '</p>';
wp_mail($to, $subject, $message, $headers);
}, 10, 2);Both code snippets are tested and work.
And this sends the customer an email when the order is manually cancelled.
add_action('woocommerce_order_status_cancelled', function ($order_id) {
$order = wc_get_order($order_id);
if (!$order) {
return;
}
$to = $order->get_billing_email();
if (empty($to)) {
return;
}
$subject = 'Your order has been cancelled';
$headers = ['Content-Type: text/html; charset=UTF-8'];
$message = '<p>Dear ' . esc_html($order->get_billing_first_name()) . ',</p>';
$message .= '<p>Your order #' . esc_html($order->get_order_number()) . ' has been cancelled.</p>';
$message .= '<p>If you have any questions, feel free to contact us.</p>';
$message .= '<p>Thank you,<br>' . get_bloginfo('name') . '</p>';
wp_mail($to, $subject, $message, $headers);
});Thank you for the helpful responses and especially for the code suggestions – I really appreciate the support!
However, I’d like to clarify a few points:
In my case, I don’t want to implement a custom-coded solution, as I believe this should be handled natively by WooCommerce. I’m looking for a built-in, non-technical option to send a cancellation email to the customer – ideally configurable via the WooCommerce email settings.
Also, I don’t issue refunds because the order hasn’t been accepted or processed yet. In my shop (e.g. custom 3D printing), I manually review every order before it is confirmed or charged (e.g. credit card authorization only).
If the model is not printable, I cancel the order before capturing any payment – so no refund email is triggered.Currently, WooCommerce only sends the cancellation email to the admin – which makes no sense in this workflow, as I’m the one triggering the cancellation. I don’t need the email – the customer does.
The current setup leaves the customer completely uninformed that the order was rejected, which is problematic in B2C contexts. It would be much more practical if WooCommerce allowed us to define the customer as the recipient for “Cancelled Order” emails in the settings, just like for “Order Completed” or “Order Failed”.
Also, relying on custom snippets adds maintenance risks – they might break with future WooCommerce updates or conflict with theme or plugin changes. That’s why I strongly prefer a native solution that works reliably across updates.
I hope this can be considered as a future improvement.
Thanks again for your time and help!-
This reply was modified 11 months ago by
Stefan.
You can do that as well by adding the customer email address to the cancelled order email and send it to the customer rather than the admin. This is tested and works :
// Disable admin cancellation email
add_filter('woocommerce_email_enabled_cancelled_order', '__return_false');
add_action('woocommerce_order_status_cancelled', function ($order_id) {
$order = wc_get_order($order_id);
if (!$order) {
return;
}
$to = $order->get_billing_email();
if (empty($to)) {
return;
}
$subject = sprintf('Order #%s has been cancelled', $order->get_order_number());
$headers = array('Content-Type: text/html; charset=UTF-8');
// Start building the email content
$message = '<div style="background-color: #f7f7f7; padding: 20px; font-family: Arial, sans-serif;">';
$message .= '<div style="background-color: #ffffff; padding: 20px; border-radius: 5px; box-shadow: 0 1px 3px rgba(0,0,0,0.1);">';
// Header
$message .= '<h1 style="color: #720eec; margin-bottom: 20px;">Order Cancelled</h1>';
// Order details
$message .= '<p>Dear ' . esc_html($order->get_billing_first_name()) . ',</p>';
$message .= '<p>Your order #' . esc_html($order->get_order_number()) . ' has been cancelled.</p>';
// Order items
$message .= '<h2 style="color: #720eec; margin: 20px 0;">Order Details</h2>';
$message .= '<table style="width: 100%; border-collapse: collapse; margin-bottom: 20px;">';
$message .= '<tr style="background-color: #f8f8f8;"><th style="padding: 10px; text-align: left;">Product</th><th style="padding: 10px; text-align: right;">Total</th></tr>';
foreach ($order->get_items() as $item) {
$message .= '<tr>';
$message .= '<td style="padding: 10px; border-bottom: 1px solid #eee;">' . esc_html($item->get_name()) . ' × ' . esc_html($item->get_quantity()) . '</td>';
$message .= '<td style="padding: 10px; border-bottom: 1px solid #eee; text-align: right;">' . wc_price($item->get_total()) . '</td>';
$message .= '</tr>';
}
// Order totals
$message .= '<tr><td colspan="2" style="padding: 10px;"></td></tr>';
$message .= '<tr><td style="padding: 10px; text-align: right;"><strong>Total:</strong></td>';
$message .= '<td style="padding: 10px; text-align: right;"><strong>' . wc_price($order->get_total()) . '</strong></td></tr>';
$message .= '</table>';
// Footer
$message .= '<p>If you have any questions, please contact us.</p>';
$message .= '<p>Thank you,<br>' . get_bloginfo('name') . '</p>';
$message .= '</div></div>';
wp_mail($to, $subject, $message, $headers);
});Hi @crusader445,
Thanks for sharing the details and for submitting the feature request. That’s the right path, and once it gathers enough votes, our developers will review it for future consideration.
Really appreciate you helping improve WooCommerce.
If you have a moment, we’d love a quick review: https://wordpress.org/support/plugin/woocommerce/reviews/#new-post
Thanks again!
-
This reply was modified 11 months ago by
The topic ‘Send customer email when order is manually cancelled by admin’ is closed to new replies.