Jump to content
Chachita

County Sales Tax by Zip Code - Tax exempt items?

Recommended Posts

Hi everyone, hoping someone can help me figure this out.

 

I recently installed the County Sales Tax by Zip Code mod (http://addons.oscommerce.com/info/1856) found in the contributions section, into my 2.3.1 store. Everything was easy to follow and I was able to update the zip codes to reflect the NY zip codes that I need with no problem. The mod, for what it's purpose is (to apply different tax rate to different zip codes), works great. There is one thing that I need help figuring out, and I'm hoping someone more knowledgeable in PHP can point me in the right direction.

 

My store sells apparel, and in NY State, the current laws require you to charge tax only on clothing that's over $110. Any items under that amount are tax-free. From what I understand (and I could be wrong) this modification seems to apply taxes to ALL purchases that are being delivered to a NY address. I want to figure out the best way to tweak it so that it only charges tax on items that are over $110. I know that you can assign tax classes to products, which will tell OSC what tax rate to apply to each item at checkout, but even when using different classes, they are ALL still being charged tax.

 

If I wanted to add a condition to this coding (something like "IF item price is over $110", or "IF tax class is XYZ"), how would I write it, and where would I be able to insert it?

 

Or if you know a better way to do this, please let me know. I've looked at other tax by zip contributions available, and after trying, this one was the best one for my needs, which was to charge different taxes to different zip codes in NY.

 

Any help would be much appreciated!

 

Chacha

Share this post


Link to post
Share on other sites

Below are the instructions for the code that's modified:

 

3. Open catalog/includes/functions/general.php for editing

4. On or near line 305 find the following text:

 

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

 

5. Right AFTER 'global $customer_zone_id, $customer_country_id;' insert the following on a new line:

 

 //CHANGES BY <YOUR NAME> TO ACCOUNT FOR CITY, COUNTY, AND STATE TAX RATE
//echo "send to = ".$_SESSION['sendto']."<br>"; //debugging$customer_zip_query = tep_db_query("select entry_postcode, entry_zone_id from " . TABLE_ADDRESS_BOOK . " where address_book_id = '" . $_SESSION['sendto'] . "'");
$address_query = tep_db_fetch_array($customer_zip_query);$cust_zip_code = $address_query['entry_postcode'];
$cust_entry_zone_id = $address_query['entry_zone_id'];
//BEGIN THE CUSTOM CHANGES FOR ZIPCODE AND ZONE LOGIC
if ( ($cust_zip_code == '81230' || $cust_zip_code == '81231') && ($cust_entry_zone_id == '13') ) //ZIPCODE IS FOR <YOUR CITY>, AND ZONE <13> IS CO
{
return 7.2500; //THIS IS THE STATE + COUNTY + CITY TAX RATE + CITY RTA TAX.... CHANGE THIS TO YOUR OWN
}
//THIS NEXT PART SHOWS HOW TO ADD AN ADDITIONAL CONDITION TO YOUR TAX CODE LOGIC
//IF YOU DON'T NEED THIS JUST DELETE THE 'ELSE IF' AND EVERYTHING BETWEEN THE '{ }'S INCLUDING THE '{ }'S BELOW THE 'ELSE IF'
else if ( ($cust_zip_code == '81210' || $cust_zip_code == '81220' || $cust_zip_code == '81224' || $cust_zip_code == '81225' || $cust_zip_code == '81239' || $cust_zip_code == '81243' || $cust_zip_code == '81247') && ($cust_entry_zone_id == '13') ) //ZIPCODE IS FOR <YOUR COUNTY>, AND ZONE <13> IS CO
{
return 4.5000; //THIS IS THE STATE + COUNTY + COUNTY RTA TAX.... CHANGE THIS TO YOUR OWN
}
//AND THIS IS YET ANOTHER CONDITION.... NOTICE WE JUST KEEP ADDING 'ELSE IF' STATEMENTS
else if ( ($cust_zip_code == '81237' || $cust_zip_code == '81241' || $cust_zip_code == '81434' || $cust_zip_code == '81623') && ($cust_entry_zone_id == '13') ) //ZIPCODE IS FOR <YOUR COUNTY>, AND ZONE <13> IS CO
{
return 3.9000; //THIS IS THE STATE + COUNTY TAX.... CHANGE THIS TO YOUR OWN
}
//OK ONE LAST EXAMPLE, BUT W/OUT THE $cust_entry_zone_id CONDITION IN CASE SOME ONE NEEDS IT THAT WAY
//else if ($cust_zip_code == '67890')
//{
//return 1.1111;
//}
//END OF CHANGES BY <YOUR NAME>

 

6. Now on or near line 347 find the following text:

 

////
// Return the tax description for a zone / class
// TABLES: tax_rates;
function tep_get_tax_description($class_id, $country_id, $zone_id) {

 

7. Right AFTER 'function tep_get_tax_description($class_id, $country_id, $zone_id) {' insert the following on a new line:

 

//CHANGES BY <YOUR NAME> TO ACCOUNT FOR CITY, COUNTY, AND STATE TAX RATE
//echo "send to = ".$_SESSION['sendto']."<br>";$customer_zip_query = tep_db_query("select entry_postcode, entry_zone_id from " . TABLE_ADDRESS_BOOK . " where address_book_id = '" . $_SESSION['sendto'] . "'");
$address_query = tep_db_fetch_array($customer_zip_query);$cust_zip_code = $address_query['entry_postcode'];
$cust_entry_zone_id = $address_query['entry_zone_id'];
if ( ($cust_zip_code == '81230' || $cust_zip_code == '81231') && ($cust_entry_zone_id == '13') ) //ZIPCODE IS FOR <YOUR CITY>, AND ZONE <13> IS CO
{
return 'Tax: CO 2.9%, County 1.0%, City 3.0%, City RTA 0.35%'; //THIS IS THE STATE + COUNTY + CITY TAX + CITY RTA RATE DESC.... CHANGE THIS TO YOUR OWN
}
//OK HERE WE GO, WE ARE GOING TO USE THE SAME 'ELSE IF' LOGIC AS ABOVE (LINES 328-349)
//AGAIN, IF YOU DON'T NEED, DELETE THE 'ELSE IF' AND EVERYTHING BETWEEN THE '{ }'S INCLUDING THE '{ }'S BELOW THE 'ELSE IF'
else if ( ($cust_zip_code == '81210' || $cust_zip_code == '81220' || $cust_zip_code == '81224' || $cust_zip_code == '81225' || $cust_zip_code == '81239' || $cust_zip_code == '81243' || $cust_zip_code == '81247') && ($cust_entry_zone_id == '13') ) //ZIPCODE IS FOR <YOUR CITY>, AND ZONE <13> IS CO
{
return 'Tax: CO 2.9%, County 1.0%, County RTA 0.60%'; //THIS IS THE STATE + COUNTY + COUNTY RTA RATE DESC.... CHANGE THIS TO YOUR OWN
}
else if ( ($cust_zip_code == '81237' || $cust_zip_code == '81241' || $cust_zip_code == '81434' || $cust_zip_code == '81623') && ($cust_entry_zone_id == '13') ) //ZIPCODE IS FOR <YOUR CITY>, AND ZONE <13> IS CO
{
return 'Tax: CO 2.9%, County 1.0%'; //THIS IS THE STATE + COUNTY DESC.... CHANGE THIS TO YOUR OWN
}
//OK ONE LAST EXAMPLE, BUT W/OUT THE $cust_entry_zone_id CONDITION IN CASE SOME ONE NEEDS IT THAT WAY
//else if ($cust_zip_code == '67890')
//{
//return 'QQ 1.0000% Tax, Sample County 0.1111% Tax, and Development Cty. 0.0% Tax'; //THIS IS THE STATE + COUNTY + CITY TAX RATE DESC.... CHANGE THIS TO YOUR OWN
//}
//END OF CHANGES BY <YOUR NAME>

 

8. Save the modified catalog/includes/functions/general.php

9. Open catalog/checkout_shipping.php for editing

10. On or near line 36 fine the following text:

 

if ($check_address['total'] != '1') {
 $sendto = $customer_default_address_id;

 

11, Right AFTER '$sendto = $customer_default_address_id;' insert the following on a new line:

 

$_SESSION['sendto'] = $sendto;

 

12. Save the modified catalog/checkout_shipping.php

Edited by Chachita

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×