Jump to content
stevel

Country-State Selector

Recommended Posts

Right - what I meant was that the only changes in 1.0.4 are newly-edited files; there are no changes to files edited in 1.0.3. But the ZIP file has edited copies of ALL the relevant files. (I hate contributions where you have to guess as to which of multiple downloads you need.)

 

Let me know here if you have any problems or questions.

Share this post


Link to post
Share on other sites

Okie Doke. The HTML doesn't show what edits are in usps.php.

The HTML, near the end, shows catalog/includes/modules ... but what file? (assuming checkout_new_address).

I'm having to crawl thru usps.php 'cuz mine is already modded.

Still looking for any other errors.

Hope these help.

--Jeff


--Jeff

Of course I don't look busy! I did it right the first time!

Share this post


Link to post
Share on other sites

And I don't see the usps.php on your html list of files, so now I'm wondering if it's there in zip by mistake? It looks like a relatively original file, so maybe there are no edits? (Mostly thinking outloud)...

--Jeff


--Jeff

Of course I don't look busy! I did it right the first time!

Share this post


Link to post
Share on other sites

Here's what I did to make the input on create_account a little more "logical" with the screen refresh and all:

(This is lines 439-521 on my modded file, the real point is between CATEGORY_ADDRESS and ENTRY_STREET_ADDRESS):

<?php
 }
?>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td class="main"><b><?php echo CATEGORY_ADDRESS; ?></b></td>
     </tr>
     <tr>
       <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
         <tr class="infoBoxContents">
           <td><table border="0" cellspacing="2" cellpadding="2">
	 <tr>
               <td class="main"><?php echo ENTRY_COUNTRY; ?></td>
   <?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 ?>
             </tr>
 <tr>
      	 <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
    	 </tr>
             <tr>
               <td class="main"><?php echo ENTRY_STREET_ADDRESS; ?></td>
               <td class="main"><?php echo tep_draw_input_field('street_address') . ' ' . (tep_not_null(ENTRY_STREET_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_STREET_ADDRESS_TEXT . '</span>': ''); ?></td>
             </tr>
<?php
 if (ACCOUNT_SUBURB == 'true') {
?>
             <tr>
               <td class="main"><?php echo ENTRY_SUBURB; ?></td>
               <td class="main"><?php echo tep_draw_input_field('suburb') . ' ' . (tep_not_null(ENTRY_SUBURB_TEXT) ? '<span class="inputRequirement">' . ENTRY_SUBURB_TEXT . '</span>': ''); ?></td>
             </tr>
<?php
 }
?>
             <tr>
               <td class="main"><?php echo ENTRY_CITY; ?></td>
               <td class="main"><?php echo tep_draw_input_field('city') . ' ' . (tep_not_null(ENTRY_CITY_TEXT) ? '<span class="inputRequirement">' . ENTRY_CITY_TEXT . '</span>': ''); ?></td>
             </tr>
<?php
if (ACCOUNT_STATE == 'true') {
?>
             <tr>
             <td class="main"><?php echo ENTRY_STATE; ?></td>
             <td class="main">
<?php
// +Country-State Selector
       $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']);
       }
 if (count($zones_array) > 0) {
         echo tep_draw_pull_down_menu('state', $zones_array);
 } else {
   echo tep_draw_input_field('state');
 }
// -Country-State Selector
   if (tep_not_null(ENTRY_STATE_TEXT)) echo ' <span class="inputRequirement">' . ENTRY_STATE_TEXT;

?>
             </td>
           </tr>
<?php
}
?>
    <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>
             
             <!--PUT COUNTRY HERE, OLD SPOT-->
           </table></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td class="main"><b><?php echo CATEGORY_CONTACT; ?></b></td>
     </tr>

 

The benefit only being that the user inputs the country first, then the rest of the address and state after the country has refreshed the page. A little space after the country input helps separate it from the rest. Maybe one could then remove the "Select country first" from the state input with this change.

Just an idea.

I like your contrib the best so far, Steve. Works great, and solved the problem I asked about on another posting earlier today (the state getting set back to default if an input eror occurs. Yours remains as selected! :D )

 

Well Done!

--Jeff


--Jeff

Of course I don't look busy! I did it right the first time!

Share this post


Link to post
Share on other sites

I don't see usps.php in the ZIP file I uploaded. (Nor in the one I just downloaded from the Contributions site.) You had me going for a moment, because I WAS playing with usps.php at around the same time, but I don't see how I could have mixed it in. Please double-check this.

 

I thought about prompting for the country first, but that seemed a bit awkward in its own right, and the default will be correct for 99% of my customers. Feel free to rearrange things as you like (for example, I move the POSTCODE to after the state.)

Share this post


Link to post
Share on other sites

I installed this but during account creation where it has Country (Page will refresh when changed), it doesn't refresh.


Keith

 

 

What the hell was I thinkin'?

Share this post


Link to post
Share on other sites

Turn on reporting of scripting errors in your web browser. (In MSIE, this is Options..Advanced..Display a message for every script error.) Then try again and see if you get an error. My guess is that you've either specified the onChange incorrectly or did not properly update the form_check_js.php file.

 

Alternately, compare your files with the one in the zip file, and see what's different.

 

Oh yeah - if you have Javascript disabled, it won't refresh.

Edited by stevel

Share this post


Link to post
Share on other sites

I am getting an error---Object expected Line 419 char 1

 

 

I just used the files contained in the contrib

Edited by wvmlt

Keith

 

 

What the hell was I thinkin'?

Share this post


Link to post
Share on other sites

That seems odd. Line 419 of the HTML file you get from the contrib files is:

   </tr>

hardly likely to cause a problem.

 

Did you do the update of form_check_js.php?

 

If you're stuck, do a Save as HTML of the create_account page from your browser and e-mail it to me at webmaster at cheshiregarden dot com - I'll take a look. But before you do this, please go back and double and triple check that you used all the appropriate files, including form_check_js.php

Share this post


Link to post
Share on other sites

I rechecked all files and all were ok. Here's the weird part. I reloaded my old files and I still get errors. Apparently, it's not a problem with this contribution but rather a problem in my catalog. Try it here.


Keith

 

 

What the hell was I thinkin'?

Share this post


Link to post
Share on other sites
I don't see usps.php in the ZIP file I uploaded. (Nor in the one I just downloaded from the Contributions site.) You had me going for a moment, because I WAS playing with usps.php at around the same time, but I don't see how I could have mixed it in. Please double-check this.

 

I thought about prompting for the country first, but that seemed a bit awkward in its own right, and the default will be correct for 99% of my customers. Feel free to rearrange things as you like (for example, I move the POSTCODE to after the state.)

 

Oboy, this is weird. I double checked the zip, and the CONTENTS of the zip show no usps.php, but the unzipped folders/files that got created DO contain a shipping/usps.php. Very strange. :huh:

I point the error to my system, wherever it may be, not at your zip file, so I'll look into it on my side. Not that it matters anyway, the contrib works great as you uploaded it and I'm quite happy with the results.

As to the order of the State/Country/Post Code, I do have a few CAN customers, but mostly US, so to list a defaulting US country first is no big deal, but still allows folk to change it and have a refreshed screen b4 entering the rest of the data. Looks weird, but not weird enough for me to worry.

I do agree, the Postal Code goes after the state. Why osC defaults to before? I have no idea. THAT is goofy.

Good Job, Steve!

--Jeff


--Jeff

Of course I don't look busy! I did it right the first time!

Share this post


Link to post
Share on other sites

Just wanted to say again that this is an awesome contribution. I wish I had waited a few days because I had already incorporated this into the checkout pages as well. :lol:

 

One thing I noticed when going through your code was that the checkout pages do not reload because there's no onChange= in the form. I simply changed line 117? in /catalog/includes/modules/checkout_new_address.php from this:

 

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

 

to this:

 

<td class="main"><?php echo tep_get_country_list('country', $entry['entry_country_id'], 'onChange="return refresh_form(checkout_address);"') . ' ' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?></td>

 

The change made is simply adding

, $entry['entry_country_id'], 'onChange="return refresh_form(checkout_address);"'

to the tep_get_country_list() function.

Share this post


Link to post
Share on other sites

Sigh. The change is in the included file but I missed it for the instructions. (It didn't help that I left out the name of the file too!) Thanks for picking up on that - I'll reload the contrib (yet again!)

Share this post


Link to post
Share on other sites

I have some languages.

Does not refreshe STATE in the other language, works only in English.

 

Please help me.

Thx.

Share this post


Link to post
Share on other sites

Please explain the problem in more detail. What page are you on when the problem occurs? What do you do to make the problem appear? What is different in the way the page refreshes? I tried some test cases with Spanish and it seemed to work ok. I can't thinl of a language-related problem unless you didn't define DEFAULT_COUNTRY for your language.

Share this post


Link to post
Share on other sites

Steve.

 

You know when anyone writes a topic, they say "i'm not sure if this has been asked or mentioned before", it means i have not checked and here goes! :P

 

Well here it is - Have used the latest update (country-state-selector_1_2_3_4.zip) and the last instruction reads "catalog/includes/modules" no file name. I assume you mean the "checkout_new_address.php".

 

Not too important but thought i would let you know - keep up the good work.

 

Andy

Share this post


Link to post
Share on other sites
Please explain the problem in more detail. What page are you on when the problem occurs? What do you do to make the problem appear? What is different in the way the page refreshes? I tried some test cases with Spanish and it seemed to work ok. I can't thinl of a language-related problem unless you didn't define DEFAULT_COUNTRY for your language.

At me stands two languages: English and Russian. It is by default established - the English language. In English there is a refreshing all pages, in Russian does not refreshing. Put by default Russian, all the same does not work.

To look it is possible here.https://gsmrepair.net/create_account.php

 

Please help me!!

Share this post


Link to post
Share on other sites

I don't know what the problem is. I've compared the sources for English and Russian and the code for the refresh looks the same. Has anyone else encountered a problem using this contribution with non-English langauges?

Share this post


Link to post
Share on other sites

Scorpic, I took another look at your site. I am going to guess that the problem is that you have "Search Engine Friendly URLs" turned on. I don't know why this might make a difference, but try turning it off - that feature isn't needed anyway.

Share this post


Link to post
Share on other sites
Scorpic, I took another look at your site. I am going to guess that the problem is that you have "Search Engine Friendly URLs" turned on. I don't know why this might make a difference, but try turning it off - that feature isn't needed anyway.

I have tried to "Search Engine Friendly URLs" switch off it. But not that has not changed, also does not work. :(

Share this post


Link to post
Share on other sites

Ok, I'll play with it some more to see if I can figure it out, but it may be a few days.

 

I did note that you don't set the default country, though I don't think that would make a difference and that is optional.

Share this post


Link to post
Share on other sites

I just followed what you've said.

 

But, on the top of the creat_account.php page, an error message comes up..

 

 

function refresh_form(form_name) { form_name.action.value = 'refresh'; form_name.state.value = ''; form_name.submit(); return true; }

 

What is the problem and how can I get rid of this?

 

Thanks for your hard work on this contribution.

Share this post


Link to post
Share on other sites

when i select a country from the drop down menu, it does not update the states. any suggestions?

Share this post


Link to post
Share on other sites

jjanguda, sorry, I did not see your earlier post on this. What is the error message?

 

durbin, does the page refresh at all? If not, the JavaScript function is returning an error. Which page is it doing this on? Got a link I can try?

Edited by stevel

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

×