英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论