2

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

closed as off-topic by TheDeadMedic, birgire, Howdy_McGee, kaiser Feb 29 '16 at 15:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

2

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 );
  • Thank you so much for you kind reply, but unfortunately that's not what I'm looking for.. Your solution changes the TOP MAIN HEADER TITLE OF EMAIL, but I'm looking for a solution to edit the titles of each information (order details, customer details etc.) IN THE BODY OF THE EMAIL (If you look into the order email, there's all sorts of information about the order and the customer, what I want to edit are the titles of those details) – zhie Feb 19 '16 at 11:28
  • In that case you want to edit the email templates. You can override the templates by copy the template you need from plugins/woocommerce/templates/emails into your theme directory like this: wp-content/themes/**your-theme**/woocommerce/emails. E.g. copy new admin-new-order.php from the first directory into the second (your theme) and edit it accordingly. You may have to further filter things if certain templates are calling helper functions. – userabuser Feb 19 '16 at 12:52
  • Yes, that's what I did with order-details-customer.php..I changed the header and it is correctly shown in the thank you page but not in the email......that's my problem.. – zhie Feb 19 '16 at 13:08
  • Are you trying to change the new order email that goes to the admin? If so, you need to be aware that there are hooks in the admin-new-order.php template file such as woocommerce_email_after_order_table woocommerce_email_order_meta woocommerce_email_customer_details etc, which Woocommerce hooks onto to inject data into the email. Precisely which headings do you want to change. If you want to change customer details heading for example replace the above hook with woocommerce_email_custom_details_header. – userabuser Feb 19 '16 at 13:15
  • I want to change the processing-order email that customer receives when he or she makes an order. In that email, I want to specifically change the title for the bank transfer details, and title for the customer details. – zhie Feb 19 '16 at 13:47

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