Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

State/Province


FrancineNJ

Recommended Posts

:-" In create account.....I already have US & Canada....its been some time now since I installed those and now I want to add other Province's for other countries that I have in the dropdown box for countries.

For the life of me...I can't remember how I entered US & Canada....so what file or table controls that the Province will showup in my dropdown box in create account?

 

 

I have a customer wanting to create an account from Australia but their Province is not listed.

 

 

Thank you for any help you can provide :D

Link to comment
Share on other sites

In Admin, Zones.  Add a zone for each state or province, indicating the correct corresponding country.

 

 

I have in Admin, under Zones....the zones for the other countries. Take Australia for example. I had inserted them into my zones table of the database.

But, they still did not show up in the dropdown box.

 

Any other suggestions? :(

Link to comment
Share on other sites

My suggestion was the basis of what you need. But..

 

In the stock osCommerce, you don't get a dropdown box for the states on the first screen. It's only when the customer submits the form and there's no match or an ambiguity that the list appears.

 

My Country-State Selector contribution displays the list all the time for countries that have zones. You do have to ensure that the country code is set properly in the Zones table. As long as you do that, it should work.

Link to comment
Share on other sites

My suggestion was the basis of what you need.  But..

 

In the stock osCommerce, you don't get a dropdown box for the states on the first screen.  It's only when the customer submits the form and there's no match or an ambiguity that the list appears.

 

My Country-State Selector contribution displays the list all the time for countries that have zones.  You do have to ensure that the country code is set properly in the Zones table.  As long as you do that, it should work.

 

LOL! I was trying to avoid having to do your contribution. However, it sounds like I must have since I have US states and Canada.

 

Should I try re-installing it?

 

And can you post an example of what a correct country code wold look like in the Zones table?

 

Thanks!

Link to comment
Share on other sites

I doubt that reinstalling is needed. But I am puzzled that you would see the dropdown list the first time without it.

 

Here's what I have for Australia under Zones:

Australia 	 Australian Capital Territory 	 ACT 
Australia  New South Wales  NSW 
Australia  Northern Territory  NT
Australia  Queensland  QLD 
Australia  South Australia  SA  
Australia  Tasmania  TAS 
Australia  Victoria  VIC 
Australia  Western Australia  WA

 

Show us the code in create_account.php that starts with the line:

  if (ACCOUNT_STATE == 'true') {

and down until the line with ENTRY_STATE_TEXT.

Link to comment
Share on other sites

I doubt that reinstalling is needed.  But I am puzzled that you would see the dropdown list the first time without it.

 

Here's what I have for Australia under Zones:

Australia ?	Australian Capital Territory ?	ACT 
Australia ?New South Wales ?NSW 
Australia ?Northern Territory ?NT
Australia ?Queensland ?QLD 
Australia ?South Australia ?SA ?
Australia ?Tasmania ?TAS 
Australia ?Victoria ?VIC 
Australia ?Western Australia ?WA

 

Show us the code in create_account.php that starts with the line:

 ?if (ACCOUNT_STATE == 'true') {

and down until the line with ENTRY_STATE_TEXT.

 

 

ok...but for some reason it does not contain the line ENTRY_STATE_TEXT.

 

 

  if (ACCOUNT_STATE == 'true') {

$state = tep_db_prepare_input($HTTP_POST_VARS['state']);

if (isset($HTTP_POST_VARS['zone_id'])) {

$zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']);

} else {

$zone_id = false;

}

}

$country = tep_db_prepare_input($HTTP_POST_VARS['country']);

$telephone = tep_db_prepare_input($HTTP_POST_VARS['telephone']);

$fax = tep_db_prepare_input($HTTP_POST_VARS['fax']);

if (isset($HTTP_POST_VARS['newsletter'])) {

$newsletter = tep_db_prepare_input($HTTP_POST_VARS['newsletter']);

} else {

$newsletter = false;

}

$password = tep_db_prepare_input($HTTP_POST_VARS['password']);

$confirmation = tep_db_prepare_input($HTTP_POST_VARS['confirmation']);

 

$error = false;

 

if (ACCOUNT_GENDER == 'true') {

if ( ($gender != 'm') && ($gender != 'f') ) {

$error = true;

 

$messageStack->add('create_account', ENTRY_GENDER_ERROR);

}

}

 

if (strlen($firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {

$error = true;

 

$messageStack->add('create_account', ENTRY_FIRST_NAME_ERROR);

}

 

if (strlen($lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {

$error = true;

 

$messageStack->add('create_account', ENTRY_LAST_NAME_ERROR);

}

 

if (ACCOUNT_DOB == 'true') {

if (checkdate(substr(tep_date_raw($dob), 4, 2), substr(tep_date_raw($dob), 6, 2), substr(tep_date_raw($dob), 0, 4)) == false) {

$error = true;

 

$messageStack->add('create_account', ENTRY_DATE_OF_BIRTH_ERROR);

}

}

 

if (strlen($email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) {

$error = true;

 

$messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_ERROR);

} elseif (tep_validate_email($email_address) == false) {

$error = true;

 

$messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);

} else {

$check_email_query = tep_db_query("select count(*) as total from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'");

$check_email = tep_db_fetch_array($check_email_query);

if ($check_email['total'] > 0) {

$error = true;

 

$messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_ERROR_EXISTS);

}

}

 

if (strlen($street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {

$error = true;

 

$messageStack->add('create_account', ENTRY_STREET_ADDRESS_ERROR);

}

 

if (strlen($postcode) < ENTRY_POSTCODE_MIN_LENGTH) {

$error = true;

 

$messageStack->add('create_account', ENTRY_POST_CODE_ERROR);

}

 

if (strlen($city) < ENTRY_CITY_MIN_LENGTH) {

$error = true;

 

$messageStack->add('create_account', ENTRY_CITY_ERROR);

}

 

if (is_numeric($country) == false) {

$error = true;

 

$messageStack->add('create_account', ENTRY_COUNTRY_ERROR);

}

 

if (ACCOUNT_STATE == 'true') {

$zone_id = 0;

$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);

$entry_state_has_zones = ($check['total'] > 0);

if ($entry_state_has_zones == true) {

$zone_query = tep_db_query("select distinct zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and (zone_name like '" . tep_db_input($state) . "%' or zone_code like '%" . 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('create_account', ENTRY_STATE_ERROR_SELECT);

}

} else {

if (strlen($state) < ENTRY_STATE_MIN_LENGTH) {

$error = true;

 

$messageStack->add('create_account', ENTRY_STATE_ERROR);

}

}

}

Link to comment
Share on other sites

Sorry, that's the wrong bit of code - I meant further down in the file.

 

 

Sorry....ok...this is the last instance of " if (ACCOUNT_STATE == 'true') { "

again no "ENTRY_STATE_TEXT" there.

 

 

if (ACCOUNT_STATE == 'true') {

?>

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

<?php

}

?>

<tr>

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

<td class="main"><?php echo tep_get_country_list('country') . ' ' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?></td>

</tr>

</table></td>

</tr>

</table></td>

</tr>

Link to comment
Share on other sites

You must have moved the code elsewhere in the file, then. Perhaps before the display of the postcode field. Look for code just before what you posted that refers to $zones_array and $zones_query - similar to what was in your earlier post.

Link to comment
Share on other sites

You must have moved the code elsewhere in the file, then.  Perhaps before the display of the postcode field.  Look for code just before what you posted that refers to $zones_array and $zones_query - similar to what was in your earlier post.

 

 

This is above if (ACCOUNT_STATE == 'true') {

and below ENTRY_STATE........is this it?

 

<?php

$zones_array[] = array('id' => '', 'text' => 'Please Select');

$zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '223' 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']);

}

 

$zones_array2[] = array('id' => '', 'text' => '----------');

$zones_query2 = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '38' order by zone_name");

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

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

}

echo tep_draw_pull_down_menu('state', array_merge($zones_array, $zones_array2), 'Please Select');

 

if (tep_not_null(ENTRY_STATE_TEXT)) echo ' <span class="inputRequirement">' . ENTRY_STATE_TEXT;

?> </td>

</tr>

Link to comment
Share on other sites

Yeah... You have hardwired USA and Canada and don't allow any other countries to have their zones displayed.

 

I suggest you go ahead and install Country-State Selector.

Link to comment
Share on other sites

Yeah...  You have hardwired USA and Canada and don't allow any other countries to have their zones displayed.

 

I suggest you go ahead and install Country-State Selector.

 

 

I was affraid you were going to say that. I don't remember doing that (it's an age thing) but back then, I only wanted to ship to US & Canada...and of course..now I changed my mind.

 

I do have an older version of create_account. No country codes are listed.

Would this work if I uploade this one?

<?php
 if (ACCOUNT_STATE == 'true') {
?>
             <tr>
               <td class="main"><?php echo ENTRY_STATE; ?></td>
               <td class="main">
<?php
   if ($process == 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 = '" . (int)$country . "' 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('state', $zones_array);
     } else {
       echo tep_draw_input_field('state');
     }
   } else {
     echo tep_draw_input_field('state');
   }

 [B]Or..I can also edit this one to include an entry for Austraila or any other country to the dropdown list. I would just copy but change the country_id.
That would work.[/B]

$zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '223' 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']);

}

Link to comment
Share on other sites

I was affraid you were going to say that.  I don't remember doing that (it's an age thing) but back then, I only wanted to ship to US & Canada...and of course..now I changed my mind.

 

I do have an older version of create_account. No country codes are listed.

Would this work if I uploade this one?

<?php
?if (ACCOUNT_STATE == 'true') {
?>
? ? ? ? ? ? ?<tr>
? ? ? ? ? ? ? ?<td class="main"><?php echo ENTRY_STATE; ?></td>
? ? ? ? ? ? ? ?<td class="main">
<?php
? ?if ($process == 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 = '" . (int)$country . "' 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('state', $zones_array);
? ? ?} else {
? ? ? ?echo tep_draw_input_field('state');
? ? ?}
? ?} else {
? ? ?echo tep_draw_input_field('state');
? ?}

?[B]Or..I can also edit this one to include an entry for Austraila or any other country to the dropdown list. I would just copy but change the country_id.
That would work.[/B]

$zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '223' 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']);

}

 

Thank you for all your help....actually talking to you an posting has helped me.

What I stated above has worked. I added the additional code for said country to create_account.php.

I now have Australia's Province in the dropdown box of State/Province :thumbsup:

 

<?php
      $zones_array[] = array('id' => '', 'text' => 'Please Select');
      $zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '223' 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']);
      }

      $zones_array2[] = array('id' => '', 'text' => '----------');
      $zones_query2 = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '38' order by zone_name");
      while ($zones_values = tep_db_fetch_array($zones_query2)) {
        $zones_array2[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);
      }
     
      $zones_array2[] = array('id' => '', 'text' => '----------');
      $zones_query2 = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '13' order by zone_name");
      while ($zones_values = tep_db_fetch_array($zones_query2)) {
        $zones_array2[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);

Link to comment
Share on other sites

It seems as if you'd want a suffix 3 on that last set. Or is there code you're not showing that merges these arrays? How does the customer select the country?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...