Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Country-State Selector


stevel

Recommended Posts

Thanks Steve, I think you may have misunderstood....In vers 1.4.1 - the file you reference (includes/functions/general.php) is not touched by this contribution.

 

This is what I am looking for :

In the dropdown list of States (on all customers pages) - I would like just the State name listed (as it was previously in ver 1.0.5 - you added this functionality in ver 1.4.0 according to your 'Change History') not the State name AND the two digit State abbreviation (zone code) in parantheses.

 

I have made the changes to remove the state zone code as per my post above. I hope I havent messed up something else....

 

I changed one line of code in three files

create_account.php

includes/modules/address_book_details.php

includes/modules/checkout_new_address.php

 

 

I changed this line

$zones_array[] = array('id' => $zones_values['zone_id'], 'text' => $zones_values['zone_name'] . ' (' . $zones_values['zone_code'] . ')');

 

 

TO THIS

$zones_array[] = array('id' => $zones_values['zone_id'], 'text' => $zones_values['zone_name']);

 

and it seems to have removed the 2 digit state code in parantheses after the State name in the drop down boxes.

 

If anyone can see that this would cause some other problem or if I should have changed this in other places, please say.

(hoping I did this right)

Edited by sheepiedog
Link to comment
Share on other sites

  • 2 weeks later...

First of all, thanks for this great contribution. I have a quick question though, and I'm not entirely sure if it's where I didn't do something properly. However, when a customer is signing in, and they select the state, and all is well, and they become a customer, only the state ID number is written to the sql database in the customer section. Is there any way of getting it to write the state name or code to the customers table in the database?? I'm going to continue racking my brain and journeying down the rabbit hole! Thanks in Advance!

Link to comment
Share on other sites

You really don't want to do that - use the provided function to look up the zone name (tep_get_zone_name, I think), or use the address formatting function. The zone ID is needed to look up tax zones, shipping zones and more.

Link to comment
Share on other sites

Hi Guys,

 

I've installed this contribution on my site, and it's going to make a huge difference since I was originally holding off from allowing non UK users to sign up to the site as there was no real way to control the states.

 

The only problem I have come across so far is that when I am in Admin on customers.php as soon as I change the Country to anything else the State field changes from a combo box to a plain text field as if it couldn't find any matches. However in all of the other pages this works fine.

 

Has anyone else experienced the same? - I've been through the install plan a few times but can't see anything that I've missed.

 

Thanks in advance!

 

Mike

Link to comment
Share on other sites

Hey,

 

Yeah I've done a Diff and the only thing that is different around the call to populate the list is that it was previously using the zone_name rather than the zone_id. From what the code looks like it's doing this seems to be the relevent section but somehow it seems that its not getting a match for the array and therefore not populating correctly.

 

Any ideas? - the other pages all work fine :s

 

ORIGN SECTION:

 

$entry_state = tep_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state);

if ($error == true) {

if ($entry_state_error == true) {

if ($entry_state_has_zones == true) {

$zones_array = array();

$zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . tep_db_input($cInfo->entry_country_id) . "' order by zone_name");

while ($zones_values = tep_db_fetch_array($zones_query)) {

$zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);

}

echo tep_draw_pull_down_menu('entry_state', $zones_array) . ' ' . ENTRY_STATE_ERROR;

} else {

echo tep_draw_input_field('entry_state', tep_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state)) . ' ' . ENTRY_STATE_ERROR;

}

} else {

echo $entry_state . tep_draw_hidden_field('entry_zone_id') . tep_draw_hidden_field('entry_state');

}

} else {

echo tep_draw_input_field('entry_state', tep_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state));

}

 

NEWSECTION:

 

// +Country-State Selector

$entry_state = tep_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state);

$zones_array = array();

$zones_query = tep_db_query("select zone_name, zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$cInfo->entry_country_id . "' order by zone_name");

while ($zones_values = tep_db_fetch_array($zones_query)) {

$zones_array[] = array('id' => $zones_values['zone_id'], 'text' => $zones_values['zone_name']);

}

if (count($zones_array) > 0) {

echo tep_draw_pull_down_menu('entry_zone_id', $zones_array, $cInfo->entry_zone_id);

echo tep_draw_hidden_field('entry_state', '');

} else {

echo tep_draw_input_field('entry_state', $entry_state);

}

// -Country-State Selector

Link to comment
Share on other sites

I'd guess that $cInfo->entry_zone_id isn't being set properly, though if that were true the country name would not be properly reflected in the country dropdown on refresh. Is it? It's time to add some debugging code in the section you excerpt, adding some var_dump calls of the variables and $zones_array. If $zones_array comes up empty you'll get the text box.

Link to comment
Share on other sites

  • 1 month later...

I have the Limit Countries 2.x (2.1) implemented with the Country-State Selector v1.5.5 (AJAX) contribution and it works except for the fact that the "active status" does not show on the Admin>Countries page (countries.php). The header is there, but none of the values ie: 0 or 1 does not show (the values are there in the database). When I view source code for the page it shows some thing like:

 

<td class="dataTableContent">Afghanistan</td>

<td class="dataTableContent" align="center" width="40">AF</td>

<td class="dataTableContent" align="center" width="40">AFG</td>

<td class="dataTableContent" align="center" width="40"></td> <= no value for status

 

Somehow the info for that is not being called from the database, even though it is there. Also, I can add, edit, delete etc using the dropdown, but the result does not show (side bar thing).

 

Any help would be appreciated. My server is using:

PHP version 5.2.9

MySQL version 5.1.30

 

Thanks!

- Ken

Edited by NolaMan
Link to comment
Share on other sites

  • 3 weeks later...

Hi people, I just installed this contribution and everything works fine from the first sight, so, thank you very much.

 

I have an issue with the "bugfix" of 2 june 2008 made by mthierfelder as in is on the download page of this con.

 

There it is written

There is a bug in the latest versin 1.5.5 in /admin/customers.php that causes a "Parse error: syntax error, unexpected T_CASE in /path/to/admin/customers.php on line 221"

Original file messed up the // comment and included an extra "}" by mistake, see below.



 

After installing, find (around line 165):



// if ($error == false) {



// +Country-State Selector 


} // End if (!$refresh) 
if (($error == false) && ($refresh != 'true')) {


// -Country-State Selector



 

...and replace with:



// if ($error == false) {



// +Country-State Selector 


// } End if (!$refresh) 


if (($error == false) && ($refresh != 'true')) {


// -Country-State Selector


 

The strange thing is: If I follow the instructions and comment this "}" out, them I'm getting exactly the error that it shuld remove.

 

If I DONT follow, everything works fine.

 

My question: Is this a bugfix or a bug?

Link to comment
Share on other sites

Hi,

 

I have a problem with the width of the states field. Changing the width does not have any effect on the size of the field. Can someone please tell me what is wrong with the following code?

 

Thanks a lot!

 

			  <tr>
			<td class="main" width="30%"><?php echo ENTRY_CITY; ?></td>
			<td class="main" width="70%"><?php echo tep_draw_input_field('city') . ' ' . (tep_not_null(ENTRY_CITY_TEXT) ? '<span class="inputRequirement">' . ENTRY_CITY_TEXT . '</span>': ''); ?></td>
		  </tr>
<?php
 if (ACCOUNT_STATE == 'true') {
?>

		  <tr>
			<td class="main" width="30%"><?php echo ENTRY_STATE; ?></td>
			<td class="main" width="70%"><?php

// +Country-State Selector
$zones_array = array();
$zones_array[] = array('id' => 0, 'text' => PULL_DOWN_DEFAULT);
$zones_query = tep_db_query("select zone_id, zone_name from " . TABLE_ZONES . " where zone_country_id = " . 
  (int)$country . " order by zone_name");
while ($zones_values = tep_db_fetch_array($zones_query)) {
  $zones_array[] = array('id' => $zones_values['zone_id'], 'text' => $zones_values['zone_name'] . '');
  }
if (count($zones_array) > 1) {
  echo tep_draw_pull_down_menu('zone_id', $zones_array);
} else {
  echo tep_draw_input_field('state');
}
// -Country-State Selector



if (tep_not_null(ENTRY_STATE_TEXT)) echo ' <span class="inputRequirement">' . ENTRY_STATE_TEXT;
?>
			</td>
		  </tr>
<?php
 }
?>

Link to comment
Share on other sites

I have narrowed it down, it must have something to do with the drop down field itself

 

if i replace

 

echo tep_draw_pull_down_menu('zone_id', $zones_array);

 

with

 

echo tep_draw_pull_input_field('zone_id', $zones_array);

 

the field is just as big as it should be. Is the size for the drop down field taken from elsewhere?

 

Thanks!

Link to comment
Share on other sites

The size of dropdown boxes is determined by the browser - you cannot change it. Maddeningly, different browsers behave differently in this regard.

Link to comment
Share on other sites

I've been modifying my site with many of the contributions here. I was working on a fix so that only the US states would appear in a drop down list when adding accounts, changing addresses, etc. Everything is working fine accept when you log into your account and try to add an address. If you edit an existing address everything is fine, but when you add you see the following (cropped) screen:

 

Everything is fine except there is no drop down list or text box next to "State". If you fill in everything completely and click add you get an error and THEN the state list appears. You can then edit the state and it will add the address correctly. I have been through the file but I'm at a loss for what's missing? The code is below the image.

 

add_addr.gif

$Id: address_book_process.php 1766 2008-01-03 17:35:06Z hpdl $

osCommerce, Open Source E-Commerce Solutions
[url="http://www.oscommerce.com"]http://www.oscommerce.com[/url]

Copyright © 2007 osCommerce

Released under the GNU General Public License
*/

require('includes/application_top.php');

if (!tep_session_is_registered('customer_id')) {
$navigation->set_snapshot();
tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
}

// needs to be included earlier to set the success message in the messageStack
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADDRESS_BOOK_PROCESS);

if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'deleteconfirm') && isset($HTTP_GET_VARS['delete']) && is_numeric($HTTP_GET_VARS['delete'])) {
tep_db_query("delete from " . TABLE_ADDRESS_BOOK . " where address_book_id = '" . (int)$HTTP_GET_VARS['delete'] . "' and customers_id = '" . (int)$customer_id . "'");

$messageStack->add_session('addressbook', SUCCESS_ADDRESS_BOOK_ENTRY_DELETED, 'success');

tep_redirect(tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
}

// error checking when updating or adding an entry
$process = false;
if (isset($HTTP_POST_VARS['action']) && (($HTTP_POST_VARS['action'] == 'process') || ($HTTP_POST_VARS['action'] == 'update'))) {
$process = true;
$error = false;

if (ACCOUNT_GENDER == 'true') $gender = tep_db_prepare_input($HTTP_POST_VARS['gender']);
if (ACCOUNT_COMPANY == 'true') $company = tep_db_prepare_input($HTTP_POST_VARS['company']);
$firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
$lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);
$street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']);
if (ACCOUNT_SUBURB == 'true') $suburb = tep_db_prepare_input($HTTP_POST_VARS['suburb']);
$postcode = tep_db_prepare_input($HTTP_POST_VARS['postcode']);
$city = tep_db_prepare_input($HTTP_POST_VARS['city']);
$country = tep_db_prepare_input($HTTP_POST_VARS['country']);
if (ACCOUNT_STATE == 'true') {
if (isset($HTTP_POST_VARS['zone_id'])) {
$zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']);
} else {
$zone_id = 0;
}
if (isset($HTTP_POST_VARS['state'])) {
$state = tep_db_prepare_input($HTTP_POST_VARS['state']);
if ((strcmp($state, strtoupper($state)) == 0)) $state = strtolower($state);
if ((strcmp($state, strtolower($state)) == 0)) $state = ucwords($state);
} else {
$state = '';
}
}


if (ACCOUNT_GENDER == 'true') {
if ( ($gender != 'm') && ($gender != 'f') ) {
$error = true;

$messageStack->add('addressbook', ENTRY_GENDER_ERROR);
}
}

if (strlen($firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {
$error = true;

$messageStack->add('addressbook', ENTRY_FIRST_NAME_ERROR);
}

if (strlen($lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {
$error = true;

$messageStack->add('addressbook', ENTRY_LAST_NAME_ERROR);
}

if (strlen($street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {
$error = true;

$messageStack->add('addressbook', ENTRY_STREET_ADDRESS_ERROR);
}

if (strlen($postcode) < ENTRY_POSTCODE_MIN_LENGTH) {
$error = true;

$messageStack->add('addressbook', ENTRY_POST_CODE_ERROR);
}

if (strlen($city) < ENTRY_CITY_MIN_LENGTH) {
$error = true;

$messageStack->add('addressbook', ENTRY_CITY_ERROR);
}

if (!is_numeric($country)) {
$error = true;

$messageStack->add('addressbook', ENTRY_COUNTRY_ERROR);
}

if (ACCOUNT_STATE == 'true') {
$check_query = tep_db_query("select count(*) as total from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "'");
$check = tep_db_fetch_array($check_query);
if ($check['total'] > 0) { // if country has defined zones
if ($zone_id == 0) { // if zone_id not set try to retrieve based on state name
$zone_query = tep_db_query("select distinct zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and (zone_name = '" . tep_db_input($state) . "' or zone_code = '" . tep_db_input($state) . "')");
if (tep_db_num_rows($zone_query) == 1) {
$zone = tep_db_fetch_array($zone_query);
$zone_id = $zone['zone_id'];
} else {
$error = true;
$messageStack->add('addressbook', ENTRY_STATE_ERROR_SELECT);
}
} else { // retrieve state name from database using zone_id
$zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and zone_id = '" . (int)$zone_id . "'");
if (tep_db_num_rows($zone_query) == 1) {
$zone = tep_db_fetch_array($zone_query);
$state = stripslashes($zone['zone_name']);
} else { // if no state found to match zone_id in country then there is an error
$error = true;
$messageStack->add('addressbook', ENTRY_STATE_ERROR_SELECT);
}
}
} else {
if (strlen($state) < ENTRY_STATE_MIN_LENGTH) {
$error = true;
$messageStack->add('addressbook', ENTRY_STATE_ERROR);
}
}
}


if ($error == false) {
$sql_data_array = array('entry_firstname' => $firstname,
'entry_lastname' => $lastname,
'entry_street_address' => $street_address,
'entry_postcode' => $postcode,
'entry_city' => $city,
'entry_country_id' => (int)$country);

if (ACCOUNT_GENDER == 'true') $sql_data_array['entry_gender'] = $gender;
if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $company;
if (ACCOUNT_SUBURB == 'true') $sql_data_array['entry_suburb'] = $suburb;
if (ACCOUNT_STATE == 'true') {
if ($zone_id > 0) {
$sql_data_array['entry_zone_id'] = (int)$zone_id;
$sql_data_array['entry_state'] = '';
} else {
$sql_data_array['entry_zone_id'] = '0';
$sql_data_array['entry_state'] = $state;
}
}

if ($HTTP_POST_VARS['action'] == 'update') {
$check_query = tep_db_query("select address_book_id from " . TABLE_ADDRESS_BOOK . " where address_book_id = '" . (int)$HTTP_GET_VARS['edit'] . "' and customers_id = '" . (int)$customer_id . "' limit 1");
if (tep_db_num_rows($check_query) == 1) {
tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "address_book_id = '" . (int)$HTTP_GET_VARS['edit'] . "' and customers_id ='" . (int)$customer_id . "'");

// reregister session variables
if ( (isset($HTTP_POST_VARS['primary']) && ($HTTP_POST_VARS['primary'] == 'on')) || ($HTTP_GET_VARS['edit'] == $customer_default_address_id) ) {
$customer_first_name = $firstname;
$customer_country_id = $country;
$customer_zone_id = (($zone_id > 0) ? (int)$zone_id : '0');
$customer_default_address_id = (int)$HTTP_GET_VARS['edit'];

$sql_data_array = array('customers_firstname' => $firstname,
'customers_lastname' => $lastname,
'customers_default_address_id' => (int)$HTTP_GET_VARS['edit']);

if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender;

tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int)$customer_id . "'");
}

$messageStack->add_session('addressbook', SUCCESS_ADDRESS_BOOK_ENTRY_UPDATED, 'success');
}
} else {
if (tep_count_customer_address_book_entries() < MAX_ADDRESS_BOOK_ENTRIES) {
$sql_data_array['customers_id'] = (int)$customer_id;
tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array);

$new_address_book_id = tep_db_insert_id();

// reregister session variables
if (isset($HTTP_POST_VARS['primary']) && ($HTTP_POST_VARS['primary'] == 'on')) {
$customer_first_name = $firstname;
$customer_country_id = $country;
$customer_zone_id = (($zone_id > 0) ? (int)$zone_id : '0');
if (isset($HTTP_POST_VARS['primary']) && ($HTTP_POST_VARS['primary'] == 'on')) $customer_default_address_id = $new_address_book_id;

$sql_data_array = array('customers_firstname' => $firstname,
'customers_lastname' => $lastname);

if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender;
if (isset($HTTP_POST_VARS['primary']) && ($HTTP_POST_VARS['primary'] == 'on')) $sql_data_array['customers_default_address_id'] = $new_address_book_id;

tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int)$customer_id . "'");

$messageStack->add_session('addressbook', SUCCESS_ADDRESS_BOOK_ENTRY_UPDATED, 'success');
}
}
}

tep_redirect(tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
}
}

if (isset($HTTP_GET_VARS['edit']) && is_numeric($HTTP_GET_VARS['edit'])) {
$entry_query = tep_db_query("select entry_gender, entry_company, entry_firstname, entry_lastname, entry_street_address, entry_suburb, entry_postcode, entry_city, entry_state, entry_zone_id, entry_country_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$HTTP_GET_VARS['edit'] . "'");

if (!tep_db_num_rows($entry_query)) {
$messageStack->add_session('addressbook', ERROR_NONEXISTING_ADDRESS_BOOK_ENTRY);

tep_redirect(tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
}

$entry = tep_db_fetch_array($entry_query);
} elseif (isset($HTTP_GET_VARS['delete']) && is_numeric($HTTP_GET_VARS['delete'])) {
if ($HTTP_GET_VARS['delete'] == $customer_default_address_id) {
$messageStack->add_session('addressbook', WARNING_PRIMARY_ADDRESS_DELETION, 'warning');

tep_redirect(tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
} else {
$check_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where address_book_id = '" . (int)$HTTP_GET_VARS['delete'] . "' and customers_id = '" . (int)$customer_id . "'");
$check = tep_db_fetch_array($check_query);

if ($check['total'] < 1) {
$messageStack->add_session('addressbook', ERROR_NONEXISTING_ADDRESS_BOOK_ENTRY);

tep_redirect(tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
}
}
} else {
$entry = array();
}

if (!isset($HTTP_GET_VARS['delete']) && !isset($HTTP_GET_VARS['edit'])) {
if (tep_count_customer_address_book_entries() >= MAX_ADDRESS_BOOK_ENTRIES) {
$messageStack->add_session('addressbook', ERROR_ADDRESS_BOOK_FULL);

tep_redirect(tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));
}
}

$breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ACCOUNT, '', 'SSL'));
$breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL'));

if (isset($HTTP_GET_VARS['edit']) && is_numeric($HTTP_GET_VARS['edit'])) {
$breadcrumb->add(NAVBAR_TITLE_MODIFY_ENTRY, tep_href_link(FILENAME_ADDRESS_BOOK_PROCESS, 'edit=' . $HTTP_GET_VARS['edit'], 'SSL'));
} elseif (isset($HTTP_GET_VARS['delete']) && is_numeric($HTTP_GET_VARS['delete'])) {
$breadcrumb->add(NAVBAR_TITLE_DELETE_ENTRY, tep_href_link(FILENAME_ADDRESS_BOOK_PROCESS, 'delete=' . $HTTP_GET_VARS['delete'], 'SSL'));
} else {
$breadcrumb->add(NAVBAR_TITLE_ADD_ENTRY, tep_href_link(FILENAME_ADDRESS_BOOK_PROCESS, '', 'SSL'));
}
?>

>

if (!isset($HTTP_GET_VARS['delete'])) {
include('includes/form_check.js.php');
}
?>

$countries_query = tep_db_query("select countries_id from " . TABLE_COUNTRIES . " order by countries_name");
$cl = array(); $s = '';
while ($country = tep_db_fetch_array($countries_query)) {
$cl[] = $country['countries_id'];
$s .= $country['countries_id'] . ', ';
}
?>

<script language="JavaScript">
function ShowNewList(){
var id = new Array();
var x, item;
for (x = 0; x 
{ item = document.getElementById(id[x]);
if (item)
{ item.style.display = 'none'; item.disabled = true;}
}
var pm = document.getElementById('ctry');
id = pm.value;
var item = document.getElementById(id);
item.style.display = '';
item.disabled = false;
}












if ($messageStack->size('addressbook') > 0) {
?>





}

if (isset($HTTP_GET_VARS['delete'])) {
?>












} else {
?>






if (isset($HTTP_GET_VARS['edit']) && is_numeric($HTTP_GET_VARS['edit'])) {
?>



} else {
if (sizeof($navigation->snapshot) > 0) {
$back_link = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']);
} else {
$back_link = tep_href_link(FILENAME_ADDRESS_BOOK, '', 'SSL');
}
?>




}
}
?>
output('addressbook'); ?>


















'); ?>










' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . ''; ?>' . tep_image_button('button_delete.gif', IMAGE_BUTTON_DELETE) . ''; ?>










' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . ''; ?>










' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . ''; ?>'; ?>








Steve in Ellenton, FL

Link to comment
Share on other sites

I too am having the issue on customers.php where the drop down changes to a text box after a different country is selected. All other places where the drop downs are work fine. My situation is similar to Mike's.

 

Thanks

 

<?php
if (ACCOUNT_STATE == 'true') {
?>
	  <tr>
		<td class="main"><?php echo ENTRY_STATE; ?></td>
		<td class="main">
<?php
	 // +Country-State Selector
 $entry_state = tep_get_zone_name($cInfo->entry_country_id, $cInfo->entry_zone_id, $cInfo->entry_state);
 $zones_array = array();
 $zones_query = tep_db_query("select zone_name, zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$cInfo->entry_country_id . "' order by zone_name");

 while ($zones_values = tep_db_fetch_array($zones_query)) {
	$zones_array[] = array('id' => $zones_values['zone_id'], 'text' => $zones_values['zone_name']);
 }
   if (count($zones_array) > 1) {
	 echo tep_draw_pull_down_menu('entry_zone_id', $zones_array, $cInfo->entry_zone_id);
	 echo tep_draw_hidden_field('entry_state', '');
  } else {
	 echo tep_draw_input_field('entry_state', $entry_state);
  }
  // -Country-State Selector



?></td>
	 </tr>
<?php
}
?>

Link to comment
Share on other sites

That means that the test on the count of zone_array is returning zero. You'll need to add some debugging code to figure out why.

Edited by stevel
Link to comment
Share on other sites

Does anyone have any thoughts on why it is returning 0 the first time, yet if you either change country or submit to return with an error, the state drop down list appears and populates correctly? This is the only file that does this.

Steve in Ellenton, FL

Link to comment
Share on other sites

This would suggest that entry_country_id is not being populated from the customer's address book entry. The code that should do this is here:

 

	  default:
	  if(isset($HTTP_GET_VARS['cID'])){
		$customers_query = tep_db_query("select c.customers_id, c.customers_gender, c.customers_firstname, c.customers_lastname, c.customers_dob, c.customers_email_address, a.entry_company, a.entry_street_address, a.entry_suburb, a.entry_postcode, a.entry_city, a.entry_state, a.entry_zone_id, a.entry_country_id, a.entry_residential, c.customers_telephone, c.customers_fax, c.customers_newsletter, c.customers_default_billing_address_id from " . TABLE_CUSTOMERS . " c left join " . TABLE_ADDRESS_BOOK . " a on c.customers_default_billing_address_id = a.address_book_id where a.customers_id = c.customers_id and c.customers_id = '" . (int)$HTTP_GET_VARS['cID'] . "'");
		$customers = tep_db_fetch_array($customers_query);
		$cInfo = new objectInfo($customers);
	  }

 

(Your query may not look exactly like this, but it's the right part of the source.)

 

As I said, add some debugging code to display the values of relevant variables at different points in the code so that you can trace what is going on. I'd probably start with a var_dump of $cInfo after the above code.

Edited by stevel
Link to comment
Share on other sites

Hi Stevel,

 

Thank you for all your work and support. I would like to change the fields in the catalog/create_account.php from:

street

suburb

post code

city

state

country

 

To the opposite:

 

country

state

city

post code

suburb

street

 

Could you please help me to reverse this code:

 

<tr>

<td class="main"><b><?php echo CATEGORY_ADDRESS; ?></b></td>

</tr>

<tr>

<td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">

<tr class="infoBoxContents">

<td><table border="0" cellspacing="2" cellpadding="2">

<tr>

<td class="main"><?php echo ENTRY_STREET_ADDRESS; ?></td>

<td class="main"><?php echo tep_draw_input_field('street_address') . ' ' . (tep_not_null(ENTRY_STREET_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_STREET_ADDRESS_TEXT . '</span>': ''); ?></td>

</tr>

<?php

if (ACCOUNT_SUBURB == 'true') {

?>

<tr>

<td class="main"><?php echo ENTRY_SUBURB; ?></td>

<td class="main"><?php echo tep_draw_input_field('suburb') . ' ' . (tep_not_null(ENTRY_SUBURB_TEXT) ? '<span class="inputRequirement">' . ENTRY_SUBURB_TEXT . '</span>': ''); ?></td>

</tr>

<?php

}

?>

<tr>

<td class="main"><?php echo ENTRY_POST_CODE; ?></td>

<td class="main"><?php echo tep_draw_input_field('postcode') . ' ' . (tep_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="inputRequirement">' . ENTRY_POST_CODE_TEXT . '</span>': ''); ?></td>

</tr>

<tr>

<td class="main"><?php echo ENTRY_CITY; ?></td>

<td class="main"><?php echo tep_draw_input_field('city') . ' ' . (tep_not_null(ENTRY_CITY_TEXT) ? '<span class="inputRequirement">' . ENTRY_CITY_TEXT . '</span>': ''); ?></td>

</tr>

<?php

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" ><?php echo ENTRY_COUNTRY; ?></td>

<?php // +Country-State Selector ?>

<td class="main" ><?php echo tep_get_country_list('country',$country,'onChange="getStates(this.value, \'states\');"') . ' ' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?></td>

<?php // -Country-State Selector ?>

</tr>

</table></td>

</tr>

</table></td>

</tr>

 

 

Your help is greatly appreciated.

 

Eva

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.

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