Support variant-aware cart lines
This commit is contained in:
@@ -102,27 +102,36 @@ export class CartComponent implements OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
removeItem(itemID: number): void {
|
||||
this.cartService.removeItem(itemID);
|
||||
removeItem(item: CartItem): void {
|
||||
this.cartService.removeItem(item.itemID, this.cartVariant(item));
|
||||
this.swipedItemId.set(null);
|
||||
}
|
||||
|
||||
updateQuantity(itemID: number, quantity: number): void {
|
||||
this.cartService.updateQuantity(itemID, quantity);
|
||||
updateQuantity(item: CartItem, quantity: number): void {
|
||||
this.cartService.updateQuantity(item.itemID, quantity, this.cartVariant(item));
|
||||
}
|
||||
|
||||
increaseQuantity(itemID: number, currentQuantity: number): void {
|
||||
this.updateQuantity(itemID, currentQuantity + 1);
|
||||
increaseQuantity(item: CartItem): void {
|
||||
this.updateQuantity(item, item.quantity + 1);
|
||||
}
|
||||
|
||||
decreaseQuantity(itemID: number, currentQuantity: number): void {
|
||||
if (currentQuantity <= 1) {
|
||||
this.removeItem(itemID);
|
||||
decreaseQuantity(item: CartItem): void {
|
||||
if (item.quantity <= 1) {
|
||||
this.removeItem(item);
|
||||
} else {
|
||||
this.updateQuantity(itemID, currentQuantity - 1);
|
||||
this.updateQuantity(item, item.quantity - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private cartVariant(item: CartItem): { colour?: string; size?: string; price?: number; currency?: string } {
|
||||
return {
|
||||
colour: item.colour,
|
||||
size: item.size,
|
||||
price: item.price,
|
||||
currency: item.currency,
|
||||
};
|
||||
}
|
||||
|
||||
onSwipeStart(itemID: number, event: TouchEvent): void {
|
||||
const startX = event.touches[0].clientX;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user