更改WooCommerce购物车和结账页面上的“Total”文本。

huangapple go评论70阅读模式
英文:

Change "Total" text in WooCommerce cart and checkout pages

问题

WooCommerce 使用 wc_cart_totals_order_total_html() 函数来显示购物车页面(以及结账页面)中的“格式化订单总金额(包括税金,如果需要的话)”。在购物车页面(以及结账页面),我希望能够在显示的总金额旁边添加文本“应付金额:”。

任何帮助都将不胜感激。

英文:

WooCommerce uses wc_cart_totals_order_total_html() function to display the "formatted order total amount (including tax if needed)" in cart page (and checkout too).

In the cart page (and checkout), I would like to be able to add the text "Amount to be paid:" next to the displayed total amount.

Any help is appreciated.

答案1

得分: 2

To alter, the text "Total" displayed next to the formatted displayed total amount (in cart and checkout pages), you can use a custom function hooked in WordPress gettext hook as follows:

add_filter('gettext', 'change_some_woocommerce_strings', 10, 3);
function change_some_woocommerce_strings($translate_text, $original_text, $domain) {
    if ($original_text === 'Total' && $domain === 'woocommerce' && (is_cart() || is_checkout())) {
        $translate_text = __('Amount to be paid', $domain);
    }

    return $translate_text;
}

Code goes in functions.php file of the active child theme (or active theme). Tested and works.

英文:

To alter, the text "Total" displayed next to the formatted displayed total amount (in cart and checkout pages), you can use a custom function hooked in WordPress gettext hook as follows:

add_filter( 'gettext', 'change_some_woocommerce_strings', 10, 3 );
function change_some_woocommerce_strings( $translate_text, $original_text, $domain ) {
    if ( $original_text === 'Total' && $domain === 'woocommerce' && ( is_cart() || is_checkout() ) ) {
        $translate_text = __('Amount to be paid', $domain);
    }

    return $translate_text;
}

Code goes in functions.php file of the active child theme (or active theme). Tested and works.

huangapple
  • 本文由 发表于 2023年6月25日 20:08:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/76550311.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定