Skip to content

Commit 2363896

Browse files
committed
mutations add<Product Type>ProductsToCart dosn't check if the cart is active
1 parent e431556 commit 2363896

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

app/code/Magento/QuoteGraphQl/Model/Cart/GetCartForUser.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,15 @@ public function execute(string $cartHash, ?int $customerId): Quote
8585
);
8686
}
8787

88-
try {
89-
return $this->cartRepository->getActiveForCustomer($customerId);
90-
} catch (\Exception $e) {
91-
throw new GraphQlNoSuchEntityException(
92-
__('Current customer does not have an active cart.')
93-
);
88+
if ($customerId) {
89+
try {
90+
return $this->cartRepository->getActiveForCustomer($customerId);
91+
} catch (\Exception $e) {
92+
throw new GraphQlNoSuchEntityException(
93+
__($e->getMessage())
94+
);
95+
}
9496
}
97+
return $cart;
9598
}
9699
}

0 commit comments

Comments
 (0)