Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Local, City, County Sales Tax and Taxes


Guest

Recommended Posts

For the record, I have read all the posts on sales tax and there seems to be occasional confusion on tax collecting. The 'general' rule for sales tax in the USA is you must collect sales tax for ANY sales to customers in the state you have a physical office in and collect local tax for any customer who you ship to in the city or county you are in.

 

Requirement: We are in the city and county of Denver, Colorado. This requires us to have 2 different tax 'rates'. One for anyone residing in the state of Colorado and another for anyone residing in the city and county of Denver.

 

Problem: OSCommerece tax zones only use 'country' and 'state' when creating a new zone, I need it to look at the 'country', 'state' and 'city', thus creating a 3 'zone' system. Or it can only look at 'state' and 'city', but I suspect that if even harder...?

 

Solution?: I am not our web-admin/programmer, and as great as he is, eCommerce is not his calling. I am trying to figure out if this is something I need to configure somewhere or the code needs to be massaged so it recognizes 3 zones. It it's a config. issue, I would love a pointer or brief tutorial if you have time. If I know it's a massaging code issue, at least I can help him do it and if you have any pointers, that would be great!

 

I am hoping someone out there has either addressed this problem or knows how to. I cannot imagine all the users here in the United States not having already solved this since it's the law.

Link to comment
Share on other sites

Ok everyone, I have a potential "temp" solution to this, but I need help from someone more knowledgable than me. If it works it could really help a whole lotta people. Here's the idea...

 

In the includes/functions/general.php file, there is a function which returns the tax rate for a zone/class. What I'm proposing is to create an IF/ELSE scenario in there that calls to the "entry_city" field of the "address_book" table for a customer, and if the entry equals say "Denver", then skips the normal zone/class ID return code and simply returns a specific ID code number that has been manually input into the "Zone" table for a zone entry created in the Admin menu.

 

For example: I create a Denver Zone in the admin area for Zones, and then go into the Database with PhpMyAdmin and give it a Zone ID of "999." Then in the "general.php" file there is an If/Else command that "If" the customer ID's "entry_city" in the address book equals "Denver", then Zone ID "999" is returned; otherwise (else) the standard Zone ID return code is processed.

 

Here is the return zone/class ID code from the general.php file:

////

// 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;



   if ( ($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;

   }

 }

 

It would only work for the specific city listed in the general.php file, but "Denver" could be replaced with anything. This solution would bypass the need to create new columns/fields in the "zones," "zones_to_geo_zones", and "address_book" tables of the database. Otherwise we have to completely rewrite the code across a ton of files and add a "city_id" field to go along with "countries_id" and "zones_id".

 

Anybody have an idea how to approach this? It's just beyond my current PHP/Mysql programming ability. It doesn't have to be pretty - just work.

 

:?:

Link to comment
Share on other sites

Is it possible to have States/Zones setup as follows:

 

State

State, City 1

State, City 2 (if required?)

 

(replace State and City with appropriate names)

 

If I understand correctly you do not need to have a complete list of cities in a state, just the few where taxes are applicable.

:heart:, osCommerce

Link to comment
Share on other sites

Is it possible to have States/Zones setup as follows:

 

State

State, City 1

State, City 2 (if required?)

 

(replace State and City with appropriate names)

 

If I understand correctly you do not need to have a complete list of cities in a state, just the few where taxes are applicable.

 

This seems like the simple solution for this problem. Does it work with the latest snapshot 5/1/2003?

Link to comment
Share on other sites

Is it possible to have States/Zones setup as follows:

 

State

State, City 1

State, City 2 (if required?)

 

Well I tried that approach since it was suggested by others, and unless I did the whole thing incorrectly, or am totally misunderstanding what you're suggesting, this isn't viable because the USER selects their tax rate in a drop down box. This isn't an option... dishonest people will choose the 50% less State tax alone; and some honest people in suburbs of the city but not under the tax zone won't understand and will be charged 50%more tax inappropriately.

 

The second problem with this is that we manually have to go through all of these sales so that our accounting is accurate - if some didn't pay, it comes out of our pocket; if they paid and weren't supposed to we have to send them a refund. To either charge someone the wrong tax, or to not charge them tax is a criminal offense here. It's simply not the right thing to do, and is an accounting nightmare.

 

Harold... if I'm misunderstanding the solution you are offering than please correct me and let me know how to do this right. I've considered all of the options I could find, yet still have not found an appropriate solution.

Link to comment
Share on other sites

You know, I am completely stunned that this isn't getting more response from the community. I notice it got moved again - maybe nobody is seeing this thread? It was orginally in the "Installation and Configuration" forum, then got moved over to "Contributions," and now is here in the "Features" forum.

 

Man this is frustrating... I have to find a soution for this problem this week or I'm probably going to have to uninstall and start over with a different cart solution - and that's not a casual thing. I just can't believe that nobody cares about this. Risking legal action against one's business is a really big deal.

 

Ok, one more time in case I simply haven't been clear enough...

 

The Issue

 

In Colorado, the city of Denver requires that we charge those within the Denver tax zone 7.2%, and those outside the Denver tax zone yet in the state of Colorado 2.9%. Here is the problem...

 

1) If we charge everyone in the State 7.2%, it's against the law.

 

2) If we don't visibly post at the time of checkout the amount of city and/or state tax the customer is paying as seperate line items, it's against the law.

 

3) We can't use the Drop Down selection option for tax. This leaves it up to the customer to choose the proper option. The problems with this are: a) they might not see the city tax option; B) they could simply choose the 2.9% even if they live in Denver; c) if they live in a suburb of Denver not under Denver tax law, then they might not understand and select the 7.2% option accidentally; and d) it's an accounting nightmare.

 

All three of these possibilites put us in violation of Denver Tax Ordinances. Yes... it's entirely possible that the local government might look the other way and say nothing. But if they don't, then it creates a situation that could possibly cost us a lot of money in legal proceedings - or in the worst case scenario, our business altogether. It's not worth the risk.

 

The Solution

 

Except for adding new fields/columns to the database and changing the code throughout several files, there is no way to do a 3-zone tax fix to OsC that I'm aware of.

 

The solution I've suggested above is a "hack" that could be a temporary solution for a lot of people. I'm working on it myself, trying to learn how I could apply it by researching in books and online. It's just beyond my current knowledge and ability, which is why I'm asking for help from the community. Somebody out there knows how to do this by just giving it ten minutes of thought. It's taken me days, and I still haven't found it.

 

Here's a better explanation...

 

What it does is simply change a paragraph in the "functions/general.php" file so that an If/Else command is created which checks the customer's "entry_city" input in the database, and if it equals something specific, automatically pulls up a single custom Tax Zone which has the combined State and City tax in a single line item.

 

It does use the solution offered above to create a "State, City 1" Zone for our custom zone - but that's only part of it. We have to go into the database and change our custom zone's ID to "999". Then the hacked general.php file would check the user's city and if it equals what the general.php file asks for, then it goes and retrieves zone "999" only for the customer at checkout.

 

Now it doesn't place State and City tax as seperate line items... but the local government will probably be more likely to let it slide since: a) it is charging city residents the proper total, B) it is informing them that they are paying City tax on the frontend at the time of checkout, c) it doesn't charge people outside of the city the wrong tax, 5) it doesn't leave it up to the customer by giving them more than one option, and 6) it helps keep our accounting correct.

 

I hope that makes this a little clearer, and that it gets some response. The solutions being offered on the forums to this problem are not solutions so far. One can't charge everyone the same tax rate and clean it up in the wash later without risking legal proceedings. Nor can one use the Drop Down customer selection option without also risking legal action.

 

There has to be another way.

Link to comment
Share on other sites

I agree with you totaly. I'm in California and here we have to charge the local county tax which is .085 if the order is delivered in our county all the other orders that are delivered in CA are charged .0725. I feel for you having a 3 tier tax structure. I too refuse to get into tax trouble and am making sure I follow the tax laws to the letter. I had to switch to another shopping cart for now, I am hoping to be able to use OSC for my future stores. I also have experienced to many problems with OSC connecting to authorize.net. This is also an issue that goes unaddressed. I am hanging in here and hoping I may contribute somehow to these issues. For now though all seems lost.

Link to comment
Share on other sites

I'm pulling this out of a hat, but since you're only concerned with Denver, could you just hard code the solution so that when it goes to get the tax rate, it takes the customers id, checks what city they are in and if it's denver than tack on the additional percentage?

If every member of this board donated $1 to the dev team, that would be over $11,000.00. Don't you think this cart is worth at least a $1????

Link to comment
Share on other sites

If that is the case, give the following code a try. No guarantees that it will work, but it will be a starting point at least.

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



// 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'] == 'denver') {

 return 7.9; // Not sure what the usual return is, but think it should be

              // a value similar to this.

}

 

You could place this right after the other variable declarations at the thop of the function so it always checks this first without running through the whole thing for nothing. Hope that helps.

If every member of this board donated $1 to the dev team, that would be over $11,000.00. Don't you think this cart is worth at least a $1????

Link to comment
Share on other sites

The top of the tep_get_tax_rate function located in general.php to be more specific.

If every member of this board donated $1 to the dev team, that would be over $11,000.00. Don't you think this cart is worth at least a $1????

Link to comment
Share on other sites

I'm pulling this out of a hat, but since you're only concerned with Denver, could you just hard code the solution so that when it goes to get the tax rate, it takes the customers id, checks what city they are in and if it's denver than tack on the additional percentage?

 

That's the idea exactly. I'm going to try your code right now and see if it works. Thank you very much for responding. I'll post back and let you know what happens.

 

:)

Link to comment
Share on other sites

Oh wow... it worked!!!

 

:D :D :D

 

Ocularmagic, you are magic.

 

It needed some editing of course, but it was the start. I never would've figured this out myself.

 

Ok, so I copied the entire If statement 2 more times and changed them to elseif instead for a running if statement, and assigned each to 'Denver', 'denver', and 'DENVER' respectively to cover all case situations. Then I input '7.3000' for each 'return', since this was the format that the tax_rate table in the database listed for our state tax_rate. Our city tax is actually 7.3%.

 

Next, I took the same code and copied it into the next section for returning the tax rate description. After modifying them each a little bit, and defining a new TEXT_CUSTOM_TAX_RATE field in the english.php file, I was able to get it to also return the description "Denver, CO combined City & State Tax of 7.3%."

 

We tested it with a customer account in Denver, and one in an outlying suburb of Erie. The Denver customer returned the proper city/state tax rate, and the Erie one only returned the State tax.

 

Now I don't have to dump the cart! I immediately called the business guys and they were ecstatic - we were all starting to get a little bummed out 'cause we thought we would have to start over.

 

The only problem is if someone from a city called Denver outside of Colorado places an order, then they will be charged the tax as well. But the chances of that happening are worth the risk... as one of the business guys said, "That's like preparing for lightning."

 

I could see modifying the code here to check for both the City name and State name, and am going to look at the code a little closer to see how that would work. But otherwise, I'm very happy right now.

 

I could see easily modifying this to work for multiple city listings by adding addtional 'elseif' statements, and possibly for multiple Zip Code listings as well by replacing each appearance of the 'city' term below with 'postcode' instead. This won't work for counties since there isn't an 'entry_county' column in the address_book database table for members. But...

 

If one were to enable 'suburbs' in their customers' accounts and change all of the language files where the word 'suburb' appeared to say 'county' instead, and then replaced all of the 'city' terms below with 'suburb'... one could easily modify this for use with a county or two. This could be a hardcoded temp solution for this with carts in California.

 

Here is the code, and it needs to be put in place of lines 268 - 315 in the includes/functions/general.php file (both the 'return tax rate' and 'return tax description' sections). Then you'll want to replace all instances of 'Denver' with your city, and input your custom tax rate as well.

 

////

// 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'] == 'Denver') { 

   return 7.3000; // Input your custom tax rate here	

} 



elseif ($customer_city['entry_city'] == 'denver') { 

   return 7.3000; // Input your custom tax rate here 

} 



elseif ($customer_city['entry_city'] == 'DENVER') { 

   return 7.3000; // 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'] == 'Denver') { 

   return TEXT_CUSTOM_TAX_RATE; // Input your custom tax description here 

}	

elseif ($customer_city['entry_city'] == 'denver') { 

   return TEXT_CUSTOM_TAX_RATE; // Input your custom tax description here 

}	

elseif ($customer_city['entry_city'] == 'DENVER') { 

   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;

   }

 }

 

Next, you'll want to open the includes/languages/english.php file and around line 316 add this text...

 

define('TEXT_CUSTOM_TAX_RATE', 'Denver, CO combined City & State Tax of 7.3%');

 

Of course you'll want to put your own text in place of 'Denver, CO...' for whatever your tax rate and location.

 

And again... if one were to replace all instances of 'city' in the code above with 'postcode' or 'suburb' (ie., '$customer_city' to '$customer_postcode', and 'entry_city' to 'entry_postcode', etc.), then they could apply this to Zip Codes and suburbs as well. If one were to enable the suburb option in customer accounts, and then replace all instances of the word 'suburb' in the various language files with 'county', then one could conceivably do this on a county basis as well.

 

*Note - this is a hack to a core file, and is not accessible or editable from the Administrative Menu. All of the changes take place in the general.php file. When upgrading to newer versions of this file, the code will have to be added again; and there is no guarantee that future releases of OsCommerce will allow for this hack to work.

 

What OsCommerce really needs is to create a 4-way matrix for Tax Zones, instead of a simple 2-way matrix - Country, State, County/Parish, and City.

 

Anyway... Yeah!!!! It worked!!!

 

:wink:

 

Ocularmagic... send me a PM with a mailing address and I'll send you either one of my CDs or a discount coupon at our online store.

Link to comment
Share on other sites

Well it appears that there are actually a LOT of Denver's in the USA - almost one for every state. So I'm going to try and figure out how to modify this to lookup both the City and the State - but since the 'entry_state' column of the address_book table is blank, it will have to be based on the entry_zone_id column instead.

 

I tried one attempt already, but it didn't work. I'm going to eat dinner and then approach it again later tonight. It can't be that difficult to modify.

Link to comment
Share on other sites

You know what, I never even noticed that the state field is empty. I wonder what it's there for then? Anyway, it doesn't really matter as you can get the state of the customer by checking their entry_zone_id in the address book table against the zone_id in the zones table and then get the state that way. For example the entry_zone_id is 13, so you go to the zones table and look up the zone_id that is equal to 13, then pull out the name. Well I guess you don't even have to do that much if you are going to hard code it. Just pull out the entry_zone_id along with entry_city then just check if it's 13 when you check the city. If it is, then it's in Colorado. So your code changes would look like the following:

 

For the query you just add entry_zone_id.

$customer_city_query = tep_db_query("select entry_city, entry_zone_id from " . TABLE_ADDRESS_BOOK . " where customers_id =  '" . $customer_id . "'");

 

And for the if statements you add the theck for it also.

 

if (($customer_city['entry_city'] == 'Denver') && ($customer_city['entry_zone_id] == 13)) {

 

That should be it, then it will only enter the ifs for Denver Colorado. Let me know if this works out. Check to see what your zone_id is for Colorado, it was 13 in my db. You should really not have all those ifs because you want every case. Who knows if someone will come along and accidentallly have their caps lock on for the first half of DENver and figure that your cart will fix it. It would just be a simple function call and it would eliminate a lot of bloated code. I'm sure I'll run across it and I'll post it here when I do. This should work for now though. Glad I could help.

If every member of this board donated $1 to the dev team, that would be over $11,000.00. Don't you think this cart is worth at least a $1????

Link to comment
Share on other sites

Great. Thanks for this... I'm going to try it in just a little bit. I wasn't able to get back to it last night. I actually tried something similar to this yesterday, but it was just a little off in the syntax from what you have here and didn't work right. I'll post back after I try your version.

 

How about by zipcode?

 

Unfortunately the Denver tax zone crosses several zip codes, splitting them in half. So that won't work for us. It might for someone else though.

 

You should really not have all those ifs because you want every case.

 

Yeah, I get that. But this covers the main possibilities for now, and makes everyone happy. I will run a search for it myself as well later, and post back any findings to this thread.

 

Be back soon...

Link to comment
Share on other sites

The function is strtoupper, or strtolower which ever you prefer. Here is the example from php.net:

 

$str = "Mary Had A Little Lamb and She LOVED It So";

$str = strtoupper($str);

print $str; # Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO

If every member of this board donated $1 to the dev team, that would be over $11,000.00. Don't you think this cart is worth at least a $1????

Link to comment
Share on other sites

The function is strtoupper, or strtolower which ever you prefer. Here is the example from php.net:

 

$str = "Mary Had A Little Lamb and She LOVED It So";

$str = strtoupper($str);

print $str; # Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO

 

How would this get inserted into the code?

Link to comment
Share on other sites

Thank you, thank you and thank you. The tax issue has finally been solved! :D

 

I am also lucky because there is only one San Francisco that I know of - which means less code to modify :wink:

 

Wow I got the authorize.net connection to finally work correctly and now the tax nightmare gone. Yes Virginia there really is a Santa Claus.

 

Thanks everyone. You have been such a blessing in my life.

Link to comment
Share on other sites

The function is strtoupper, or strtolower which ever you prefer. Here is the example from php.net:

 

$str = "Mary Had A Little Lamb and She LOVED It So";

$str = strtoupper($str);

print $str; # Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO

 

How would this get inserted into the code?

 

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

 

That would change the city to all upper case.

If every member of this board donated $1 to the dev team, that would be over $11,000.00. Don't you think this cart is worth at least a $1????

Link to comment
Share on other sites

Special thanks goes to Ocularmagic for making this code possible. He made it happen, I simply asked the questions and put it all together.

 

Thanks for the credit in the install file, I appreciate it.

If every member of this board donated $1 to the dev team, that would be over $11,000.00. Don't you think this cart is worth at least a $1????

Link to comment
Share on other sites

  • 2 weeks later...

I have tried to use this code snippet to create all caps

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

into the following code but can't seem to get it to work.

//// 

// 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; 

   } 

 }

 

Any ideas?

Link to comment
Share on other sites

Jeff, can you give a little more info. Did it give you an error, did the function not return correctly? What exactly happened that told you it wasn't working? If you insert:

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

 

After:

$customer_city = tep_db_fetch_array($customer_city_query);

 

In both places, it should work, as far as I can tell.

If every member of this board donated $1 to the dev team, that would be over $11,000.00. Don't you think this cart is worth at least a $1????

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...