From 79db7817be9a75784eb67e8ec337577e4753cef6 Mon Sep 17 00:00:00 2001 From: Rihards Abolins Date: Tue, 22 Jun 2021 08:13:24 +0300 Subject: [PATCH 1/2] #2615 If product out of stock show error message --- src/Model/Resolver/MoveWishlistToCart.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Model/Resolver/MoveWishlistToCart.php b/src/Model/Resolver/MoveWishlistToCart.php index c11fcb1..35a03e2 100644 --- a/src/Model/Resolver/MoveWishlistToCart.php +++ b/src/Model/Resolver/MoveWishlistToCart.php @@ -101,9 +101,9 @@ protected function addItemsToCart(array $wishlistItems, CartInterface $quote): v $stockStatus = $this->stockStatusRepository->get($product->getId()); $productStockStatus = $stockStatus->getStockStatus(); - // Don't add out of stock product to cart + // If product is out of stock outputs error message if($productStockStatus === StockStatusInterface::STATUS_OUT_OF_STOCK){ - continue; + throw new GraphQlNoSuchEntityException(__('One or more items are out of stock')); } $data = json_decode($item['buy_request'], true); From 840fce17eddfcd6189ffdcd9dc8600e105d07577 Mon Sep 17 00:00:00 2001 From: Rihards Abolins Date: Tue, 22 Jun 2021 08:21:57 +0300 Subject: [PATCH 2/2] #2615 Error message change for failed order --- src/Model/Resolver/MoveWishlistToCart.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/Resolver/MoveWishlistToCart.php b/src/Model/Resolver/MoveWishlistToCart.php index 35a03e2..b768933 100644 --- a/src/Model/Resolver/MoveWishlistToCart.php +++ b/src/Model/Resolver/MoveWishlistToCart.php @@ -120,7 +120,7 @@ protected function addItemsToCart(array $wishlistItems, CartInterface $quote): v try { $this->quoteRepository->save($quote); } catch (Exception $e) { - throw new GraphQlNoSuchEntityException(__('There was an error when trying to save wishlist items to cart')); + throw new GraphQlNoSuchEntityException(__('Failed to add items to cart')); } }