Jump to content
stevel

Country-State Selector

Recommended Posts

// +Country-State Selector

define ('DEFAULT_COUNTRY', '222');

// -Country-State Selector

Do i add this to every file that use CS Selector?

 

As regards the County's, yes theyre in my db.

 

Cheers

Fatmcgav

Share this post


Link to post
Share on other sites
Do i add this to every file that use CS Selector?

 

As regards the County's, yes theyre in my db.

 

Cheers

Fatmcgav

 

No, you only need to add it to the language file as stated in the contribs install instructions.

 

You might need to look in includes/modules/address_book....? cant remember the file name.

 

Do you get the drop down in address_book_details for the county?

 

Have you got a link so i can see what it is doing?

 

Mike

Share this post


Link to post
Share on other sites

All sorted. For some reason or another, the 'Default Country define' didn't get added to english.php :S :S

 

Also, i noticed a typo in the install manual,

catalog/includes/form_check_js.php

 

Against the actual filename of

catalog/includes/form_check.js.php

Just thought i'd let you know. :)

 

Cheers

Fatmcgav

Share this post


Link to post
Share on other sites
In address_book_details.php, the code you want instead is:

<?php // +Country-State Selector ?>
<td class="main"><?php echo tep_draw_hidden_field('country',$entry['entry_country_id']) . 'United States '; ?></td>
<?php // -Country-State Selector ?>

 

Once again Steve, Thanks

 

All looking good now

 

:thumbsup:

 

Mike

Share this post


Link to post
Share on other sites

Found me another problem :):)

 

When i try to update an address in my address book, it now ask's me to select a Country from the pull-down list. Now i have no pull-down list, so i duno why it should be askin.

 

I've tried commenting out the country check in form_check.js, and i've changed DEFAULT COUNTRY to 23 (UK).

 

Any ideas ppl.

 

Cheers

Fatmcgav

Share this post


Link to post
Share on other sites

Hi Steve,

Strange problem (bug?) hope you can help!

 

I have many State/Counties added and all work except one that cannot be used in the "create_account.php" BUT you can go in after the account is created (with another County selected) and alter to use that State/County. I'm figuring there is a bug in the create account file?

 

Here is the: Create Account Screen Link

The problem: New York - Westchester County

It gives the MessageStackError when you try to proceed with this (only one out of 100 listed) county selected.

 

If you would like to see any files let me know but I won't post them 1st to help save viewing space on this post.

 

Much Thanks, KJ Miller

ps, I'll put your banner on the site (well traffic'd) if you wish for your troubles.


define('PROJECTS', 'Something that goes on forever!');

Share this post


Link to post
Share on other sites

KJ,

 

The problem is that "Westchester County" is ambiguous because it is a substring of some of the other entries. One way you can fix this is to rename the New York - Westchester County zone to "New York - Westchester County (Other town)" or some such.

 

I should look to see if I can modify the osC code that does this check, as if you are using my contrib, the check is not required. If a country has zones, they will be selected from a list and not free-form entered, so there's no point in doing the lookup. When I get home tonight I'll figure out what the code change should be and let you know. But you probably do need something to indicate that you mean "other town not listed".

 

Thanks for the banner offer, but I don't do banners.

Share this post


Link to post
Share on other sites

Hey Steve,

Thanks for the clear-cut answer! It's hard to get that from some forum responses.

 

So if there isn't a fix you can come up with I guess I could make it

Westchester County-

(the dash would nulify the substring?)

 

Let me (us) know (a fix would rectify more than just me). I'm sure somebody else has come up with this. And yes I'm using your Contrib on the Country-State selector (thanks, I hear the later ver of osC will have this by default?)

 

Thanks much, Your a good person for sure!

KJ


define('PROJECTS', 'Something that goes on forever!');

Share this post


Link to post
Share on other sites

Try this. In create_account.php, find these lines (around line 136):

    if (ACCOUNT_STATE == 'true') {
     $zone_id = 0;

change this to:

/*
   if (ACCOUNT_STATE == 'true') {
     $zone_id = 0;

at around line 158, find these lines:

    }

   if (strlen($telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {

change these to:

    }
*/
   if (strlen($telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {

 

I think that will take care of it. Let me know how it works out. I looked at address_book_process.php and it does not have this problem.

Share this post


Link to post
Share on other sites

I think you have hit the nail on the head!

Tried entering in 3 to 4 different customers with & without the identicle (first words in the tax name) and seems OK!!

 

Thanks so much for the debugging :thumbsup: , for any folks in the future w/ these probs I'll paste the section of code with the rem statement:

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

        }

      }

    }

*/

    if (strlen($telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {

      $error = true;

 

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

    }


define('PROJECTS', 'Something that goes on forever!');

Share this post


Link to post
Share on other sites

Glad to hear it. The code I commented out is checking to see if the user-entered state matches one and only one zone for a country that has zones. But if you are using Country-State Selector, the user is forced to pick a zone from a list, so there is no chance for ambiguity. You can just remove the commented-out code, or leave it as-is, as you wish.

Share this post


Link to post
Share on other sites

Hi Steve,

 

Can someone help me pls? I already have a contribution installed that allows me to make my customer from the admin pannel (Customers Add ~ http://www.oscommerce.com/community/contributions,1644) and i disabled the create acount for visitors. So i have total control and make customer myself.

 

I was looking for something like your contribution - to make a Country-State selector, it sounds nice, so i installed it, and tested it (how it was meant to be on the create_acount for users, and it works nice)

 

But now i want to remove that 'create_acount' again so you can only make acounts in the admin. :s Is it easy to merge those two?? Cause right now i'm looking at bouth pages, but have no clue where i should put the updates from the create_acount in my customers.php page in admin :s

 

Has anyone tried this before? It shouldnt be to hard i think, cause my customers.php (with an "edit" button now) looks the same to fill in, but where i change the option to refresh it when you select your country (and prob some other modded code from the create_acount page?)

 

Can anyone help me here pls? IF you need code - i can send it, or post here, just let me know!

 

Thnx in advance, and this looks like a musthave contribution!!

Greets,

Tom


Even in this dark place, yes, I am afraid of my own shadow.

 

 

 

Contributions | KnowledgeBase | osCommerce 2.2 pdf

Share this post


Link to post
Share on other sites
Hi Steve,

 

Can someone help me pls? I already have a contribution installed that allows me to make my customer from the admin pannel (Customers Add ~ http://www.oscommerce.com/community/contributions,1644) and i disabled the create acount for visitors. So i have total control and make customer myself.

 

I was looking for something like your contribution - to make a Country-State selector, it sounds nice, so i installed it, and tested it (how it was meant to be on the create_acount for users, and it works nice)

 

But now i want to remove that 'create_acount' again so you can only make acounts in the admin. :s Is it easy to merge those two?? Cause right now i'm looking at bouth pages, but have no clue where i should put the updates from the create_acount in my customers.php page in admin :s

 

Has anyone tried this before? It shouldnt be to hard i think, cause my customers.php (with an "edit" button now) looks the same to fill in, but where i change the option to refresh it when you select your country (and prob some other modded code from the create_acount page?)

 

Can anyone help me here pls? IF you need code - i can send it, or post here, just let me know!

 

Thnx in advance, and this looks like a musthave contribution!!

Greets,

Tom

 

 

Noone can help me?


Even in this dark place, yes, I am afraid of my own shadow.

 

 

 

Contributions | KnowledgeBase | osCommerce 2.2 pdf

Share this post


Link to post
Share on other sites

Hi Steve,

On the following fix I have found a problem that now exists on that page. When a "new" customer signs up and selects a tax region upon checkout he is not getting charged any tax? (even though he is tied to a tax field) Something get cut out that maybe needs to be there for this?

Thanks, KJ

 

/*    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);

        }

      }

    }

*/


define('PROJECTS', 'Something that goes on forever!');

Share this post


Link to post
Share on other sites

darklings, sorry, I can't help as I am unfamiliar with that contribution.

 

KJ, it sounds to me as if you have not correctly included your newly created zones in a tax zone. This really is not related to C-S Selector - rather, you specify which zones go in which tax zones in admin.

Share this post


Link to post
Share on other sites

Hi Steve,

 

It was OK before the code remark. So... I went back in and took out the rem statement (create_account.php) that we put in and now the tax gets applied to a new customers again (did several bogus sales to test). Only thing now is the ambiguos strings or identicle starting tax names won't work again. (for anybody wondering what that is read this thread about 5 posts before.)

 

Any thoughts to the part of this code that we rem'd that could be needed by osC tax calculation or a tie-in with the proper tax field??

By the way, with the statement rem'd, the only way to get tax on the sale was to edit the account after it was origianally setup. Then the tax did get applied correctly.

 

As mentioned I could rename the (prefixed) state names but that would'nt solve your contrib's slight bug and I would like to work on correcting it rather than running around the problem.

 

Pls let me know what I can try???

 

Thanks much!

 

--KJ


define('PROJECTS', 'Something that goes on forever!');

Share this post


Link to post
Share on other sites

Hello there,

 

Is it correct, that when I have the contribution installed, the State Name is represented by the state code (e.g. instead of Ain it will display 01). Can this somehow be changed? It apprears to look good in the admin interface (there there is written Ain, instead of 01), but in the /catalog/ I always and everywhere get the ID (it seems to come from the database) and I also get the Emails with 01 in it.

 

Thanks for an answer and best regards,

 

 

Pascal

Edited by ps05

Share this post


Link to post
Share on other sites
No, that is not correct.  The user should see the state name (zone_name).

 

Any way to show the user the state name? Or is that impossible?

 

Thanks for the help.

 

Cheers,

 

Pascal

Share this post


Link to post
Share on other sites
The user DOES see the state name, if you have installed it correctly.  For a demonstration, see my web store www.cheshiregarden.com

Hi, Thanks for the great contribution. My prob is that I want the country to say Canada only with the pull-down for Provinces but I have "please select" for country first. What do I need to change???

 

Thanks

My Webpage

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×