Since the changes I made are not on or a part of this plug-in, but rather on the built-in tax module I thought I would just share what I did here.
Background: My store is located in the state of Colorado, United States. Further, it is located in the city of Loveland, within Larimer county. I am required to collect sales tax at the state level for anyone living within the state of Colorado, at the county level for those within Larimer county, and at the city level for those within Loveland.
Step 1: Define zones (yes, zones - not zone defines) for each of the zip-codes within Larimer county. These are defined as Country = United States, Zone Name = Colorado, 80537, Zone Code = CO. For my needs, this meant defining 24 new zones (one for each of the zip-codes)
Step 2: Define zone definitions - one for the State, one for the County, and one for the City
Step 3: For each of the new zone definitions, go to details and add each zone as appropriate. Note, state should be normal state zone, county includes all zip-code zones for the county except those for the city, and city gets those for the city.
Step 4: Create the appropriate Tax rates for each of State, County, and City.
Step 5: Add the following defines to your english.php file - found in your override folder
Code:
// defines to setup local taxes
define('US_HOME_STATE_ID', '13'); // this is the zone_id from the database for Colorado
define('US_HOME_STATE_NAME', 'Colorado');
Step 6: Modify the code in the following three files:
includes/modules/checkout_new_address.php
includes/modules/create_account.php
includes/modules/pages/address_book_process/header_php.php
The modification is the same in all three files:
Find the following code...
Code:
if (ACCOUNT_STATE == 'true') {
$state = (isset($_POST['state'])) ? zen_db_prepare_input($_POST['state']) : FALSE;
if (isset($_POST['zone_id'])) {
$zone_id = zen_db_prepare_input($_POST['zone_id']);
} else {
$zone_id = false;
}
}
and change it to...
Code:
if (ACCOUNT_STATE == 'true') {
$state = zen_db_prepare_input($_POST['state']);
if (isset($_POST['zone_id'])) {
$zone_id = zen_db_prepare_input($_POST['zone_id']);
// add hack to set up "state, zip" check for Colorado
if ($zone_id == US_HOME_STATE_ID) {
$state = US_HOME_STATE_NAME . ", " . substr($postcode, 0, 5); // format is now "Colorado, 80537"
$temp_zone_id = $zone_id; // saving this for test later if new format is not found
$zone_id = false; // have to do this or the db select will fail = disaster
} else {
$temp_zone_id = false; // make sure this is false if we are not dealing with our home state
}
// end hack
} else {
$zone_id = false;
}
}
Also find the following code ...
Code:
if ($found_exact_iso_match) {
$zone_id = $zone->fields['zone_id'];
$zone_name = $zone->fields['zone_name'];
} else {
$error = true;
$error_state_input = true;
$messageStack->add('addressbook', ENTRY_STATE_ERROR_SELECT);
}
and change it to ...
Code:
if ($found_exact_iso_match) {
$zone_id = $zone->fields['zone_id'];
$zone_name = $zone->fields['zone_name'];
//added hack to reset zone_id if "state, zip" combination was not found
} elseif ($temp_zone_id) {
$zone_id = $temp_zone_id;
$zone_name = US_HOME_STATE_NAME;
// end hack
} else {
$error = true;
$error_state_input = true;
$messageStack->add('checkout_address', ENTRY_STATE_ERROR_SELECT);
}
Note the changes I made are wrapped in "hack" comments
That's it. When a customer sets up their address and selects their state, and enters their zip code, the code changes ensure that the correct zone is selected for the state, zip combination. If you configure your tax and zones correctly, the built-in tax module will charge the correct amount of tax, and will recalculate the correct amount of tax when a coupon or gift voucher is used.
Note: two of the files can be modified in overrides, the the one in the pages folder cannot.
MODIFY FILES AT YOUR OWN RISK - this hack is not supported.
Bookmarks