I'm currently building an ecommerce shop app for my portfolio and I'm in this following situation.
User selects an item and adds it to cart and they add the same item to the cart again. Now when they want to remove one item all the same items are being removed. I'm currently using filter method and obviously filter method is doing it's job.
Can anyone please tell me how I can remove one product from my cart, without removing all of its type?
Thank you for your time.
Here is the sample of the array which I want to filter.
selectedProducts = [
{
id: 12,
sku: 12064273040195392,
title: "Cat Tee Black T-Shirt",
availableSizes: ["XS", "S"],
style: "Black with custom print",
price: 10.9,
imgUrl: photo1,
currencyId: "GBP",
currencyFormat: "£",
isFreeShipping: true
},
{
id: 13,
sku: 51498472915966370,
title: "Dark Thug Blue-Navy T-Shirt",
availableSizes: ["M"],
style: "Front print and paisley print",
price: 29.45,
imgUrl: photo2,
currencyId: "GBP",
currencyFormat: "£",
isFreeShipping: true
},
{
id: 12,
sku: 12064273040195392,
title: "Cat Tee Black T-Shirt",
availableSizes: ["XS", "S"],
style: "Black with custom print",
price: 10.9,
imgUrl: photo1,
currencyId: "GBP",
currencyFormat: "£",
isFreeShipping: true
} ];