Skip to content

Commit 7f12792

Browse files
MC-39104: 2 error messages in Cart when product is out of stock
1 parent ad29452 commit 7f12792

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,13 @@ public function validate(Observer $observer)
157157
if ($stockStatus->getStockStatus() === Stock::STOCK_OUT_OF_STOCK
158158
|| $parentStockStatus && $parentStockStatus->getStockStatus() == Stock::STOCK_OUT_OF_STOCK
159159
) {
160-
$quoteItem->addErrorInfo(
161-
'cataloginventory',
162-
Data::ERROR_QTY,
163-
__('This product is out of stock.')
164-
);
160+
if (!$quoteItem->getStockStateResult() && !$quoteItem->getStockStateResult()->getHasError()) {
161+
$quoteItem->addErrorInfo(
162+
'cataloginventory',
163+
Data::ERROR_QTY,
164+
__('This product is out of stock.')
165+
);
166+
}
165167
$quoteItem->getQuote()->addErrorInfo(
166168
'stock',
167169
'cataloginventory',

0 commit comments

Comments
 (0)