@@ -24,12 +24,12 @@ class CartService {
|
|||||||
|
|
||||||
async getCartS(userId: string) {
|
async getCartS(userId: string) {
|
||||||
const doc = (await this.cartRepo.getCartWithAggregate(userId))[0] as ICart;
|
const doc = (await this.cartRepo.getCartWithAggregate(userId))[0] as ICart;
|
||||||
if (!doc) {
|
|
||||||
throw new BadRequestError(CartMessage.CartNotFound);
|
|
||||||
}
|
|
||||||
const cart = CartDTO.transformCart(doc);
|
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);
|
const recommended = await this.getRecommendedProducts(doc);
|
||||||
return { cart: { ...cart, cartShipmentItems }, recommended };
|
return { cart: { ...cart, cartShipmentItems }, recommended };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user