Customizing WooCommerce emails isn’t something that’s terribly difficult assuming that you’re familiar with how the WordPress hook system works. And that you’re familiar with what hooks WooCommerce provides.

Customizing WooCommerce Emails

The former is pretty easy to find as there a solid reference and I, along other with others, have talked about it in-depth. Once you have that understanding, though, trying to track down all of the hooks for the latter is the challenge.

There are a few references I’ll share at the end of this post, as well as some various tips I recommend for customizing WooCommerce emails, but I always appreciate a practical example more than anything else so I’ll start with that first.

Customizing WooCommerce Emails

For this example, I’m just going to do something simple:

Add a line of text above the table of information that shows the customer’s purchase information.

Sounds straightforward, right? The challenge comes in finding the right hook, but I’ll cover that momentarily.

First, though, the code:

If you’re familiar with hooks and callbacks, it’s straightforward. Here’s what’s happening:

  1. I’m registering a custom callback, acme_email_message, that will add a single sentence above the table in a WooCommerce email.
  2. I’ve set a priority of 20 just to make sure it fires a little later in the process.
  3. I use wp_kses to make sure that the code is secure.
  4. I echo it to the caller (which is WooCommerce).

If you write this in a plugin you’re working on, you’ll see the email sentence “Access your additional information on your My Account page,” will appear above the table.

Easy enough!

But What About Other Hooks?

If you want to modify other places in a WooCommerce email, there are a number of resources I recommend. Some of them provide a good breakdown as to where to look for these hooks, others are simply reading through the source (which I always recommend).

In no particular order:

And I’m sure there are other references, but this is enough to get started.