Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

United States States only


5 replies to this topic

#1 prof3ta

  • Community Member
  • 40 posts

Posted 28 September 2004, 16:34

Ive found a few contributions, but theyre not quite what im looking for. Im trying to make the U.S. the only field in country, and trying to get a drop down state list with the US states only.
How can i do this? Do i need to modify the db itself?

#2 julianpuje

  • Community Member
  • 891 posts
  • Real Name:The Eag

Posted 28 September 2004, 16:48

Hi
I wanted UK only and had to create a new countries file in the db. I renamed the original countries_old and copied the UK line over.

Julian
A little knowledge is dangerous, I SHOULD KNOW.
If Life Begins At 40, What ends????

#3 prof3ta

  • Community Member
  • 40 posts

Posted 28 September 2004, 17:18

julianpuje, on Sep 28 2004, 04:48 PM, said:

Hi
I wanted UK only and had to create a new countries file in the db. I renamed the original countries_old and copied the UK line over.

Julian

<{POST_SNAPBACK}>


Okee, so a sql script could be written as a contrib to replace old country file and modify the states.
That's a fairly simple contrib, wonder why no one has done it yet

#4 ozcsys

  • Community Member
  • 5,002 posts
  • Real Name:Richard
  • Location:NW Arkansas USA

Posted 28 September 2004, 17:23

prof3ta, on Sep 28 2004, 11:34 AM, said:

Ive found a few contributions, but theyre not quite what im looking for. Im trying to make the U.S. the only field in country, and trying to get a drop down state list with the US states only.
How can i do this? Do i need to modify the db itself?

<{POST_SNAPBACK}>


Do you want to have the US as the default or as the only country? If as the default then look in the tips section of the knowledge base and follow the instructions. If you want it to be the only one you need to remove the other countries from the database. The easiest way to do this is to go to phpmyadmin and bring up the countries table and write down the info for the US and the empty the talble and add the US back in.

For the state dropdown when they create an account go to your create_account.php file at or about line 130 and find

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;



And change it to


if (ACCOUNT_STATE == 'true') {
$zone_id = 0;
$check_query = tep_db_query("select count(*) as total from " . TABLE_ZONES . " where zone_country_id = '223" . (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 = '223" . (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;

This should give the customer a dropdown of states to choose from
The Knowledge Base is a wonderful thing.
Do you have a problem? Have you checked out Common Problems?
There are many very useful osC Contributions
Are you having trouble with a installed contribution? Have you checked out the support thread found Here
BACKUP BACKUP BACKUP!!! You did backup, right??

#5 prof3ta

  • Community Member
  • 40 posts

Posted 28 September 2004, 18:01

Thanks man, as soon as my stupid server is back online I'll try it out.

ozcsys, on Sep 28 2004, 05:23 PM, said:

Do you want to have the US as the default or as the only country? If as the default then look in the tips section of the knowledge base and follow the instructions. If you want it to be the only one you need to remove the other countries from the database. The easiest way to do this is to go to phpmyadmin and bring up the countries table and write down the info for the US and the empty the talble and add the US back in.

For the state dropdown when they create an account go to your create_account.php file at or about line 130 and find

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;
And change it to
if (ACCOUNT_STATE == 'true') {
      $zone_id = 0;
      $check_query = tep_db_query("select count(*) as total from " . TABLE_ZONES . " where zone_country_id = '223" . (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 = '223" . (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;

This should give the customer a dropdown of states to choose from

<{POST_SNAPBACK}>



#6 prof3ta

  • Community Member
  • 40 posts

Posted 28 September 2004, 20:18

It's all good and working now. Except the sql query didnt quite work. It should have worked by selecting "223" from zones, giving you only US states, but it kept giving the whole table for zones. So i just went in and deleted everything != 223 and it works. Thanks for both your help.