Hi
I am trying to understand how to write a If and Else statement correctly regarding sale tax or tax exemptions on certain items for example fruits.
For example:
Here is a demo check out:
- QTY--items - Price - Total
- 6 apple - $0.89 (each) = $5.34
- 6 orange - $0.89 (each) = $5.34
- 6 Kiki - $0.89 (each) = $5.34
- 8 tomato - $0.89 (each) = $7.12
- 6 banana - $0.89 (each) = $5.34
- 8 onion - $0.89 (each) = $7.12
- 6 lettuces - $0.89 (each) = $5.34
Overall Total : $40.94
Here is a sale tax I wrote for CT which is 8.75%
if ($sstat == "CT"){$taxx = round($totalCost * .08875,2);}
How do I write if the fruits(items) cost over $30 there no exemption but if the fruits(items) cost less than $30 is exemption.
The sale tax for the item that is less than $30 is 4.5%.
Back to the code that I wrote above now I add the following line:
if ($sstat == "CT"){$taxx = round($totalCost * .08875,2);}
else if ($totalCost > 0 && $totalCost <= 50){$taxx = round($totalCost * .00475,2);}
Here is the question about how to exempted foods.
I take away tomatos, onions and lettuces because their not fruits.
But the apples, oranges, kiki and bananas are fruits.
The total cost for the fruits that I mention above is $21.36.
It's less than $30 so it's exempted and the sale tax is 4.5%
How do I separate the fruits and vegatables above the demo check out?
How do I add or write the code again? Here is it again
if ($sstat == "CT"){$taxx = round($totalCost * .08875,2);}
else if ($totalCost > 0 && $totalCost <= 50){$taxx = round($totalCost * .00475,2);}
Do I have to do an 'array' or establish a 'var function' in order to separate the fruits and vegetable? Do I need to create a item# to separate the fruits and vegetable? I really do appreciate if someone explained to me how write this correctly? `