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.
1 Answer
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>';
}