Web Tool Bag  
Home · Articles · Downloads · Discussion Forum · Web Links · News CategoriesSeptember 09 2010 04:02:28
Navigation
Home
Articles
Downloads
Discussion Forum
Web Links
News Categories
Search
Users Online
Guests Online: 1
No Members Online

Registered Members: 214
Newest Member: aloyskimbe
Forum Threads
Newest Threads
Unix Servers
downloads
Validation on the re...
letters not working
When I input the wro...
Hottest Threads
Installation [11]
Captcha picture d... [4]
Any questions and... [4]
Integrate with Vi... [3]
How to include it? [3]
Latest Articles
PHP obfuscation usef...
Apache2 speed up
How to Optimize Loops
How to Fix Performan...
How to Understand Pe...
City Tax Rates for OsCommerce
City Tax Rates for OsCommerce FIX

in catalog/includes/functions/general.php replace tep_get_tax_rate and tep_get_tax_description functions: (don't use functions in install.txt file, please use functions bellow)

function tep_get_tax_rate($class_id, $country_id = -1, $zone_id = -1) {
global $customer_zone_id, $customer_country_id, $customer_id;

//get customers info
//Zdr Patch
// Taxes are calculated by City Tax Rate according Billing Address
// If needed to be calculated according Shsipping address use $_SESSION['sendto'] is sql query
// $customer_city_query = tep_db_query("select entry_city, entry_zone_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . $customer_id . "'");
$customer_city_query = tep_db_query("select entry_city, entry_zone_id from " . TABLE_ADDRESS_BOOK . " where address_book_id = '" . $_SESSION['billto'] . "'");

$customer_city = tep_db_fetch_array($customer_city_query);
$customer_city['entry_city'] = strtoupper($customer_city['entry_city']);

//set tax rate if city and zone id match
$customer_city_rate_query = tep_db_query("select CITY, RATE from citysalesrate where CITY = '" . $customer_city['entry_city'] . "'");

//Zdr Patch
// if (($customer_city_rate = tep_db_fetch_array($customer_city_rate_query)) && ($customer_zone_id == STORE_ZONE)) {

if ( $customer_city_rate = tep_db_fetch_array($customer_city_rate_query) ) {
return $customer_city_rate['RATE'];
}
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_zone_id;


//get customers info
//Zdr Patch
//Description is shown according Billing Address
// If needed to be shown according Shsipping address use $_SESSION['sendto'] is sql query
$customer_city_query = tep_db_query("select entry_city, entry_zone_id from " . TABLE_ADDRESS_BOOK . " where address_book_id = '" . $_SESSION['billto'] . "'");
$customer_city = tep_db_fetch_array($customer_city_query);
$customer_city['entry_city'] = strtoupper($customer_city['entry_city']);

//set tax description if city and zone id match
$customer_city_rate_query = tep_db_query("select CITY, RATE from citysalesrate where CITY = '" . $customer_city['entry_city'] . "'");
$customer_city_rate = tep_db_fetch_array($customer_city_rate_query);
$customer_city_rate['CITY'] = strtoupper($customer_city_rate['CITY']);


function descr_resultz(){

$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");

return tep_db_num_rows($tax_query);

}

//Zdr Patch
// if (($customer_city_rate['CITY'] == $customer_city['entry_city']) && ($customer_zone_id == STORE_ZONE)) {
if ( $customer_city_rate['CITY'] == strtoupper($customer_city['entry_city']) ) {
return $customer_city_rate['CITY'] . ' TAX ' . $customer_city_rate['RATE'] . '%';

}elseif (descr_resultz()) {

$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");
$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;
}
}

Posted by zdravko on July 11 2008 08:43:58 760 Reads · Print
Ratings
Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Member Poll
Which PHP framework do you preffer?

Symfony

Zend

PHPDevShell

PHP on TRAX

eZ Components

Fusebox

PhpOpenbiz

Prado

QPHP

Seagull

You must login to vote.
Shoutbox
You must login to post a message.

No messages have been posted.
manual submit | PHP Obfuscator
Copyright © 2010 - www.webtoolbag.com