Hey everyone, Id like to apologize for not providing support on the 1.5x versions.. They were modified by me but I just havent had time for the last few months to come in here help with with any problems.. A big thanks to Steve for helping as much as he does with your problems even though he doesnt use the version himself. If there are any big problems you can email me at webmaster AT insaini DOT com.
Also for a bit of info..
The AJAX Functions file (catalog/includes/functions/ajax.php) has a function
function ajax_get_zones_html($country, $default_zone = '', $ajax_output = true) {
where $country is a country id, $default_zone is the zone id or state (string) .. and ajax_output either echo's the output directly or does a return
the defaults should be noted..
at the top of for instance the create_account.php file
you only need this
require(DIR_WS_FUNCTIONS . 'ajax.php');
if (isset($_POST['action']) && $_POST['action'] == 'getStates' && isset($_POST['country'])) {
ajax_get_zones_html(tep_db_prepare_input($_POST['country']));
} else {
some of you may have
require(DIR_WS_FUNCTIONS . 'ajax.php');
if (isset($_POST['action']) && $_POST['action'] == 'getStates' && isset($_POST['country'])) {
ajax_get_zones_html(tep_db_prepare_input($_POST['country']), '');
} else {
or
require(DIR_WS_FUNCTIONS . 'ajax.php');
if (isset($_POST['action']) && $_POST['action'] == 'getStates' && isset($_POST['country'])) {
ajax_get_zones_html(tep_db_prepare_input($_POST['country']), true);
} else {
the latter will cause the '1' to show up.. (as true really represents a 1) .. so the default_zone is usually 1 .. best to remove both the extra parameters.. they are only needed on the first call (when the page loads) and have default values
so you all should change the code to look like
require(DIR_WS_FUNCTIONS . 'ajax.php');
if (isset($_POST['action']) && $_POST['action'] == 'getStates' && isset($_POST['country'])) {
ajax_get_zones_html(tep_db_prepare_input($_POST['country']));
} else {
at the top of those files which require it.. i believe (create_account.php, address_book_process.php, etc..)
ALSO
if you look below the code shows the 'echo ajax_get_zones_html(....)' ajax function call.. here you can specifiy the default zone you want to show up (false for ajax output is necessary as we are not returning the output and not echoing directly) ..
further down you will see how the country selector calls the javascript getStates method..
Your code should look like this.. if it doesnt.. you might be having problems.. overall the script works as it should.. however there is the one situation I think someone described.. that they want a list of the most common nations at the top .. this isnt in code.. best to see the ajax function and rework it as you need to..
if (ACCOUNT_STATE == 'true') {
?>
<tr>
<td class="main" width="25%"><?php echo ENTRY_STATE; ?></td>
<td class="main"><div id="states">
<?php
// +Country-State Selector
echo ajax_get_zones_html($country,'',false);
// -Country-State Selector
?>
</div></td>
</tr>
<?php
}
?>
<tr>
<td class="main" width="25%"><?php echo ENTRY_COUNTRY; ?></td>
<?php // +Country-State Selector ?>
<td class="main" colspan="3"><?php echo tep_get_country_list('country',$country,'class="formtextinput" onChange="getStates(this.value, \'states\');"') . ' ' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?></td>
<?php // -Country-State Selector ?>
</tr>