0

I'm trying to use Woocommerce hooks to make changes in specific email templates. I'd like to override the text in customer-processing-order.php and customer-completed-order.php in my functions.php file. Here is the code I am using:

add_action( 'woocommerce_email_customer_details', 'hitt_processing_customer_email', 10, 4 );
function hitt_processing_customer_email( $order, $sent_to_admin, $plain_text, $email ) {

    if( 'customer_processing_order' == $email->id ){
        echo '<p>My custom content here</p>';
    }

    if( 'customer_completed_order' == $email->id ){
        echo '<p>My custom content here</p>';
    }
}

But this doesn't seem to be working. I set myself as the customer and when I got the "your order is being processed" email, it did not have the custom text added. What am I doing wrong?

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
Dana Victoria
  • 71
  • 1
  • 1
  • 10
  • You can not use hooks to change the text starting on emails as it's hardcoded in the related templates themselves… So you need to override both related templates via your active theme [as explained in this official documentation](https://docs.woocommerce.com/document/template-structure/) – LoicTheAztec Feb 03 '19 at 20:56

1 Answers1

0

I realized that the code above was working but it was placing it in the wrong place so I didn't see the change so here is the revised code that places the text below the default text but above the price table:

add_action( 'woocommerce_email_before_order_table', 'custom_content_to_processing_customer_email', 10, 4 );
function custom_content_to_processing_customer_email( $order, $sent_to_admin, $plain_text, $email ) {

if( 'customer_processing_order' == $email->id ){

    echo '<p>Your custom text on the customer processing order</p>';

}
if( 'customer_completed_order' == $email->id ){
    echo '<p>Your custom text on the customer completed order email.</p>';
}

}
Dana Victoria
  • 71
  • 1
  • 1
  • 10