Jump to content
stevel

Country-State Selector

Recommended Posts

Hmm. I think it should be ok to add, after the assignment to $process_okay, this line:

 

 $refresh = (isset($HTTP_POST_VARS['action'])  && ($HTTP_POST_VARS['action'] == 'refresh'));

That should suffice for this edit.

Share this post


Link to post
Share on other sites
Stefano,

 

Thanks for the kind words and the reference to Kitty Angels.

 

What you want should not be difficult.  Let me think about it for a while and I'll get back to you.  The harder part is not allowing the user to leave it as "please select", but I know how to do that.

 

Did anyone get a solution to the "Please select" as an option for states ?

 

Regards

 

Paul :huh:

Share this post


Link to post
Share on other sites
Did anyone get a solution to the "Please select" as an option for states ?

 

Regards

 

Paul :huh:

 

 

I noticed if the user selects "Please Select" it allows the user to type in anything for state (no select box). Is this what you are referring to? I too would like a fix for this. I've looked in the files for a way to make "please select" the default, but can't see an easy way. Anyone find a fix?

 

Thanks :) This contrib makes it easier on us shop owners. Anything that keeps us from having to fix little errors and mistakes from customers all day long is wonderful in my book.

Share this post


Link to post
Share on other sites

WebPixie, I am confused by your comment. As currently implemented, you don't see a "Please Select" as an option using Country-State Selector. If this were added, it would appear only for those countries which had zones defined, requiring that the customer use the dropdown list to select a zone (state). For countries without defined zones, a plain text box would appear.

 

I'll see what I can come up with for adding a "Please Select".

Share this post


Link to post
Share on other sites
WebPixie, I am confused by your comment.  As currently implemented, you don't see a "Please Select" as an option using Country-State Selector.  If this were added, it would appear only for those countries which had zones defined, requiring that the customer use the dropdown list to select a zone (state).  For countries without defined zones, a plain text box would appear.

 

I'll see what I can come up with for adding a "Please Select".

 

 

My form has a "please select" on the country select.... it shows the default country when you first load the page, but the pull down has please select as the first option which you can select and causes trouble :( Now I'm confused! -lol-

Share this post


Link to post
Share on other sites

Ok, this is actually pretty easy. What you want to do is prevent "Please Select" from being included in the list.

 

In includes/functions/html_output.php, in function tep_get_country_list, at around line 292, replace:

   $countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));

with

    $countries_array = array();

 

The only use for this Please Select line is if there is no default country, and osC makes no attempt to protect against a user selecting that - if they do, you end up with the first country on the list (Afghanistan).

 

I had dabbled with the HTML attribute DISABLED, but it doesn't work if that option is the default, as it would be in a stock install. With Country-State Selector, there's no need for Please Select, so the above change removes it.

 

I'll include this in a future update to the contrib. Thanks for the idea.

Share this post


Link to post
Share on other sites

Hi Steve,

 

Thanks for the lovely contribution. I installed it cut and paste as my store is heavily modded. I also ran the sql file for uk counties to add them to zones. Instead of changing my default country (UK) to 223 in the database, I changed you default file statement to 222 to match the uk. That is fine.

 

My problem is that there is no drop down box in 'state'. It is a plain blank text box which (i suppose) should contain all the english counties. Someone has asked this question in this thread before, but i didnt see a reply. Any help? BTW the offending page is http://www.huskyz.com/catalog/create_account.php

Share this post


Link to post
Share on other sites

Make sure that the country code you chose, 222, matches that in the UK zones you loaded. The symptom you describe is caused by no zones defined for that country code. This isn't something I can diagnose by looking at the web page.

Share this post


Link to post
Share on other sites
Make sure that the country code you chose, 222, matches that in the UK zones you loaded.  The symptom you describe is caused by no zones defined for that country code.  This isn't something I can diagnose by looking at the web page.

 

Hi Steve

 

Thanks for the rapid response, I still have all the files open that I have modified so that I can revert them to their previous state if something goes wrong so that is a real help.

 

222 was the code that was in the database for United Kingdom, so that is the one I used. I have checked the USA and the same thing happens, no drop down box. In fact I dont get a drop down box for aby of the countries (tested).

 

All the counties are defined as zones for the uk country. I must have done something wrong.... Doesn't the country number (223) part of the mod just change the default country in the "country" drop down box?

 

Anyway, be grateful for any further help.

Kind regards

Kim

Share this post


Link to post
Share on other sites

Have tested since then..., after the first try at filling in the for, the page refreshes and the drop down box appears with the counties (hooray) but, when you enter the chosen county, the page refreshes and comes up with the error

 

Error Please select a state from the States pull down menu.

 

even though the state has been selected

 

any ideas?

 

cheers

Kim

 

Hi Steve

 

Thanks for the rapid response, I still have all the files open that I have modified so that I can revert them to their previous state if something goes wrong so that is a real help.

 

222 was the code that was in the database for United  Kingdom, so that is the one I used. I have checked the USA and the same thing happens, no drop down box. In fact I dont get a drop down box for aby of the countries (tested).

 

All the counties are defined as zones for the uk country. I must have done something wrong.... Doesn't the country number (223) part of the mod just change the default country in the "country" drop down box?

 

Anyway, be grateful for any further help.

Kind regards

Kim

Share this post


Link to post
Share on other sites
Have tested since then..., after the first try at filling in the for, the page refreshes and the drop down box appears with the counties (hooray) but, when you enter the chosen county, the page refreshes and comes up with the error

 

Error Please select a state from the States pull down menu.

 

even though the state has been selected

 

any ideas?

 

cheers

Kim

 

OK, sorry to be such a gasbag, but I have worked out the problem. As I said, my shop is already heavily modded....I have the BTS mod working on it. When I inserted the new code in all the files, I left out the html as all the html is dealt with in the template files.

 

Of course, I didnt update the template files with the necessary html files. Also, I seem to have run a zone sql twice, so each county was listed twice. I am sure this didnt help. I have scrubbed the lot and I am trying again tomorrow when everyone is out!

Share this post


Link to post
Share on other sites

Ok me again, I feel like I am speaking to only me..I suppose the first sign of madness.

 

I have made a clean install of your lurrrrverlllyyy mod and I now have it working. I installed the latest edition with all the extra stuff in the javascript file. However, i am still coming up with the same problem as described by others: When I change country, the page does ot refresh the state drop down box. For example, my default is united kingdom, and if I change it from that to (for instance) the USA, the zones in the 'state' dropdown box remain UK counties and not US states.

 

I have 2 form_check.js.php files and I have changed added the new code to both of them. I use the latest firefox, but have tested in IE6 also and the problem is the same, no refresh of 'states' dropdown box.

 

Any help or suggestions would be greatly appreciated Steve.

 

Cheers

kim

Share this post


Link to post
Share on other sites

Kim,

 

Your create_account page is not including form_check.js.php at all. NONE of the JavaScript is appearing in the page. Please make sure that this file is properly included. There should be a line similar to the following:

<?php require('includes/form_check.js.php'); ?>

somewhere between <head> and </head>.

 

To verify this, load the page in the browser and then do a "view source" in the browser (varies by browser type just how you do this). Look to see if there is JavaScript code between <head> and </head> including a "refresh_form" function.

 

I'm sorry I didn't respond to your messages from yesterday - I didn't see a notification in e-mail of them.

Share this post


Link to post
Share on other sites

Hey Steve

 

Thanks for the reply, I did as you advised. There is no html in my create_account.php because it should be dealt with by create_account.tpl.php fpr the bts contribution. I have created a head tag in create_account.php and included the above code. As a belt and braces kind of girl, I also included it in the create_account.tpl.php file. I know that php is very forgiving, but can javascript cope with being told to do the same thing twice?

 

On view source, I now get javascript messages, but the darn page still isnt doing it's job, I cant see a refresh in the view source code for the 'country' 'state' elements of the page, but then I know less than my cat about javascript...just common sense.

 

I can see we are getting close, this is driving me insane....would you have a look at my page source again?

 

Really appreciate all the support you are providing with this mod.

 

cheers

Kim

Share this post


Link to post
Share on other sites

Well, you have other problems now - perhaps an errant blank line after a closing ?> in an include file. But you have not made the following edit:

 

Replace:

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

 

with:

 

                <?php // +Country-State Selector ?>
               <td class="main"><?php echo tep_get_country_list('country',$country,
                  'onChange="return refresh_form(create_account);"') . ' ' . 
                  (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . 
                  '</span>': ''); ?></td>
               <?php // -Country-State Selector ?>

This is the guts of the contribution - without it, nothing will work.

Share this post


Link to post
Share on other sites

Thanks Steve, you were absolutely right, (bashes forehead on desk)

 

The problems were that :-because of BTS, some of the new code had to go in template files instead of the create_account.php... Those of us that have installed the BTS mod will need to change code in mainpage.tpl.php, create_account.tpl.php and create_account.php

 

If anyone with the BTS contribution wants to install this, (for the create_account.php changes) if they pull up mainpage.tpl.php, create_account.tpl.php and create_account.php in Dreamweaver they can do it with a Find - Replace function, so long as they check on each file.

 

I have to say again, this is a really great mod, thank you sincerely for your hard work and support.

 

thanks loads

Kim

Share this post


Link to post
Share on other sites

First off,

Is this a typo?

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin=^quot;0" rightmargin="0"

 

in regards to leftmargin?

 

Second, is this last > supposed ot be in this code?

 

<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin=^quot;0" rightmargin="0"

<?php // +Country-State Selector

if ($refresh) {echo ' onLoad="document.addressbook.state.focus();"';}

// -Country-State Selector?>

>

 

 

I am having an issue during the account creation process. Below "Your Address" This is echod out in the info box where you put this info: an class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '': ''); ?>

 

I am sure it's on my end and will be doing things over carefully again to ensure it isn't the contrib. The other questions I have may lend merit to my question or again maybe they just belong there and I screwed up (most likely) :)

 

S

Share this post


Link to post
Share on other sites

ACtually yes that was the problem. The typo of leftmargin=^quot;0 should be leftmargin="0"

Probably seems like common sense to those with php experience, I however take everything literally so as not to screw things up ehhe.

 

Might want to update the contrib.

 

Thanks for this contrib - other than that, easy to install.

Share this post


Link to post
Share on other sites

HI all,

 

I have installed this contribution offline (osc) and works very nicely.

 

My question is: is there the possibility or is there another contribution which the user can drill down still to Suburb?

ie:

1 - Choose country first

2 - Choose State/Province

3 - Chose Suburb or City (after having chosen the State/province

 

Thanks

 

Salvo

Share this post


Link to post
Share on other sites

You would have to add a new table that lists the suburb or city for each zone and add code similar to what this contribution has to display it. Seems like a lot of work unless you sell within a small region only. It also seems more prone to error - if you have such a list, you must make sure that there are no omissions of cities or suburbs customers might want to enter.

Share this post


Link to post
Share on other sites

Thanks for answering Steve.

 

if it is a lot of work, I might I let it be... what I might do in the future unless someone has done already, is to create a drop down menu for the SUBURBS. I only need them for 1 country, 1 provice, (about 120 suburbs codes). not all countries.

 

The suburbs would show using the if statement...

 

Thanks

 

Salvo

Edited by Salvo

Share this post


Link to post
Share on other sites

First of all, thanks for the great contrib, I hated the idea of people typing their state name in manually.

 

I just have a few questions relating to using the contrib with a template system like BTS. I have read this whole thread (which I never do : ) and saw that battleaxe also uses BTS. She said she modified several files including mainpage.tpl.php which I also modified to get this working on my end. I am not sure what all you (battleaxe) put in which files but since I couldnt find anywhere else to put the replacement body tag I stuck it in mainpage.tpl.php. Everything is working and this is probably more of a template question than it is a question about this contrib but .. what happens if I go to install another contrib that replaces the body tag? For instance, I believe that this contib calls for the body tag to be replaced in more than one file but since there is only one mainpage.tpl.php I could only put it there.

 

If someone could, please explain how all this works with the template system.

 

I appreciate the help in advance!!

 

Craig

 

P.S. Has anyone made a contrib to take a zip code that has been entered and auto complete the city and state? I know a lot of software has this now, I wonder how hard it would be to do with OScommerce?

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

×