Skip to content

Commit

Permalink
Merge pull request #20 from riha112/2615
Browse files Browse the repository at this point in the history
#2615 If product out of stock output error message
  • Loading branch information
carinadues authored Jul 19, 2021
2 parents bc0189c + 840fce1 commit 55b6097
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Model/Resolver/MoveWishlistToCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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'));
}
}

Expand Down

0 comments on commit 55b6097

Please sign in to comment.