Changing specific order details text in Woocommerce order received page

人走茶凉 提交于 2021-02-08 08:21:30

问题


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


回答1:


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…



来源:https://stackoverflow.com/questions/48267068/changing-specific-order-details-text-in-woocommerce-order-received-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!