2

I need to remove this item count text in my orders table at the my account page, because I don't need it:

enter image description here

The text at Gesamtsumme should be changed from:

234,35€ for 1 Artikel

to

234,35€</p>

I've tried it with deleting it in the file but I want to do this via my functions.php because this is better I think.

4

4 回答 4

2

对于所有语言,使其适用于单数和复数项目计数的正确方法是$text未翻译的字符串在哪里)

add_filter('ngettext', 'remove_item_count_from_my_account_orders', 105, 3 );
function remove_item_count_from_my_account_orders( $translated, $text, $domain ) {
    switch ( $text ) {
        case '%1$s for %2$s item' :
            $translated = '%1$s';
            break;

        case '%1$s for %2$s items' :
            $translated = '%1$s';
            break;
    }
    return $translated;
}

代码位于您的活动子主题(或活动主题)的 function.php 文件中。测试和工作。

于 2018-09-30T22:54:57.297 回答
1

终于做到了:

add_filter('ngettext', 'rename_place_order_button' );
function rename_place_order_button( $translated, $text, $domain ) {
    switch ( $translated ) {
        case '%1$s für %2$s Artikel' :
            $translated = __( '%1$s', 'woocommerce' );
            break;
    }
    return $translated;
}
于 2018-09-30T22:12:56.067 回答
0

请在functions.php文件下添加以下代码

function replace_content($content)
{
$content = str_replace('für 1 Artikel', '',$content);
return $content;
}
add_filter('the_content','replace_content');
于 2018-09-30T20:57:49.920 回答
0

为了将来参考,如果您使用像 Loco Translate 这样的翻译插件,您也可以在那里更改翻译,因此不需要代码。

搜索以下 2 个字符串:

%1$s 用于 %2$s 项

%1$s 用于 %2$s 件商品

将两者更改为:

%1$s

这只会在“我的账户”页面的订单列表中显示订单的总价

于 2022-01-11T17:23:00.267 回答