How annoying is the fact you can only resend the “New Order Notification” from the single order admin page? What if you’re testing out and customizing email templates, and need to email yourself the “processing” or the “completed” notification, without having to place a new test order or switching order status twice to re-trigger the notification?
Well, today we will see how to add a “Resend whatever email” function under the “order actions” on the single order edit page. Of course, make sure you switch the billing email to yours, otherwise the customer will get these emails and not you. Enjoy!
PHP Snippet: Allow Administrator to Resend Any Order Email
In this case, I’ve targeted the “customer processing” email. In order to do that, I’ve created a custom Order action (please note the custom ‘resend_processing‘ order action ID, because that’s used later in the trigger ‘woocommerce_order_action_resend_processing‘, so if you change that you also need to change the ‘woocommerce_order_action_{action}” hook name).
Also, you’ll need to call the correct email class, in my case: WC_Email_Customer_Processing_Order. See notes after the snippet to target other emails.
/**
* @snippet Resend Processing Email @ WooCommerce Order Admin
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 8
* @community https://businessbloomer.com/club/
*/
add_filter( 'woocommerce_order_actions', 'bbloomer_resend_processing_email_action', 9999, 2 );
function bbloomer_resend_processing_email_action( $actions, $order ) {
if ( $order->has_status( wc_get_is_paid_statuses() ) ) {
$actions['resend_processing'] = 'Resend processing email';
}
return $actions;
}
add_action( 'woocommerce_order_action_resend_processing', 'bbloomer_resend_processing_email_trigger' );
function bbloomer_resend_processing_email_trigger( $order ) {
WC()->mailer()->emails['WC_Email_Customer_Processing_Order']->trigger( $order->get_id(), $order, true );
}
If you want to target other emails:
- Add one more line to bbloomer_resend_processing_email_action() e.g. $actions[‘resend_completed’] = ‘Resend completed email’;
- Create a custom order action listener based on previous point e.g. add_action( ‘woocommerce_order_action_resend_completed’, etc.
- Declare your custom function: instead of bbloomer_resend_processing_email_trigger() use e.g. bbloomer_resend_completed_email_trigger()
- Inside the function, call the relevant class (in our case: ‘WC_Email_Customer_Completed_Order‘)
Example:
/**
* @snippet Resend Completed Email @ WooCommerce Order Admin
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 8
* @community https://businessbloomer.com/club/
*/
add_filter( 'woocommerce_order_actions', 'bbloomer_resend_completed_email_action', 9999, 2 );
function bbloomer_resend_completed_email_action( $actions, $order ) {
if ( $order->has_status( wc_get_is_paid_statuses() ) ) {
$actions['resend_completed'] = 'Resend completed email';
}
return $actions;
}
add_action( 'woocommerce_order_action_resend_completed', 'bbloomer_resend_completed_email_trigger' );
function bbloomer_resend_completed_email_trigger( $order ) {
WC()->mailer()->emails['WC_Email_Customer_Completed_Order']->trigger( $order->get_id(), $order, true );
}
Here’s the list of default WooCommerce email classes:
- WC_Email_Cancelled_Order
- WC_Email_Customer_Completed_Order
- WC_Email_Customer_Invoice
- WC_Email_Customer_New_Account
- WC_Email_Customer_Note
- WC_Email_Customer_On_Hold_Order
- WC_Email_Customer_Processing_Order
- WC_Email_Customer_Refunded_Order
- WC_Email_Customer_Reset_Password
- WC_Email_Failed_Order
- WC_Email_New_Order
Trying to create a RESEND NEW CUSTOMER EMAIL feature. But can’t get it — what am I doing wrong?
Thanks for any assistance.
‘woocommerce_order_action_resend_new_customer’ should be ‘woocommerce_order_action_resend_new’
Just want to say thanks for this. Very much appreciated!
Thank you!
Hi
how can we add resend order completed emails to this code.
Thanks
Good point, thank you. I’ve added more info to the tutorial now – let me know!
Hi,
Thanks !
Why don’t you add on hold action ?
Cool, thanks for that!
Hello
can you add a text with a link to the customer’s email to quickly reply to the order email? I tried to add links in the admin-new-order.php template but I can’t get the recipient to appear in the email windowβ¦ the field is empty
Hello Micol, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
You don’t need a comment section to posts because you never reply to any of them.
Wow, thank you for your honest feedback