4👍
✅
Just check in cartList array and increment qunatity if it exists
addStorageCart (product) {
var findProduct = this.cartList.find(o => o.id === product.id)
if(findProduct){
findProduct.quantity +=1;
return;
}
this.cartadd.id = product.id;
this.cartadd.name = product.product_name;
this.cartadd.price = product.product_price;
this.cartadd.quantity = 1;
this.cartadd.image = product.product_image;
this.cartList.push(this.cartadd);
this.cartadd = {}
this.storeCart();
}
Source:stackexchange.com