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&cust-email=info@businessbloomer.com

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

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 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

  • WooCommerce: Add Second Description @ Product Category Pages
    In terms of SEO, if you’re trying to rank your product category pages, you really need to make the most of the default WooCommerce product category “description” and “thumbnail”. Most themes, if compatible with WooCommerce, will show this content right below the product category name and above products. Nothing new so far. But what if […]
  • WooCommerce: Add Content to a Specific Order Email
    Customizing WooCommerce emails via the WordPress dashboard is not easy and – sometimes – not possible. For example, you can’t edit or add content to them unless you’re familiar with code. Well, here’s a quick example to learn how to add content to any WooCommerce default order email. In this case study, our goal is […]
  • WooCommerce: How to Add a Custom Checkout Field
    Let’s imagine you want to add a custom checkout field (and not an additional billing or shipping field) on the WooCommerce Checkout page. For example, it might be a customer licence number – this has got nothing to do with billing and nothing to do with shipping. Ideally, this custom field could show above the […]
  • WooCommerce: Get Order Data (total, items, etc) From $order Object
    As a WooCommerce development freelancer, every day I repeat many coding operations that make me waste time. One of them is: “How to get ____ if I have the $order variable/object?“. For example, “How can I get the order total“? Or “How can I get the order items“? Or maybe the order dates, customer ID, […]
  • WooCommerce Visual Hook Guide: Emails
    WooCommerce customizers: the Visual Hook Guide is back! Here’s a visual HTML hook guide for the WooCommerce Emails. This visual guide belongs to my “Visual Hook Guide Series“, that I’ve put together so that you can find WooCommerce hooks quickly and easily by seeing their actual locations. Let me know in the comments if this […]

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

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 *