Ok simple compare the value of what ever is being used as the cloth type source. If your using data retrieved from a database table wrap the if statement in there so that it does it for each instance of the data or else just us a plan old if statement. The functions.php is so you can add most of your logic in functions so you dont have to recode everything every time you want to use it. Lets do a hypothetical situation.
General if statement checking if value is one or the other. You need to specify each time what variable and value pairs are being evaluated. I noticed you used
if($clothType == "AAA" || "BBB" || "CCC") which explains why its not working. It would be nice if it did work that way but it does not see below how it should be done.
PHP Code:
<?php
$clothType = $_POST['cloth_type'];
if($clothType == "AAA" || $clothType == "BBB" || $clothType == "CCC")
{
// code to execute
}
else
{
//value is not one for the three do another calculation here
}
?>
You can make a function for calculating the total cost easy
PHP Code:
<?php
function calculateCost($itemAmt,$Cost,$Tax,$preTax="false",$round="true")
{
//make sure the values are numeric
if(!is_numeric($itemAmt) && !is_numeric($Cost) && !is_numeric($Tax))
{
// all items need to be numeric of else this will not work
return "NaN";
}
else
{
// everything is a number lets roll
$subTotal = $itemAmt * $Cost;
$totalAmt = $subTotal * $Tax;
if($preTax == "true")
{
return $subTotal;
}
else
{
if($round == "true")
{
return round($totalAmt);
}
else
{
return $totalAmt;
}
}
}
?>
This function will make doing total calculations simple just call the function and fill in the params. I think I already posted a percentage function but yeah anything that is not fixed you should turn into a function to save coding time and file bloat.