You can add extra text to an email with this code snippet. You may want to include an extra thank you message, or offer a discount coupon code for returning customers. In this example we are turning the “order completed” email into a legal tax invoice by adding the required extra information at the top.
To target a specific email use one of these conditions:
if ( $email->id == 'customer_processing_order' ) {}
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' ) {}
/**
* Add custom content to a specific customer order email
*/
add_action('woocommerce_email_before_order_table', 'cc_add_custom_content_specific_email', 20, 4);
function cc_add_custom_content_specific_email($order, $sent_to_admin, $plain_text, $email) {
if ($email->id == 'customer_completed_order') {
echo '<h2 class="email-extra-title">TAX INVOICE</h2><p class="email-extra-text">Smith & Smith Pty Ltd<br />
26 Smith Street, Smithville, NSW 2000<br />
Tel: +61 (0)2 9876 5432<br />
ABN 11 111 111 111</p>';
}
}