WooCommerce: Bulk Re-Send All Customer’s Completed Order Emails

This is quite an uncommon WooCommerce requirement, but especially for downloadable products the Completed Order email is such as important one – and customers may end up asking you to resend them all their past order emails.

This is an interesting snippet, as it features important functionalities: getting orders by billing email, looping through the results and re-triggering the Completed Order email whenever a specific admin URL parameter is posted. Enjoy!

A customer requested to get all their Completed Order emails once again in their inbox. Maybe because they contain useful info, downloads, or they need to collect some data all together. Great – use their billing email address in any WordPress dashboard page, append it to the current URL with parameter ‘cust-email’, add the snippet below to your functions.php, and all emails will magically bulk trigger!

PHP Snippet: Trigger All Customer’s Past Order Emails @ WooCommerce Admin

While logged in as administrator and in the WordPress dashboard, add parameter “cust-email” with value = a customer’s billing email, hit enter, and the below snippet will trigger.

Example: test.com/wp-admin/post.php?post=232480&action=edit&[email protected]

 * @snippet       Re-Send All Customer's Completed Emails
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 7
 * @donate $9     https://businessbloomer.com/bloomer-armada/

add_action( 'admin_init', 'bbloomer_trigger_customer_order_emails_admin' );
function bbloomer_trigger_customer_order_emails_admin() {
   if ( isset( $_REQUEST['cust-email'] ) && ! empty( $_REQUEST['cust-email'] ) ) {
      if ( ! current_user_can( 'manage_woocommerce' ) ) {
         wp_die( 'You do not have permission to bulk edit products' );
      $email = sanitize_email( $_REQUEST['cust-email'] );
		if ( is_email( $email ) && email_exists( $email ) ) {
         global $wpdb;
			$result = $wpdb->get_col( $wpdb->prepare(
				"SELECT p.ID FROM {$wpdb->posts} AS p
				INNER JOIN {$wpdb->postmeta} AS pm ON p.ID = pm.post_id
				WHERE p.post_status = 'wc-completed'
				AND pm.meta_key = '_billing_email'
				AND pm.meta_value = %s",
			$result = array_map( 'absint', $result );
			if ( $result ) {
				foreach ( $result as $order_id ) {
					$order = wc_get_order( $order_id );
					WC()->mailer()->emails['WC_Email_Customer_Completed_Order']->trigger( $order_id, $order );

Where to add custom code?

You should place PHP snippets at the bottom of your child theme functions.php file and CSS at the bottom of its style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my guide "Should I Add Custom Code Via WP Editor, FTP or Code Snippets?" and my video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything went as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting.

If you think this code saved you time & money, feel free to join 17,000+ WooCommerce Weekly subscribers for blog post updates and 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance!

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

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.

Questions? Feedback? Support? Leave your Comment Now!

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. 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 BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

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