How do I enable WooCommerce to fire additional emails?

Tips and tricks from Tamara Olson Designs

Use case: You want to send an email to a factory or a third person besides the two emails (customer and admin) that are generated through WooCommerce.

Luckily, the wonderful people at SkyVerge have done a great job getting us started with this tutorial.

In this tutorial, we create a separate email that fires when shipping is expedited. For us, however, there were a few things we wanted to change:

1. Not have the email fire only for expedited orders, but fire on all orders.

2. Use a separate email template for the factory email because we need to have things like the SKU.

For the first change, it required deleting these two lines from the SkyVerge tutorial plugin:

This will cause the email to fire on all accounts.

For the second, the templates used are defined here:

 

We were focused on the HTML template, as we were adding PHP to the template to grab the SKU. A light bulb moment made us realize that if defined like this:

WooCommerce will search for the email template in its own plugin directory then default to a file in the theme inside: woocommerce/emails/factory-new-order.php

We copied the admin-new-order.php file and renamed it “factory-new-order.php” We deleted the body and all table layout in the email. To grab the SKU, loop through each item:

With the product and order variables, we could grab the attributes or anything else we needed.

Happy coding!


Share Your Thoughts

About the Author

ScottAuthor

Scott Stewart prides himself on pixel perfect development. He has developed websites for small businesses, writers, artists, and corporations. He utilizes the flexibility of WordPress to craft beautiful and elegant websites. He received his BA from the University of Oregon and his Masters of Fine Arts from San Diego State University. He hails from a small town in Oregon, but now lives in San Diego, CA.

Tamara Olson Designs Case Studies