Tax adding repeatedly :(
Posted: Thu Mar 16, 2006 4:05 pm
Hey Guys,
I have a system developed where the script checks the Product CAT Id against a DB ... if the Cat is returned as 2, then it adds tax (17.5%)... but when I select a tax-able item and a non-tax-able item... it adds it up for both..
Code:
Thanks for any help! 
I have a system developed where the script checks the Product CAT Id against a DB ... if the Cat is returned as 2, then it adds tax (17.5%)... but when I select a tax-able item and a non-tax-able item... it adds it up for both..
Code:
Code: Select all
foreach ($_SESSION['purchase_prods'] AS $arr){
$tot+=$arr[1] * $arr[2];
$qry=mysql_query("SELECT cat.catid AS catid FROM Products AS p, categories AS cat WHERE p.Product_ID='$arr[0]' AND p.Product_Cat_ID=cat.catid AND cat.catid='2'") OR DIE (mysql_error());
$result=mysql_num_rows($qry);
switch ($result){
case '1':
$vat=(.175 * $tot);
$hax=$sub_total+$vat;
$vat=number_format($vat,2,'.','');
$sub_total=$hax;
break;
default:
$vat='0.00';
break;
}
}
$sub_total=number_format($sub_total, 2, '.', "");