3

I want to display just wishlist count like wishlist (2) in top bar, how can I remove the word "items" or "item"

  • can you please upload your code here? – Rohan Hapani Aug 31 '17 at 9:12
3

you can remove it from

if you have no theme installed you can go to this and change the 1 item and %1 items.

vendor/magento/module-catalog/i18n/en_US.csv or

if you have a theme installed you can go to this location and do that.

app/design/frontend/Magento/<theme>/i18n/en_US.csv

  • thanks! but if i change "%1 items" to "%1" in en_US.csv it will change every where it found "%1 items". is there any other way? – Waqar Aug 31 '17 at 10:15
  • @waqar this is not used at more places so I think it will not affect your site. I personally replaced it and didn't see changes.You can go ahead. – Riddhish Bhayani Aug 31 '17 at 10:26
2

You can also edit counter generated phrase.

Look at the file in:

vendor/magento/module-wishlist/CustomerData/Wishlist.php

on line 84 you will see:

protected function createCounter($count)
{
    if ($count > 1) {
        return __('%1 items', $count);
    } elseif ($count == 1) {
        return __('1 item');
    }
    return null;
}

You only have to override that method in your custom module.

For more info on how to do that this, look the following:

How to override customerData folder's file in magento 2?

  • 1
    Please correct the path in your answer. It's "CustomerData" folder. /vendor/magento/module-wishlist/CustomerData/Wishlist.php – Pratik Kamani Dec 21 '18 at 6:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.