Nicola Mustone

Happiness Lead @ Automattic



Add Text to The Emails Body

A man with tools

In WooCommerce, with every order, comes one or more emails. WooCommerce sends automatically to the shop manager or to the customer, depending on the current step of the purchase process and they have some pre-defined messages.

These messages change based on the email sent and there are no options to change them. Sometimes you may need to add more text to all emails, such as a notice that says that the order is an online order. How do you do this?

Guess what? Custom code!

Before implementing any code changes, always ensure your site is backed up. This will help you restore things in case of unforeseen errors. I recommend using Jetpack Backup for real-time backups and one-click restores.

Open the file functions.php in wp-content/themes/your-child-theme-name/ and add this code at the end of the file:

<?php
add_action( 'woocommerce_email_header', 'add_email_header', 20 );
function add_email_header() {
echo '<h2>My Heading</h2>';
echo '<p>Add content here</p>';
}
view raw functions.php hosted with ❤ by GitHub

This will add the specified content right after the header section of the email but before any pre-defined content.

Advertisements

Subscribe to This Blog

Receive new articles from this blog directly in your inbox! No spam guaranteed!

Join 651 other subscribers

Contribute to Improving This Blog

Did you enjoy this article? Was it helpful? Contribute to help me write more articles! The funds collected from this blog are reinvested directly into improving my skills or the blog so that I can provide more and better content!

One-Time
Monthly
Yearly

Make a one-time donation

Make a monthly donation

Make a yearly donation

Choose an amount

€5.00
€15.00
€100.00
€5.00
€15.00
€100.00
€5.00
€15.00
€100.00

Or enter a custom amount


Your contribution is appreciated.

Your contribution is appreciated.

Your contribution is appreciated.

DonateDonate monthlyDonate yearly
Advertisements

More Posts That You Might Like…


5 responses to “Add Text to The Emails Body”

  1. Super thanks to you Nicola. Exactly what I was hunting for.

    1. You’re welcome Collins!

  2. That’s great idea! I’m wondering how to use it for one type of email only? I’d like to add some text in completed order email.

    1. Hi Herbatka,
      It would be easier to add your content in the actual content section of that email instead of the header, and you would do it by overriding the email template.

      You can read more about that here: https://docs.woocommerce.com/document/template-structure/

  3. […] Would you like to change also the content of your emails? Check out how to add text to the email body! […]

Leave a Reply

Advertisements

Categories

Newsletter

Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Join 651 other subscribers

About The Author

Hi, I’m Nico! Support Lead at Automattic, championing WordPress.com & WooCommerce. Off-duty, I’m at Elemental Beacon, leading epic D&D adventures. Let’s connect, whether it’s about WordPress or a quest!

Advertisements

Don't Miss a Thing!

Receive new articles from this blog directly in your inbox!

No spam guaranteed!

Join 651 other subscribers

Continue Reading

%d bloggers like this: