Guest Posted October 7, 2007 Share Posted October 7, 2007 In my heavily modified store, I have been working on my own version of a county/city tax mod based off the zone_id, but without taxing the taxes. (I need to be able to charge sales tax in 4 states plus the respective counties and cities. [And to make it even easier, one state does not allow sales tax on shipping charges.]) The mod seems to work okay when there is only one item in the shopping cart. The sales tax display shows the taxing authorities and correct amount. However, when 2 or more items are in the cart, checkout_confirmation and all order copies show the sales tax for the last item only yet still computes the total tax correctly and adds it correctly into the total. (I am also having problems with the shipping charges not always being taxed correctly. I think this is probably due to variable name mix-up elsewhere. Currently those changes are commented out so as to work on one problem at a time.) I need help in figuring why the sales tax display is incorrect when 2 or more items are in the cart. My code changes in functions/general.php are: // Returns the tax rate for a zone / class // TABLES: tax_rates, zones_to_geo_zones function tep_get_tax_rate($class_id, $country_id = '$customer_country_id', $zone_id = '$customer_zone_id', $county_id = '$customer_county_id', $city_id = '$customer_city_id') { global $customer_zone_id, $customer_country_id, $customer_county_id, $customer_city_id; $tax_multiplier =0; $city_taxquery = tep_db_query("select tax_rate from " . TABLE_CITY_TAX_RATES . " where city_id = '" . $city_id . "'"); if (tep_db_num_rows($city_taxquery)) { $city_tax_query = tep_db_fetch_array($city_taxquery); $city_taxrate = $city_tax_query['tax_rate']; $tax_multiplier += ($city_taxrate / 100); } $county_taxquery = tep_db_query("select tax_rate from " . TABLE_COUNTY_TAX_RATES . " where county_id = '" . $county_id . "'"); if (tep_db_num_rows($county_taxquery)) { $county_tax_query = tep_db_fetch_array($county_taxquery); $county_taxrate = $county_tax_query['tax_rate']; $tax_multiplier += ($county_taxrate / 100); } $tax_query = tep_db_query("select sum(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za on (tr.tax_zone_id = za.geo_zone_id) left join " . TABLE_GEO_ZONES . " tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '" . (int)$country_id . "') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '" . (int)$zone_id . "') and tr.tax_class_id = '" . (int)$class_id . "' group by tr.tax_priority"); if (tep_db_num_rows($tax_query)) { while ($tax = tep_db_fetch_array($tax_query)) { $tax_multiplier += 1.0 + ($tax['tax_rate'] / 100); } return ($tax_multiplier - 1.0) * 100; } else { return 0; } } //// // Return the tax description for a zone / class // TABLES: tax_rates; function tep_get_tax_description($class_id, $country_id, $zone_id, $county_id=0, $city_id=0) { $tax_description = ''; $city_taxquery = tep_db_query("select tax_description from " . TABLE_CITY_TAX_RATES . " where city_id = '" . $city_id . "'"); if (tep_db_num_rows($city_taxquery)) { $city_tax_query = tep_db_fetch_array($city_taxquery); $tax_description .= $city_tax_query['tax_description'] . ' + '; } $county_taxquery = tep_db_query("select tax_description from " . TABLE_COUNTY_TAX_RATES . " where county_id = '" . $county_id . "'"); if (tep_db_num_rows($county_taxquery)) { $county_tax_query = tep_db_fetch_array($county_taxquery); $tax_description .= $county_tax_query['tax_description'] . ' + '; } $tax_query = tep_db_query("select tax_description from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za on (tr.tax_zone_id = za.geo_zone_id) left join " . TABLE_GEO_ZONES . " tz on (tz.geo_zone_id = tr.tax_zone_id) where (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = '" . (int)$country_id . "') and (za.zone_id is null or za.zone_id = '0' or za.zone_id = '" . (int)$zone_id . "') and tr.tax_class_id = '" . (int)$class_id . "' order by tr.tax_priority"); if (tep_db_num_rows($tax_query)) { while ($tax = tep_db_fetch_array($tax_query)) { $tax_description .= $tax['tax_description'] . ' + '; } $tax_description = substr($tax_description, 0, -3); return $tax_description; } else { return TEXT_UNKNOWN_TAX_RATE; } } //// I tried highlighting the main changes, but no highlighting in the cited code section. If you have any ideas or suggestions, I'm all ears. Or to paraphrase all of the above: HELP!! Doug Quote Link to comment Share on other sites More sharing options...
Guest Posted October 10, 2007 Share Posted October 10, 2007 Found the problem, it stemmed from a mis-install of another contribution. I still find some of the taxation code mystifying. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.