cart refactor
This commit is contained in:
@@ -156,18 +156,18 @@ export class CartService {
|
||||
/**
|
||||
* Increment item quantity in cart
|
||||
*/
|
||||
async incrementItem(userId: string, shopId: string, foodId: string, quantity: number): Promise<Cart> {
|
||||
async incrementItem(userId: string, shopId: string, variantId: string, quantity: number): Promise<Cart> {
|
||||
const cart = await this.getOrCreateCart(userId, shopId);
|
||||
await this.itemService.addOrIncrementItem(cart, foodId, shopId, quantity);
|
||||
await this.itemService.addOrIncrementItem(cart, variantId, shopId, quantity);
|
||||
return this.recalculateAndSaveCart(cart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrement item quantity in cart by 1 (removes item if quantity reaches 0)
|
||||
*/
|
||||
async decrementItem(userId: string, shopId: string, foodId: string): Promise<Cart> {
|
||||
async decrementItem(userId: string, shopId: string, variantId: string): Promise<Cart> {
|
||||
const cart = await this.findOneOrFail(userId, shopId);
|
||||
await this.itemService.decrementOrRemoveItem(cart, foodId);
|
||||
await this.itemService.decrementOrRemoveItem(cart, variantId);
|
||||
return this.recalculateAndSaveCart(cart);
|
||||
}
|
||||
|
||||
@@ -187,9 +187,9 @@ export class CartService {
|
||||
/**
|
||||
* Remove item from cart
|
||||
*/
|
||||
async removeItem(userId: string, shopId: string, foodId: string): Promise<Cart> {
|
||||
async removeItem(userId: string, shopId: string, variantId: string): Promise<Cart> {
|
||||
const cart = await this.findOneOrFail(userId, shopId);
|
||||
this.itemService.removeItemOrFail(cart, foodId);
|
||||
this.itemService.removeItemOrFail(cart, variantId);
|
||||
return this.recalculateAndSaveCart(cart);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user