const getTotalCartAmount=()=>{
let totalAmount=0;
for(const item in cartItems)
{
if(cartItems[item]>0)
{
let itemInfo = all_product.find((product)=>product.id===Number(item))
totalAmount+=itemInfo.new_price*cartItems[item];
}
}
return totalAmount;
}
//all_products file
let all_product = [
{
id: 1,
name: “Striped Flutter Sleeve Overlap Collar Peplum Hem Blouse”,
category: “women”,
image: p1_img,
new_price: 50.0,
old_price: 80.5,
},
{
id: 2,
name: “Striped Flutter Sleeve Overlap Collar Peplum Hem Blouse”,
category: “women”,
image: p2_img,
new_price: 85.0,
old_price: 120.5,
},
{
id: 3,
name: “Striped Flutter Sleeve Overlap Collar Peplum Hem Blouse”,
category: “women”,
image: p3_img,
new_price: 60.0,
old_price: 100.5,
},
Abhishek is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3