Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Can anyone tell me what I might need to do to modify some PHP code in the CA city tax rate contrib? I need to charge tax by city, and this cotrib has worked well, but I see there are a few cities in CA that have the same name, but they're in different areas and have different tax rates.

 

I want to be able to have osC look at those cities' zip codes, too, not just the city name in order to charge the correct rate. I only need to do this for the few cities that share names.

 

Here's the first part of the code which is in general.php:

 

 

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

//CHANGES BY GILLIAN TO ACCOUNT FOR CITY AND STATE TAX RATE
//echo "send to = ".$_SESSION['sendto']."<br>";  //debugging
$customer_city_query = tep_db_query("select entry_city, entry_zone_id from " . TABLE_ADDRESS_BOOK . " where address_book_id =  '" . $_SESSION['sendto'] . "'");
$address_query = tep_db_fetch_array($customer_city_query);
$cust_city = $address_query['entry_city'];
$cust_entry_zone_id  = $address_query['entry_zone_id'];


if ( ($cust_city == 'Acampo') && ($cust_entry_zone_id == '12') )
{
	return 7.7500;
} //END IF	
elseif ( ($cust_city == 'Acton') && ($cust_entry_zone_id == '12') )
{
	return 7.7500;
} //END IF	
elseif ( ($cust_city == 'Adelanto') && ($cust_entry_zone_id == '12') )
{
	return 7.7500;
} //END IF	
elseif ( ($cust_city == 'Agoura Hills') && ($cust_entry_zone_id == '12') )
{
	return 8.2500;
} //END IF

 

Could I just modify it like this?

 

elseif ( ($cust_city == 'Adelanto') && ($cust_zip_code == '92352') && ($cust_entry_zone_id == '12') )
{
	return 7.7500;
} //END IF

Posted

More info:

 

Here's my modification to the variables:

 

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

//CHANGES BY GILLIAN TO ACCOUNT FOR CITY AND STATE TAX RATE
//echo "send to = ".$_SESSION['sendto']."<br>";  //debugging
$customer_city_query = tep_db_query("select entry_city, entry_postcode, entry_zone_id from " . TABLE_ADDRESS_BOOK . " where address_book_id =  '" . $_SESSION['sendto'] . "'");
$address_query = tep_db_fetch_array($customer_city_query);
$cust_city = $address_query['entry_city'];
$cust_zip_code = $address_query['entry_postcode'];
$cust_entry_zone_id  = $address_query['entry_zone_id'];

 

You'll see I've added $cust_zip_code, which *should* pull the zip code from the ADDRESS BOOK table. (After all, it's doing the same thing with the city and zone ID). As I wrote earlier, I've added the && ($cust_zip_codce = 'xxxxx') to the elseif statement below (I've done this for San Francisco only to test it out).

 

Ideally (using my limited PHP knowledge) I'm assuming for those couple of SF zip codes I've got in my elseif statements, that osC should look for city, zip code, and zone ID. If successful, it should charge the tax rate I've set for those two zip codes.

 

However, my modification doesn't seem to be working. It returns the base CA state tax.

 

When I use other cities that DON'T have the $cust_zip_code in the elseif statement, they are charged the correct city tax rate. THe positive part, is that my modifacations to the code haven't broken anything (except with regard to SF).

 

Does anyone know if there's something else I should do? Is there someplace is the contrib that I need to add this variable (I can't see it if there is). I just want to get this thing working.

 

Thanks!

 

Mike

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...