2

When I list a product as out of stock and try to add it to my basket I get the message 'This product is out of stock'.

I'd like to change this message to 'This product is currently out of stock, please call store for updates'.

Can anyone suggest how this can be done in Magento 2?

2
  • 1
    Did you try with translation? Mar 11 '17 at 9:02
  • I have, didn't work for me unfortunately. Mar 11 '17 at 9:48
3

Rather than overwrite vendor/module-catalog-inventory/i18n/en_US.csv as suggested in @Pankaj Bhope answer you should create your own translation file in app/design/frontend/<your_vendor_name>/<your_theme_name>/i18n/en_US.csv and add your translation to it:

"This product is out of stock.","This product is currently out of stock, please call store for updates."

If you don't follow this approach and overwrite Magento's core functionality directly at vendor/module-catalog-inventory/i18n/en_US.csv your changes will be lost when you next update Magento2 to avail of new features or security updates.

Also english US is the default locale on a Magento2 installation, but if you've set a different locale at Stores -> Configuration -> General you will need to change the file name from en_US.csv to match your locale, en_GB.csv for the UK for instance.

You can find more information here: http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/translations/xlate.html

1

Try This:

1) Modify vendor/module-catalog-invertory/i18n/en_US.csv

2) There are two entries of this message "This product is out of stock"

3) Change to "This product is currently out of stock, please call store for updates".

4) Clear Static contents.

5) Deploy using the cli command.

bin/magento setup:static-content:deploy

6) Now check again. If this does not work, you can directly change the message by overriding the classes but I will not recommend doing that.

4
  • Thanks Pankaj. Just to say I did not have to redeploy static content. It worked simply by updating that csv file. Mar 11 '17 at 14:00
  • You are welcome. Happy to help :) Mar 12 '17 at 7:27
  • 3
    if you follow this approach your changes will be lost when you update your Magento2 store, the recommended approach is to add your own translation dictionary to your theme, as described in the Magento2 Docs
    – Holly
    Apr 12 '17 at 7:41
  • Never update vendor files.
    – Tobe_Sta
    Aug 4 '20 at 5:54

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.