This is my tax_rate tabel:
3 1 - ESP 1276250954 0.1600
6 1 38 ESP 1276527387 0.0000
7 1 35 ESP 1276527405 0.0000
When I change the shipping address to state 38, the taxes are correct, but if I change the adress to 35 then I get the 0.16% tax.
What I found is that in ps_product, at line 1460 there is:
" AND (tax_state='$state' OR tax_state=' $state ' OR tax_state='-')";
So in my case it can either return 0.16 or 0, obviously as the state is 35, I want to have 0 tax, what I did is add the following code, that first searches for the specific state_id and then for the general state_id:
$q = "SELECT tax_rate FROM #__{vm}_tax_rate WHERE tax_country='$country'\n";
if( !empty($state)) {
$q1 = $q . " AND (tax_state='$state' OR tax_state=' $state ')";
$db->query($q1);
if ($db->next_record()) {
$_SESSION['taxrate'][$ps_vendor_id] = $db->f("tax_rate");
}else {
$q2 = $q . " AND tax_state='-'";
$db->query($q2);
if ($db->next_record()) {
$_SESSION['taxrate'][$ps_vendor_id] = $db->f("tax_rate");
}else {
$_SESSION['taxrate'][$ps_vendor_id] = 0;
}
}
}else{
$db->query($q);
if ($db->next_record()) {
$_SESSION['taxrate'][$ps_vendor_id] = $db->f("tax_rate");
}else {
$_SESSION['taxrate'][$ps_vendor_id] = 0;
}
}