From 067210346579da3d3bbc3e8e6b1eca242fd61feb Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Tue, 28 Oct 2025 14:33:16 +0330 Subject: [PATCH] add: shipment item to cart --- src/modules/cart/cart.repository.ts | 3 +++ src/modules/cart/cart.service.ts | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/cart/cart.repository.ts b/src/modules/cart/cart.repository.ts index 8188712..5db9705 100644 --- a/src/modules/cart/cart.repository.ts +++ b/src/modules/cart/cart.repository.ts @@ -353,6 +353,9 @@ class CartShipItemRepo extends BaseRepository { constructor() { super(CartShipmentItemModel); } + async getCartShipmentItems(cartId: string) { + return this.model.find({ cart: cartId }); + } } function createCartShipItemRepo(): CartShipItemRepo { diff --git a/src/modules/cart/cart.service.ts b/src/modules/cart/cart.service.ts index 6cd1698..c636156 100644 --- a/src/modules/cart/cart.service.ts +++ b/src/modules/cart/cart.service.ts @@ -25,8 +25,9 @@ class CartService { async getCartS(userId: string) { const doc = (await this.cartRepo.getCartWithAggregate(userId))[0] as ICart; const cart = CartDTO.transformCart(doc); + const cartShipmentItems = await this.cartShipItemRepo.getCartShipmentItems(cart._id); const recommended = await this.getRecommendedProducts(doc); - return { cart, recommended }; + return { cart: { ...cart, cartShipmentItems }, recommended }; } async clearCart(userId: string) {