0byt3m1n1
Path:
/
data
/
17
/
1
/
18
/
11
/
1670011
/
user
/
1801231
/
htdocs
/
functions
/
[
Home
]
File: fnc.php
<? function calculate_shiping($total_product_weight,$place,$quantity) { //echo "first line :".$total_product_weight."/".$place."/".$quantity."<br>"; $q_ship_config="select * from configuration where configuration_id=4"; $r_ship_config=mysql_query($q_ship_config); if(!$r_ship_config) { echo mysql_error(); } $row_ship_config=mysql_fetch_array($r_ship_config); $config_value=$row_ship_config['configuration_value']; if($config_value==1 || $config_value==2) { echo "<br>Config value =".$config_value."<br>"; $q_zone_rate="select * from shipping_zone where shipping_zone_name='".strtolower($place)."'"; $r_zone_rate=mysql_query($q_zone_rate); if(!$r_zone_rate) { echo mysql_error(); } $row_zone_rate=mysql_fetch_array($r_zone_rate); $rate=$row_zone_rate['shipping_zone_price']; //echo "quantity :".$quantity; if($config_value==1) { $shipping_cost=$rate; } else { $shipping_cost=$rate*$quantity; } } else if($config_value==3 || $config_value==4) { $q_zone_rate="select * from shipping_zone where shipping_zone_name='".strtolower($place)."'"; $r_zone_rate=mysql_query($q_zone_rate); $row_zone_rate=mysql_fetch_array($r_zone_rate); $weight_ratio=$row_zone_rate['shipping_weight_ratio']; $price_ratio=$row_zone_rate['shipping_price_ratio']; $no = count(explode(":",$weight_ratio)); $no=$no-1; $weight=explode(":",$weight_ratio); $price=explode(":",$price_ratio); for($i=0;$i<=$no;$i++) { if($config_value==3) { if($total_product_weight < $weight[0]) { $shipping_cost=$price[0]; break; } else if(($total_product_weight > $weight[$i]) && ($total_product_weight <= $weight[$i+1])) { $shipping_cost=$price[$i+1]; break; } } else if($config_value==4) { //echo $total_product_weight."/".$weight[0]."/".$price[0]."/".$quantity; if($total_product_weight < $weight[0]) { $shipping_cost=$price[0]*$quantity; break; } else if(($total_product_weight > $weight[$i]) && ($total_product_weight <= $weight[$i+1])) { $shipping_cost=$price[$i+1]*$quantity; break; } } } } //echo $shipping_cost; return $shipping_cost; } function calculate_tax($amount, $dstate) { $tax=0; if($dstate=="Florida") { $q_tax_config="select * from configuration where configuration_id=8"; $r_tax_config=mysql_query($q_tax_config); if(!$r_tax_config) { echo mysql_error(); } $row_tax_config=mysql_fetch_array($r_tax_config); $config_value=$row_tax_config['configuration_value']; $tax=$amount*$config_value/100; //$tax=number_format($tax,2); } return $tax; } ?>