1

How can I append text to the WooCommerce email messages without overriding the existing templates. Ideally I want to add different messages to each email, without overriding the default templates.

I've tried to hook into the following actions:

do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );

And:

do_action( 'woocommerce_email_header', $email_heading, $email );

In both cases it seems the $email variable is not passed though.

  • Can you write a piece of code you use to hook into this actions? – dev_masta Jan 12 '18 at 21:32
6
+25

You may be using the wrong hook. I use this :

add_action( "woocommerce_email_after_order_table", "custom_woocommerce_email_after_order_table", 10, 1);

function custom_woocommerce_email_after_order_table( $order ) {

    echo '<p>content after email table</p>';

}

now, if you look at this link it will show you other hooks that you can use if you want to append other information to the email.

for instance, if you want it in the header instead of after the table:

add_action( "woocommerce_email_header", "woocommerce_email_header_intro", 10, 1);

function woocommerce_email_header_intro( $order ) {

    echo '<p>content at top of email</p>';

}
  • do you have an example of making the text conditional to the email that is being sent? – addedlovely Jan 12 '18 at 13:49
  • sure what kind of conditional do you mean? – rudtek Jan 12 '18 at 18:38
  • e.g. to show a different string of text on the 'Processing' then 'Completed' emails. – addedlovely Jan 15 '18 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.