Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Commit 1267436

Browse files
committed
#530: [Cart Operations] Update Cart Items validation messages
1 parent 7270d7e commit 1267436

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

app/code/Magento/QuoteGraphQl/Model/Resolver/UpdateCartItems.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,25 @@ private function processCartItems(Quote $cart, array $items): void
111111
$this->cartItemRepository->deleteById((int)$cart->getId(), $itemId);
112112
} else {
113113
$cartItem->setQty($qty);
114+
115+
if ($cartItem->getHasError()) {
116+
$errors = [];
117+
foreach ($cartItem->getMessage(false) as $message) {
118+
if (!in_array($message, $errors)) {
119+
$errors[] = $message;
120+
}
121+
}
122+
123+
if (!empty($errors)) {
124+
throw new GraphQlInputException(
125+
__(
126+
'Could not update the product with SKU %sku: %message',
127+
['sku' => $cartItem->getSku(), 'message' => __(implode("\n", $errors))]
128+
)
129+
);
130+
}
131+
}
132+
114133
$this->cartItemRepository->save($cartItem);
115134
}
116135
}

0 commit comments

Comments
 (0)