add: shipment item to cart
This commit is contained in:
@@ -353,6 +353,9 @@ class CartShipItemRepo extends BaseRepository<ICartShipmentItem> {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super(CartShipmentItemModel);
|
super(CartShipmentItemModel);
|
||||||
}
|
}
|
||||||
|
async getCartShipmentItems(cartId: string) {
|
||||||
|
return this.model.find({ cart: cartId });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createCartShipItemRepo(): CartShipItemRepo {
|
function createCartShipItemRepo(): CartShipItemRepo {
|
||||||
|
|||||||
@@ -25,8 +25,9 @@ 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;
|
||||||
const cart = CartDTO.transformCart(doc);
|
const cart = CartDTO.transformCart(doc);
|
||||||
|
const cartShipmentItems = await this.cartShipItemRepo.getCartShipmentItems(cart._id);
|
||||||
const recommended = await this.getRecommendedProducts(doc);
|
const recommended = await this.getRecommendedProducts(doc);
|
||||||
return { cart, recommended };
|
return { cart: { ...cart, cartShipmentItems }, recommended };
|
||||||
}
|
}
|
||||||
|
|
||||||
async clearCart(userId: string) {
|
async clearCart(userId: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user