php - 更改 Woocommerce 订单接收页面中的特定订单详细信息文本

标签 php wordpress woocommerce gettext wpml

在订单接收页面('woocommerce_thankyou')上有一个表格,其中包含订单详细信息标题“订单详细信息” (Ordredetaljer 用我的母语)。

我不知道如何更改此标题。我什至无法正确找到它的源代码。如果有人可以告诉我字符串(我们使用 wpml 进行字符串翻译)或源代码,我将是一个快乐的开发人员。

Picture of the heading in question can be found here

最佳答案

您要查找的模板位于order/order-details.php

但由于 WooCommerce 模板似乎不适用于您的主题,您可以尝试以下替代方案:

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

代码位于事件子主题(或事件主题)的 function.php 文件中。

应该可以。

要专门定位“已收到订单”页面,您可以替换:

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

作者:

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…

关于php - 更改 Woocommerce 订单接收页面中的特定订单详细信息文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48267068/

相关文章:

javascript - 如何在 WordPress `functions.php` 中将一个又一个脚本排队,并让它们一起工作?

php - MySQL 仅返回 ID 1 的值

PHP Laravel 返回查看 null 变量

css - 滚动时如何更改 float 标题菜单的文本颜色?

wordpress - Woocommerce 数据库中订单的运送方法

php - Woocommerce 退款电子邮件

php - 如何将CSS应用于Wordpress/Woocommerce中除某些产品页面之外的所有页面?

php - 如果不存在则插入否则删除 - 使用重复键

php - 比较php中两个数组的值

php - 获取选定的状态字段值以将其显示在 Woocommerce 结账审核订单中