Menu Close

Add Content to the Specific WooCommerce Order Email

codeamend
Here’s the quick example to see how to add content to any WooCommerce default order email.

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

add_action( 'woocommerce_email_before_order_table', 'codeamend_add_content_specific_email', 20, 4 );
  
function codeamend_add_content_specific_email( $order, $sent_to_admin, $plain_text, $email ) {
   if ( $email->id == 'customer_processing_order' ) {
      echo '<h2 class="email-upsell-title">Get 20% off</h2><p class="email-upsell-p">Thank you for making this purchase! Come back and use the code "<strong>Back4More</strong>" to receive a 20% discount on your next purchase! Click here to continue shopping.</p>';
   }
} 
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' ) {} 

Share

Posted in WooCommerce

You can also read...

Leave a Reply

Your email address will not be published.