<?php
$total = 0;
$order = $mysql->get_array($mysql->query("country,discount_value,shipping", "fs_shop_orderdata", "owner = '{$_SESSION['owner']}' AND temp = 'y' LIMIT 1"));
$shipping = $site->shop_settings('home_country,tax_rate,int_deduct_tax');
if($order['country'] != $shipping['home_country'] && $shipping['int_deduct_tax'] == 'Y')
{
//total items
$query = $mysql->query("(price*qty) AS price", "fs_shop_cart", "owner = '{$_SESSION['owner']}' AND temp = 'y'");
while($data = $mysql->get_array($query))
{
$total += $data['price'];
}
$total -= $order['discount_value'];
$total += $order['shipping'];
$tax = $total - $total / (1+$shipping['tax_rate']/100);//work out tax
}
else
{
$tax = 0;
}
$mysql->update("sales_tax", $tax, "fs_shop_orderdata", "owner = '{$_SESSION['owner']}' AND temp = 'y' LIMIT 1");
?>