How to Change Customer Notification, Warnings, or Messages – Magento 2.1

localisationmagento-2.1magento2messages

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?

Best Answer

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

Related Topic