Reputation:
I need to remove this item count text in my orders table at the my account page, because I don't need it:
The text at Gesamtsumme should be changed from:
234,35€ for 1 Artikel
to
234,35€
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.
Upvotes: 4
Views: 1133
Reputation: 438
For future reference, if you are using a translation plugin like Loco Translate, you can also change the translation there so no code is necessary.
Search for the following 2 strings:
%1$s for %2$s item
%1$s for %2$s items
Change both to:
%1$s
This will only display the total price of the order in the orders list of the 'my account' page
Upvotes: 0
Reputation: 253978
The correct way to make it work for singular and plural item count, for all languages is (where $text
is the untranslated string):
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;
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
Upvotes: 4
Reputation:
This finaly made it:
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;
}
Upvotes: 1
Reputation: 3040
Please add the following code under functions.php file
function replace_content($content)
{
$content = str_replace('für 1 Artikel', '',$content);
return $content;
}
add_filter('the_content','replace_content');
Upvotes: 0