Skip to content

Commit

Permalink
Fix message when maxSaleQty is set and qty is more than maxSaleQty
Browse files Browse the repository at this point in the history
  • Loading branch information
XxXgeoXxX committed Feb 13, 2019
1 parent f211371 commit 8fafd29
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions app/code/Magento/QuoteGraphQl/Model/Cart/AddProductsToCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,17 @@ public function __construct(
* @param array $cartItems
* @throws GraphQlInputException
* @throws \Magento\Framework\Exception\LocalizedException
* @throws \Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException
*/
public function execute(Quote $cart, array $cartItems): void
{
foreach ($cartItems as $cartItemData) {
$this->addProductToCart->execute($cart, $cartItemData);
}

if ($cart->getData('has_error')) {
throw new GraphQlInputException(
__('Shopping cart error: %message', ['message' => $this->getCartErrors($cart)])
);
try {
$this->addProductToCart->execute($cart, $cartItemData);
} catch (\Exception $error) {
throw new GraphQlInputException(
__('Shopping cart error: %message', ['message' => $error->getMessage()])
);
}
}

$this->cartRepository->save($cart);
Expand Down

0 comments on commit 8fafd29

Please sign in to comment.