在 Woocommerce 管理订单页面中更改文本 "Billing" 和 "Shipping"

Change texts "Billing" and "Shipping" in Woocommerce admin order pages

我正在尝试更改“帐单”(意大利语中的“Fatturazione”) 和“运输”(意大利语中的“Spedizion”e)的标签文本意大利语) 在 Woocommerce 管理订单页面中。

见下方截图(相关文字为黄色)

例如,如果我想用“测试”更改帐单地址文本 和带有“测试 2”的送货地址文本,我该怎么做?

感谢任何帮助。

您可以按如下方式使用 WordPress gettext 挂钩 (针对未翻译的原文):

add_filter( 'gettext', 'change_admin_order_edit_pages_texts', 10, 3 );
function change_admin_order_edit_pages_texts( $translated_text, $text, $domain ) {
    global $pagenow, $post_type;

    if( in_array($pagenow, ['post.php', 'post-new.php']) && 'shop_order' === $post_type && is_admin() ) {
        if( 'Billing' === $text ) {
            $translated_text = __('Test 1', $domain); // <== Here the replacement txt
        }

        if( 'Shipping' === $text ) {
            $translated_text = __('Test 2', $domain); // <== Here the replacement txt
        }

    }
    return $translated_text;
}

代码进入活动子主题(或活动主题)的 functions.php 文件。已测试并有效。