Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove items count from my account orders table in Woocommerce

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€

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.


2 Answers

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.

like image 132
LoicTheAztec Avatar answered Sep 09 '25 19:09

LoicTheAztec


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;
}

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!