RE: Local, City, County Sales Tax and Taxes
jgkiefer <[email protected]>
| Newsgroups | gmane.comp.web.oscommerce.features |
|---|---|
| Message-ID | <db3e12209f987927cfbb14a0ab9e87a0@osCommerce-Forums> |
This message was sent from: Features
http://forums.oscommerce.com/viewtopic.php?p=172570#172570
----------------------------------------------------------------
I have tried to use this code snippet to create all caps
[code]$customer_city['entry_city'] = strtoupper($customer_city['entry_city']); [/code]
into the following code but can't seem to get it to work.
[code]////
// Returns the tax rate for a zone / class
// TABLES: tax_rates, zones_to_geo_zones
function tep_get_tax_rate($class_id, $country_id = -1, $zone_id = -1) {
global $customer_zone_id, $customer_country_id, $customer_id;
$customer_city_query = tep_db_query("select entry_city from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . $customer_id . "'");
$customer_city = tep_db_fetch_array($customer_city_query);
// Must take $customer_city['entry_city'] and make it either all caps or all
// lower case because some customers capitalize and some don't.
// I don't know the function off the top of my head.
if ($customer_city['entry_city'] == 'San Francisco') {
return 8.5000; // Input your custom tax rate here
}
elseif ($customer_city['entry_city'] == 'san francisco') {
return 8.5000; // Input your custom tax rate here
}
elseif ($customer_city['entry_city'] == 'SAN FRANCISCO') {
return 8.5000; // Input your custome tax rate here
}
elseif ( ($country_id == -1) && ($zone_id == -1) ) {
if (!tep_session_is_registered('customer_id')) {
$country_id = STORE_COUNTRY;
$zone_id = STORE_ZONE;
} else {
$country_id = $customer_country_id;
$zone_id = $customer_zone_id;
}
}
$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 = '" . $country_id . "') AND (za.zone_id IS NULL OR za.zone_id = '0' OR za.zone_id = '" . $zone_id . "') AND tr.tax_class_id = '" . $class_id . "' GROUP BY tr.tax_priority");
if (tep_db_num_rows($tax_query)) {
$tax_multiplier = 0;
while ($tax = tep_db_fetch_array($tax_query)) {
$tax_multiplier += $tax['tax_rate'];
}
return $tax_multiplier;
} 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) {
global $customer_id;
$customer_city_query = tep_db_query("select entry_city from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . $customer_id . "'");
$customer_city = tep_db_fetch_array($customer_city_query);
$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 = '" . $country_id . "') AND (za.zone_id IS NULL OR za.zone_id = '0' OR za.zone_id = '" . $zone_id . "') AND tr.tax_class_id = '" . $class_id . "' order by tr.tax_priority");
if ($customer_city['entry_city'] == 'San Francisco') {
return TEXT_CUSTOM_TAX_RATE; // Input your custom tax description here
}
elseif ($customer_city['entry_city'] == 'san Francisco') {
return TEXT_CUSTOM_TAX_RATE; // Input your custom tax description here
}
elseif ($customer_city['entry_city'] == 'SAN FRANCISCO') {
return TEXT_CUSTOM_TAX_RATE; // Input your custom tax description here
}
elseif (tep_db_num_rows($tax_query)) {
$tax_description = '';
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;
}
} [/code]
Any ideas?