Changing specific order details text in Woocommerce order received page

On the order-recieved page ('woocommerce_thankyou') there is a table with the order details a heading "Order Details" (Ordredetaljer in my native language).

I cannot figure out how to change this heading. I can't even find the source code for it properly. If someone could tell me the string(We use wpml for string translation) or the source code I would be a happy developer.

Picture of the heading in question can be found here

Upvotes: 2

Views: 7278

Answers (1)

LoicTheAztec
LoicTheAztec

Reputation: 253784

The template you are looking for is located in order/order-details.php

But as WooCommerce templates doesn't seem to work in your theme you can try this alternative:

add_filter('gettext', 'changes_in_thank_you', 100, 3 );
function changes_in_thank_you( $translated_text, $text, $domain ) {
    if( $text === 'Order details' ) {

        $translated_text =  __( 'Your replacement text', $domain );
    }
    return $translated_text;
}

Code goes in function.php file of the active child theme (or active theme).

It should work.

To target specifically "Order received" page you can replace:

if( $text === 'Order details' ) {

by:

if( $text === 'Order details' && is_wc_endpoint_url( 'order-received' ) ) {

In WPML:

1) In "Theme and plugins localization" You can load the translatable text for "Woocommerce" plugin scanning this plugin.
2) In "String translations" you should be able to find the string 'Order details' for the woocommerce domain and change the yranslation for your language…

Upvotes: 2

Related Questions