Editing Header Titles of each details in woocommerce Order Email [closed]

I’m using flatsome theme, woocommerce plugin.
On my thank you page I get the bank details, order details and customer details etc. but on customer order email, header TITLES of those details are different from those that are shown on the thank you page. Is there any way I can change the header titles of details on the email?
I have already changed the header title of order-details-customer.php and it is correctly reflected on thank you page but NOT IN EMAIL.

Thank you in advance!

Hope someone can really help me! T-T

1 Answer
1

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 );

Leave a Comment