Home » WooCommerce: Add Content to a Specific Order Email

WooCommerce: Add Content to a Specific Order Email

by adminkys

Customizing WooCommerce emails via the WordPress dashboard is not easy and – sometimes – not possible. For example, you can’t edit or add content to them unless you’re familiar with code.

Well, here’s a quick example to learn how to add content to any WooCommerce default order email. In this case study, our goal is showing an upsell to get buyers to go back to the website and buy with a coupon code. Enjoy!

WooCommerce - how to add content to the order email
WooCommerce – how to add content to the order email

PHP Snippet: Add Content to the WooCommerce Customer Processing Order Email

/**
 * @snippet       Add Text to Customer Processing Order Email
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @testedwith    Woo 4.6
 * @donate $9     https://www.tutoraspire.com
 */
 
add_action( 'woocommerce_email_before_order_table', 'tutoraspire_add_content_specific_email', 20, 4 );
 
function tutoraspire_add_content_specific_email( $order, $sent_to_admin, $plain_text, $email ) {
   if ( $email->id == 'customer_processing_order' ) {
      echo '';
   }
}

How to Target Other WooCommerce Order Emails

Using the same snippet above, you can target different emails by changing the email ID

if ( $email->id == 'cancelled_order' ) {}
if ( $email->id == 'customer_completed_order' ) {}
if ( $email->id == 'customer_invoice' ) {}
if ( $email->id == 'customer_new_account' ) {}
if ( $email->id == 'customer_note' ) {}
if ( $email->id == 'customer_on_hold_order' ) {}
if ( $email->id == 'customer_refunded_order' ) {}
if ( $email->id == 'customer_reset_password' ) {}
if ( $email->id == 'failed_order' ) {}
if ( $email->id == 'new_order' ) {}

You may also like