From 3e8f6a3ea551e824997986c25ef3f93d6622b638 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Tue, 28 Oct 2025 15:40:41 +0330 Subject: [PATCH] fix : cart error --- src/modules/cart/cart.service.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/cart/cart.service.ts b/src/modules/cart/cart.service.ts index 1c45c40..a019e97 100644 --- a/src/modules/cart/cart.service.ts +++ b/src/modules/cart/cart.service.ts @@ -24,12 +24,12 @@ class CartService { async getCartS(userId: string) { const doc = (await this.cartRepo.getCartWithAggregate(userId))[0] as ICart; - if (!doc) { - throw new BadRequestError(CartMessage.CartNotFound); - } const cart = CartDTO.transformCart(doc); - const cartShipmentItems = await this.cartShipItemRepo.getCartShipmentItems(doc._id.toString()); + let cartShipmentItems; + if (doc?._id) { + cartShipmentItems = await this.cartShipItemRepo.getCartShipmentItems(doc._id.toString()); + } const recommended = await this.getRecommendedProducts(doc); return { cart: { ...cart, cartShipmentItems }, recommended }; }