Products     Magento Extension     PCI-Shopping-Carts     Templates       CRELoaded     WordPress Modules     osCommerce Modules       osCommerce Addons       osCommerce Features       osCommerce Management       Payment Modules     CRELoaded Modules       CRE Loaded Addons       CRE Loaded Features       CRE Loaded Management       Payment Modules       CRELoaded Services
Free Stuff
Customization
Templates
Compare Products
You have no items to compare.
Affiliate Info
Affiliate Program FAQ
Affiliate Log In
Recent Orders
Hot Keywords: Order Notification, Order Search, Coupon, Flash Board, Compare, Floating Message, Tracking, Moneris, RSS, Visitor Filter

  auto state dropdowns depending on country

The following osCommerce contribution is a free Opensource code originated from official osCommerce website and provided for your reference only, you may download the original contribution file(s) and install it on your own; or you may request a Paid Installation Service from Agents Of Power; Agents Of Power does the "AS IS" installation on your website, we do not guarantee it will work properly on your website. Extra Paid service is available for repairing the problem from the original contribution or from your website.
While version 1.1 seems to have solved the problem caused by HTML characters in state names I decided that it would be safest to use the zone_id in the state dropdowns rather than the state name. That way no matter what kind of characters are in the state name the customer will still be able to select it from the drop down list without receiving an error message. Version 1.2 has also added the "Please Select" message to each state drop down menu so that new address entries will display the osCommerce "Please Select" message instead of the first state name in the list.
Discovered a problem with my original version when used with the World Zones contribution where accented charaters such as é or ï are defined with the HTML code for the character. Any attempt to select a state with such a character results in a error because when the form is submitted the HTML character codes get converted into the actual characters and the state name no longer matches what is in the database. The updated instructions here fix this problem.

If you have already installed this contribution the fix is simple as follows:

There are four files containing the following lines:

while ($zones_values = tep_db_fetch_array($zones_query)) {
$zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);}

These files being catalog/create_account.php, catalog/includes/modules/address_book_details.php, catalog/includes/modules/checkout_new_address.php, and catalog/admin/customers.php. In all four of the files those lines will need to be changed to read as follows:

while ($zones_values = tep_db_fetch_array($zones_query)) {
$zones_array[] = array('id' => htmlspecialchars($zones_values['zone_name']), 'text' => $zones_values['zone_name']);}

Immediately below these lines is an echo tep_draw_pull_down_menu statement. In two of the files the third parameter (immediately after $zones_array,) will be something other than a null (''). In those two files (catalog/includes/modules/address_book_details.php and catalog/admin/customers.php) you will need to enclose the third parameter inside an htmlspecialchars function.

In catalog/includes/modules/address_book_details.php the line will need to read as follows:

echo tep_draw_pull_down_menu('state', $zones_array, htmlspecialchars(tep_get_zone_name($entry['entry_country_id'], $entry['entry_zone_id'], $entry['entry_state'])), $parms);


and in catalog/admin/customers.php the line will need to read as follows:

echo tep_draw_pull_down_menu('entry_state', $zones_array, htmlspecialchars(tep_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state)), $parms);


We have a problem with some new customers failing to enter the proper state for their address. Apparently they don't enter a value for the state name that osCommerce can find in the zones database and therefore osCommerce returns an error message and a dropdown for the state with the state of Alabama being selected. Obviously the customers are not reading the error message and okay the "updated" address without noticing that the state they entered has been changed to Alabama.

To solve this problem I designed this modification so that osCommerce will display a dropdown list appropriate for each country, or a text input box if there are no zones defined for the selected country. As the country dropdown is changed so does the field for the state.
   Posted on: 10/15/2008     See contribution details Request Installation with Paid service