Your WooCommerce order emails bridge the time between your customer leaving your store (after placing an order), and the customer receiving an order. As such, they’re an extension of the shopping experience for your customers, and provide the primary means for keeping a customer updated about the order’s status.

As such, many merchants want to ensure their WooCommerce emails accurately reflect the customer’s order, answer any questions customers may have after purchasing, and help to maintain a positive shopping experience overall.

One way you can ensure that order emails provide the details customers want is to add more item information. For example, our purchase receipt case study described how product photos and other information confirm for customers they ordered the exact items they meant to. While additional details like the product photo or SKU are not present in WooCommerce emails, we can add them.

Didn’t you write this already?

Indeed we did 🙂 The WooCommerce order items table has evolved a lot over the past few releases of WooCommerce.

Modifying the email order items prior to, and including, version 2.4 was fairly straight forward. You were able to filter the entire order items table HTML, and thus could just rebuild the items table with your own changes (such as changing the “show SKU” value to true).

However, WooCommerce 2.5 made this far more difficult because you no longer had access to all of the variables needed to re-build the order items table. Since you didn’t have the order object, you couldn’t easily change the order items display with the same filter while keeping other values correct. We had put together a workaround for version 2.5, but this wasn’t a great approach to solving the problem and didn’t always work depending on the email being sent.

WooCommerce 2.6 fixes the issue by adding a more useful filter — the woocommerce_email_order_items_args filter — to the order items table within emails, which we can use to make modifying your WooCommerce emails simpler.

Checking for Customer vs Admin WooCommerce Emails

This part is entirely optional. The woocommerce_email_order_items_args gives you access to a set of arguments ($args) that you can check or modify as needed.

Sometimes you want to modify only admin or customer-facing emails, so you can check the $args['sent_to_admin'] value to do so. To only change customer emails, bail out of this is set:

// only change customer emails
if ( $args['sent_to_admin'] ) {
    return $args; 
}

To only change admin emails, do the reverse:

// only change admin emails
if ( ! $args['sent_to_admin'] ) {
    return $args; 
}

Our last example in this tutorial will show a full snippet that only adds product images and SKUs to customer-facing emails.

Add SKUs to WooCommerce Emails

In order to show SKUs in your order emails, you’ll need to change the $args['show_sku'] value in the order items table. We can do so very easily:

/**
 * Adds SKUs and product images to WooCommerce order emails
 */
function sww_add_sku_to_wc_emails( $args ) {
  
    $args['show_sku'] = true;
    return $args;
}
add_filter( 'woocommerce_email_order_items_args', 'sww_add_sku_to_wc_emails' );

This will add SKUs right next to your product names in the order items display.

WooCommerce Emails: order email item SKUs displayed

SKUs added

Add Product Photos to WooCommerce Emails

In a similar fashion, we can change the $args['show_image'] to determine whether product images are shown in WooCommerce emails or not. We’ll set this to true to show a 32px product image in your emails.

/**
 * Adds product images to WooCommerce order emails
 */
function sww_add_photos_to_wc_emails( $args ) {
  
    $args['show_image'] = true;
    return $args;
}
add_filter( 'woocommerce_email_order_items_args', 'sww_add_photos_to_wc_emails' );
WooCommerce Emails: order email item photos displayed

Product Photos added

Change Product Photo size in WooCommerce Emails

Let’s put all of the tips above together, and add a last one. The product photo in the above example is kind of small — not really enough detail to satisfy most customers. We’ll make several modifications here:

  1. only change emails sent to customers, not admins
  2. add item SKUs
  3. add product images to the email
  4. modify the image size — we’ll use a 100px by 100px image instead

The last part can be done by modifying the $args['image_size'] value.

/**
 * Adds SKUs and product images to WooCommerce order emails
 */
function sww_modify_wc_order_emails( $args ) {
    
    // bail if this is sent to the admin
    if ( $args['sent_to_admin'] ) {
        return $args; 
    }
  
    $args['show_sku'] = true;
    $args['show_image'] = true;
    $args['image_size'] = array( 100, 100 );
 
    return $args;
}
add_filter( 'woocommerce_email_order_items_args', 'sww_modify_wc_order_emails' );

WooCommerce Emails: order email item photos and SKUs displayed

You’ll use an array() for the image size, setting the dimensions to new values: array( width, height )

Advanced Changes to WooCommerce Emails: For Developers

Finally, developers with a more complete understanding of PHP and WordPress can make some more advanced changes. If you want to conditionally make changes to WooCommerce emails, you’ll have access to the WC_Order object with this filter:

$args['order']

This could let you make checks on the order before changing the order items table display. You can also loop through the order’s line items as you have access to:

$args['items']

For example, if you only wanted to show purchase notes for completed orders (rather than for any paid order), you could do something like this:

$args['show_purchase_note'] = false;

if ( $args['order']->has_status( 'completed' ) && ! $args['sent_to_admin'] ) {
    $args['show_purchase_note'] = true;
}

Customizing WooCommerce Email Display

Making small improvements to WooCommerce emails is straightforward with some basic knowledge of PHP and WordPress hooks. Just be sure you know how to properly add code to your site to make changes like this, and always test on a staging site if you have one!


Note: This post may contain affiliate links, which means we get a commission from the plugin, theme, or service provider if you choose to purchase. Regardless of this, we are committed to providing high quality, unbiased resources. Have more questions? See our affiliate policy. You can use the plain links below if you prefer that we not receive a referral commission:
Articles you may also like:

Posted by Beka Rice

Beka Rice manages the direction of Sell with WP content and writes or edits most of our articles to share her interests in eCommerce. Or she just writes as an excuse to spend more time jamming out to anything from The Clash to Lady Gaga. Who knows.

9 Comments

  1. […] Want to start displaying SKUs in WooCommerce’s order and shipping emails? Here’s a tutorial that’ll come in handy. […]

    Reply

  2. What fine do i need to change to show the SKU in the admin order emails?

    Reply

  3. Hi Beka,

    Thanks for the article.

    Quick Question – I want to display sku and product image in the email sent to the customer, and have used your code below in the previous tutorial you posted on this subject:

    [ removed ]

    This works perfectly, but only the emails sent to admin display the required fields.

    I see that you have added a new snippet on how to get this to display on customer emails, but I am not too sure where to add this in? Could you please clarify this for me?

    Thank you so much in advance!

    Reply

    1. Hey there! This tutorial would completely replace the code from the old one, so it can be added to the same place, or I’d recommend giving this a read to determine the best place to add customizations.

      Reply

      1. Perfect, thanks so much!

        Reply

  4. Hi,

    I’ve tried this code and the other article you kindly wrote for 2.5. I am getting the same results as in the admin gets the pictures but the customer email still doesn’t. As you said there is something modifying the table afterwards but not sure what this is as of yet. Have you found anything that could be interfering with the process?

    Reply

  5. How do I change the “Shipping” text to something else in the order emails? For instance – “Shipping & Handling”. I can’t find locate this code anywhere in the woocommerce plugin.

    Reply

  6. Thanks for the great article. I have followed your code to add product images to email using a custom plugin. But instead of image i see only a text “product image”. On inspecting i can see tag without src attribute.

    Reply

Leave a reply

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