How to send custom emails to your WooCommerce customers

In this article we are going to look into the different ways of using WooCommerce to send custom emails to your customers. We are going to see different approaches to send emails depending on different criteria, such as the customer data or the products bought. We are also going to learn how you can bulk send custom email to your WooCommerce customers.

Customization is key for a good user experience. Therefore, sending custom emails to WooCommerce customers is a great idea. But actually implementing these customizations may be hard. That’s why today we’ll compile different methods and help you with some code snippets.

There are many options for sending customized emails. You can use the default WooCommerce options, custom PHP code or additional tools. We’ll walk you through them and we’ll see the advantages and limitations of each approach.

Here are the main topics for today:

  • How to customize emails from the WooCommerce dashboard
  • Overview of all options in WooCommerce to send custom emails
  • Customizing the email subject
  • Customizing the email content based on order value
  • Customizing the email content based on the products ordered
  • Bulk email all customers who bought a product

Let’s get right into it!

woocommerce send custom email

How to customize emails from the WooCommerce dashboard

WooCommerce allows you to tweak and customize each of the email templates they have. In order to do that, you just need to copy the template file to your theme. You can access all emails that are sent under WooCommerce > Settings > Email section:

WooCommerce send custom email to customers

If you click on any of these emails, you should see which file you need to copy in order to customize it. For example, if we click the “Order on-hold”, which is the first email a customer gets, you’ll see this:

Custom email template for woocommerce

You can click on the “Copy file to theme” button to automatically copy the file in your theme’s folder. From there you can either use the same screen to edit your email template (just click “View template file”).

This allows you to quickly swap the content for that file. But you can also use a bit of PHP code in case you want to customize the messages.

 

Overview of all options in WooCommerce to send custom emails

When it comes to WooCommerce there are many hooks that you can use for customization. Hooks are the way WordPress uses to allow external code to be run without modifying the original file.

But customizing emails is a multi-step part. That’s because each part of the email is better modified by a different hook. So, in this example we are going to change the email subject and the content separately. You can also add your own email warnings based on certain hooks.

Most of the main email actions have a hook that you can use for customizations. Here are some examples:

  • For each of the order status there’s a subject hook – so you can customize the email subject for cancelled, completed, on hold, processing orders
  • In your email’s content there are different hooks that you can use – there are hooks for the order table, customer details, items quantity, email footer and others that you can use to add new content in your email
  • For each user action there’s a hook – therefore you can customize the emails sent on password reset, when a new account is created and so on

Let’s see some examples of how you can use these hooks.

 

Customizing the email subject

The first and easiest aspect to customize in your email is the subject. The subjects can be changed with hooks such as:

  • woocommerce_email_subject_customer_completed_order
  • woocommerce_email_subject_customer_invoice
  • woocommerce_email_subject_customer_invoice_paid
  • woocommerce_email_subject_customer_refunded_order

These hooks have 2 arguments, the message subject and the order object. The subject is a simple string, that is what is going to be sent to your customer. The order object is the current order that is generating this email.

Let’s say that you want to add some nice words to your customer in the subject, along with their name. You can do that by getting the customer data from the order object. Just add this code to your functions.php (in a theme or child theme) and let’s see the magic happening:

This code is composed of a few components:

  • create a custom filter function that will be applied to the subject for completed orders
  • load the name of the site, so we can use it in the subject
  • create a custom emails subject in the format: “Ben’s Bookstore Order #123 – You are a star, Jane Smith”

You can spice up this code by adding other customer information or order information. You can even add multiple random compliments (here we just say “you are a star”).

 

Customizing the email content based on order value

In the next example we are going to show you can add custom text to your new order email. Since the entire order data is at your disposal you can send custom emails to your WooCommerce customers based on their order data. Here we’ll use the order’s total value as a customization condition. In addition, any of the order’s data can be used.

The following code snippet adds a premium offer in the order email when the customer has spent more than $100 on this order. This could be any value and could be any message you want. You could use it if the value is in a certain range if it’s bigger than a certain amount or if it’s lower than a value.

This code has a few differences form what we did before. Now instead of modifying the content we’re adding some extra content. So in this case we’ll use an action hook, instead of a filter. Also, in this case we don’t have hooks for the content for each email type, but we still can find out which one we’ve got.

Here are the main parts of that snippet:

  • Hook a function that will be executed on the order details part of the email
  • Get the total amount and status of the order
  • Add a premium offer if the order is completed and its total amount is $100 or more

 

Customizing the email content based on the products ordered

In addition, we can check other order details, such as the products bought for a further customization. You can customize the email based on the number of products bought, product categories, variations and more. In our example we’ll check if the order has one of the VIP products, and if it does, we’ll invite the user to join our premium group.

Here is what this snippet does:

  • $prod_arr = array( 21, 37, 85 );  creates an array containing the IDs of our VIP products. Here you can set the IDs of our own products that you want to check against
  • loop through each product in the order to see if it is one of the VIP products. If it is, add our special offer to the email just by printing the custom message.

It’s also possible to customize your WooCommerce customer emails on different criteria. You can follow the tips from other articles, such as the guide we have for adding custom user fields to the registration form. Then you can add these conditions in your functions or email template. In this case you could also use data, such as your customers’ city, job title, zip code and others.

 

Bulk email all customers who bought a product

Indeed, using the WooCommerce hooks is a great way of customizing your customer emails. But the limitation of this approach is that you can only customize events that will happen. You can’t send emails at will to your customers.

For that we’ll need a different approach – we’ll use Users Insights in combination with MailChimp or similar tool for sending bulk emails.

First, we need to select and export our users. In this step, make sure that the fields you want to use in your custom emails are visible. For example, we’ll use the customer name, email, and their job title. We’ll also only filter customers who have bought a certain product and send them a special offer.

Customers who bought a product

Then we’ll export this selection by clicking the export button:

Export customers who bought a product

You can save this filter for later use using the Segments feature. Just click the segments button and you can use this selection any time you want.

Customer segments

Now you just need to import the CSV file into MailChimp. Make sure you have the custom fields you want created there so you can map them when importing. This can be done under Lists > Select a list > Settings > List Fields.

MailChimp Custom Fields

Then you can run your import under Add Contacts > Import Subscribers > CSV file.

For more details on how to import your exported user data, you can also refer to our MailChimp and Campaign Monitor user import articles.

 

Conclusion

Today we looked into the different ways to send custom emails to your WooCommerce customers. We saw different approaches, including modifying the default WooCommerce templates and using the custom email actions. We also learned how to bulk send custom emails to your WooCommerce customers based on the products that they have purchased.

By the end of the day you should be able to customize your emails in any way you like. You can add your own criteria and increase your results by a better customer communication.

We hope you enjoyed it, and see you again next time!