osCommerce Community Support Forums: United States States only - osCommerce Community Support Forums

Jump to content

Corporate Sponsor


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

United States States only Making a store for US customers only Rate Topic: -----

#1 User is offline   prof3ta Icon

  • Find Posts
  • Group: Community Member
  • Posts: 40
  • Joined: 15-April 04

Posted 28 September 2004 - 04:34 PM

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

#2 User is offline   julianpuje Icon

  • Find Posts
  • Group: Community Member
  • Posts: 891
  • Joined: 27-April 04
  • Real Name:The Eag

Posted 28 September 2004 - 04:48 PM

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

#3 User is offline   prof3ta Icon

  • Find Posts
  • Group: Community Member
  • Posts: 40
  • Joined: 15-April 04

Posted 28 September 2004 - 05:18 PM

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


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
0

#4 User is offline   ozcsys Icon

  • Find Posts
  • Group: Community Member
  • Posts: 5,002
  • Joined: 17-November 03
  • Real Name:Richard
  • Location:NW Arkansas USA

Posted 28 September 2004 - 05:23 PM

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?


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

#5 User is offline   prof3ta Icon

  • Find Posts
  • Group: Community Member
  • Posts: 40
  • Joined: 15-April 04

Posted 28 September 2004 - 06:01 PM

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

0

#6 User is offline   prof3ta Icon

  • Find Posts
  • Group: Community Member
  • Posts: 40
  • Joined: 15-April 04

Posted 28 September 2004 - 08:18 PM

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

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic