Skip to content

Commit

Permalink
mutations add<Product Type>ProductsToCart dosn't check if the cart is…
Browse files Browse the repository at this point in the history
… active
  • Loading branch information
XxXgeoXxX committed Mar 11, 2019
1 parent e431556 commit 2363896
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions app/code/Magento/QuoteGraphQl/Model/Cart/GetCartForUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,15 @@ public function execute(string $cartHash, ?int $customerId): Quote
);
}

try {
return $this->cartRepository->getActiveForCustomer($customerId);
} catch (\Exception $e) {
throw new GraphQlNoSuchEntityException(
__('Current customer does not have an active cart.')
);
if ($customerId) {
try {
return $this->cartRepository->getActiveForCustomer($customerId);
} catch (\Exception $e) {
throw new GraphQlNoSuchEntityException(
__($e->getMessage())
);
}
}
return $cart;
}
}

0 comments on commit 2363896

Please sign in to comment.