To change the heading that appears in the body (message) of the email template you can use the following filter: 'woocommerce_email_heading_' . $this->id
where $this->id
equates to the id
class property that is set within the email class of the specified type.
For example, to change the heading of the “New Order” email you would do the following:
function filter_heading_new_order($heading) {
return 'My New Heading';
}
add_filter('woocommerce_email_heading_new_order', 'filter_heading_new_order');
To get the $this->id
property of each email you can look at the classes in:
plugins/woocommerce/includes/emails
To elaborate further based upon your comments, if you want to edit some of the specific elements within the email body (message) you will need to look at some of the hoosk that are used within the template file in question as these hooks are used to inject data into the template.
For example to edit the Customer Details heading:
function filter_custom_details_header($heading) {
return 'My Customer Details Heading';
}
add_filter('woocommerce_email_custom_details_header', 'filter_custom_details_header');
To filter the heading for bank details, commonly “Our Bank Details” which is hooked onto woocommerce_email_before_order_table
and called from the callback function email_instructions()
in class-wc-gateway-bacs.php
you would need to use the gettext
filter as they echo this value and provide no direct filter for it.
function filter_bank_details_headin($translated_text, $text, $domain) {
if ( did_action('woocommerce_email_before_order_table') ) {
switch ( $translated_text ) {
case 'Our Bank Details' :
$translated_text = __( 'My Bank Details Are...', 'woocommerce' );
break;
}
}
return $translated_text;
}
add_filter( 'gettext', 'filter_bank_details_heading', 20, 3 );