I have limited the number of items allowed in shopping cart to 4. That I've done successfully. however I didn't like the displayed message:
The most you may purchase is 4
I want to change it, where/how can I do this?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI have limited the number of items allowed in shopping cart to 4. That I've done successfully. however I didn't like the displayed message:
The most you may purchase is 4
I want to change it, where/how can I do this?
you need to override app/code/Magento/CatalogInventory/Model/StockStateProvider.php
change the below line
->setMessage(__('The most you may purchase is %1.', $stockItem->getMaxSaleQty() * 1))
To
->setMessage(__('whatever message you need %1.', $stockItem->getMaxSaleQty() * 1))
for alternate solution you can create own module that contains a translation file i18n/en_US.csv. here you can translate your phrase
The most you may purchase is to whatever message you need
Another solution can be to create a theme specific translation by following the official documentation here: http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/translations/translate_practice.html
Then you only need to add the following in your magento2/app/design/frontend/Vendor/Theme/i18n/en_US.csv
:
'The most you may purchase is %1.','Your custom message %1'