Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Dropdown box causing tax problems...


jwsfun

Recommended Posts

I've got both the state and counties ('suburb', but defined as 'county' where needed) dropdown boxes working perfectly but have now run into a tax problem <_< ...In my includes/functions/general.php, I have the following bit of 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_suburb_query = tep_db_query("select entry_suburb, entry_zone_id from " . TABLE_ADDRESS_BOOK . " where customers_id =  '" . $customer_id . "'");

$customer_suburb = tep_db_fetch_array($customer_suburb_query);
$customer_suburb['entry_suburb'] = strtoupper($customer_suburb['entry_suburb']); 

if (($customer_suburb['entry_suburb'] == 'Philadelphia County') && ($customer_suburb['entry_zone_id'] == 51)) { 
   return 7.0000; 
} 

   elseif (($customer_suburb['entry_suburb'] == 'Allegheny County') && ($customer_suburb['entry_zone_id'] == 51)) {  
  	 return 7.0000; 
} 

elseif (($customer_suburb['entry_suburb'] == '') && ($customer_suburb['entry_zone_id'] == 51)) { 
  	 return 6.0000; 
}

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_suburb_query = tep_db_query("select entry_suburb, entry_zone_id from " . TABLE_ADDRESS_BOOK . " where customers_id =  '" . $customer_id . "'");

$customer_suburb = tep_db_fetch_array($customer_suburb_query);
$customer_suburb['entry_suburb'] = strtoupper($customer_suburb['entry_suburb']); 
 
   $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_suburb['entry_suburb'] == 'Philadelphia County') && ($customer_suburb['entry_zone_id'] == 51)) { 
   return TEXT_CUSTOM_TAX_RATE; // Input your custom tax description here 
}	
elseif (($customer_suburb['entry_suburb'] == 'Allegheny County') && ($customer_suburb['entry_zone_id'] == 51)) {  
  	 return TEXT_CUSTOM_TAX_RATE2; 
} 
elseif (($customer_suburb['entry_suburb'] == '') && ($customer_suburb['entry_zone_id'] == 51)) {  
  	 return TEXT_CUSTOM_TAX_RATE3; 
}

 

Collecting the right tax rate for Philadelphia and Allegheny Counties worked perfectly until the addition of the counties dropdown box, and now it does not work at all---it's only picking up the normal 6% sales tax (from admin). I can't figure out what I need to do to fix this. :huh:

Anyone have some suggestions or advice on how to fix this?

I need to fix this ASAP so I can update a contribution I've posted... :)

Link to comment
Share on other sites

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...