Im having a bit of an issue and im not sure where I am going wrong.
I have a Map which is bringin in prices, based on the ID of the product I need to add a discount or skip it.
let discountPrice = !prod.ProductID.startsWith('BGM', 'S11', 'BGP') && prod.CurrentPrice.toString().endsWith('97') ? parseFloat(prod.CurrentPrice) * 0.05 : !prod.ProductID.startsWith('BGM', 'S11', 'BGP') ? parseFloat(prod.CurrentPrice) * 0.15 : 0
let dp = usdNumber.format( discountPrice )
let finalPrice = parseFloat(prod.CurrentPrice) - parseFloat(discountPrice)
let totalWithQ = finalPrice * prod.Quantity
let fp = usdNumber.format( totalWithQ )
This works great for BGM it will skip the discount but for S11 and BGP it will still apply the discount where if the product ID has BGM, S11 or BGP i want it to skip.
Am I using startsWith wrong? Can it not pass multiple things through it and have it loop through per argument?
{User?.Cart && User?.Cart.length > 0 && (
<>
<Table>
<Thead>
<Tr className="text-left border-b-2 border-blue">
<Th className="py-5">Product</Th>
<Th className="py-5">Price</Th>
<Th className="py-5">Overstock Discount Per Item</Th>
<Th className="py-5">Quantity</Th>
<Th className="py-5">Total Price</Th>
<Th className="py-5">Controls</Th>
</Tr>
</Thead>
<Tbody>
{User.Cart.map((prod, i) => {
let discountPrice = !prod.ProductID.startsWith('BGM', 'S11', 'BGP') && prod.CurrentPrice.toString().endsWith('97') ? parseFloat(prod.CurrentPrice) * 0.05 : !prod.ProductID.startsWith('BGM', 'S11', 'BGP') ? parseFloat(prod.CurrentPrice) * 0.15 : 0
let dp = usdNumber.format( discountPrice )
let finalPrice = parseFloat(prod.CurrentPrice) - parseFloat(discountPrice)
let totalWithQ = finalPrice * prod.Quantity
let fp = usdNumber.format( totalWithQ )
return (
<Tr
key={`key-cart-prod-${i}`}
className="border-b border-opacity-50 border-Blue"
>
<Td className="py-5">
<Link href={`/product/${prod.Slug}`}>
<a>
{`${prod.Description} (${prod.ProductID})`}
</a>
</Link>
</Td>
<Td className="py-5">{`$${prod.CurrentPrice}`}</Td>
<Td className="py-5">{`${dp}`}</Td>
<Td className="py-5">{`Qty: ${prod.Quantity}`}</Td>
<Td className="py-5">{`${fp}`}</Td>
<Td className="py-5" style={{width: '1%', whiteSpace: 'nowrap'}}>
<RemoveFromCart ProductID={prod.ProductID} />
</Td>
</Tr>
)
})}
</Tbody>


