WooCommerce: Resend Any Order Email

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!

How poor from WooCommerce that you can’t resend a “completed” email notification (for example) from the Order actions! Let’s change that with a simple customization!

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:

  1. Add one more line to bbloomer_resend_processing_email_action() e.g. $actions[‘resend_completed’] = ‘Resend completed email’;
  2. Create a custom order action listener based on previous point e.g. add_action( ‘woocommerce_order_action_resend_completed’, etc.
  3. Declare your custom function: instead of bbloomer_resend_processing_email_trigger() use e.g. bbloomer_resend_completed_email_trigger()
  4. 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

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

12 thoughts on “WooCommerce: Resend Any Order Email

  1. Trying to create a RESEND NEW CUSTOMER EMAIL feature. But can’t get it — what am I doing wrong?

    Thanks for any assistance.

    add_filter( 'woocommerce_order_actions', 'bbloomer_resend_new_customer_email_action', 9999, 2 );
     
    function bbloomer_resend_new_customer_email_action( $actions, $order ) {
       if ( $order->has_status( wc_get_is_paid_statuses() ) ) { 
          $actions['resend_new'] = 'Resend New Customer Email';
       }
       return $actions;
    }
     
    add_action( 'woocommerce_order_action_resend_new_customer', 'bbloomer_resend_new_customer_email_trigger' );
      
    function bbloomer_resend_new_customer_email_trigger( $order ) {
       WC()->mailer()->emails['WC_Email_Customer_New_Account']->trigger( $order->get_id(), $order, true );
    }
    
    1. ‘woocommerce_order_action_resend_new_customer’ should be ‘woocommerce_order_action_resend_new’

  2. Just want to say thanks for this. Very much appreciated!

  3. Hi
    how can we add resend order completed emails to this code.
    Thanks

    1. Good point, thank you. I’ve added more info to the tutorial now – let me know!

  4. Hi,
    Thanks !
    Why don’t you add on hold action ?

    function bbloomer_resend_processing_email_action( $actions, $order ) {
       if ( $order->has_status( wc_get_is_paid_statuses() ) ) {   
          $actions['resend_processing'] = 'Resend processing email';
       }
    if ($order->has_status( 'on-hold' )) {
    	$actions['resend_on_hold_email'] = 'Resend on hold email';
       }
       return $actions;
    }
    
    add_action( 'woocommerce_order_action_resend_on_hold_email', 'am_resend_processing_email_trigger');
    
    function am_resend_processing_email_trigger( $order ) {
        WC()->mailer()->emails['WC_Email_Customer_On_Hold_Order']->trigger( $order->get_id(), $order, true );
    }
    
    
  5. 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

    1. 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!

  6. You don’t need a comment section to posts because you never reply to any of them.

    1. Wow, thank you for your honest feedback

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *