stevel Posted August 1, 2004 Author Share Posted August 1, 2004 No, but I'm experienced at debugging from limited information - it's a lot of what I do at work! Glad to hear that you're in business again. Quote Steve Contributions: Country-State Selector Login Page a la Amazon Protection of Configuration Updated spiders.txt Embed Links with SID in Description Link to comment Share on other sites More sharing options...
avery Posted August 1, 2004 Share Posted August 1, 2004 Hi Steve, I opted for your contribution after all and it works fine. I've got the default country as UK and Outside US and Canada showing in the State box by entering it on thedatabase as a UK zone id, and everything is passed ok to 2checkout, all the customer needs to do is enter credit card details. I'm going to delete all other countries from the database leaving only UK with one state namely Outside US and Canada. Can these fields be hidden easily on the create account page with your contribution installed? Andrew Quote Link to comment Share on other sites More sharing options...
stevel Posted August 2, 2004 Author Share Posted August 2, 2004 (edited) Hah - that was the solution I was originally going to give you, then I thought better of it. Try this. Find the code that starts: <?php if (ACCOUNT_STATE == 'true') { ?> <tr> Replace this and up to the </tr> with: <?php echo tep_draw_hidden_field('state','Outside US and Canada'); ?> I think that will work, but it will also show the phony 'state' to the customer when their address is displayed. There are ways of dealing with that. Edited August 2, 2004 by stevel Quote Steve Contributions: Country-State Selector Login Page a la Amazon Protection of Configuration Updated spiders.txt Embed Links with SID in Description Link to comment Share on other sites More sharing options...
Heath34 Posted August 3, 2004 Share Posted August 3, 2004 I have completed this install to the best of my ability, but have one small problem. I can't get the default country to work. I deleted all countries except USA. I then set this in english.php: ('DEFAULT_COUNTRY', '1') Should this not make USA selected automatically? Quote Link to comment Share on other sites More sharing options...
stevel Posted August 3, 2004 Author Share Posted August 3, 2004 The number is the country code in the database record. Deleting other entries won't change that. Try '223'. Quote Steve Contributions: Country-State Selector Login Page a la Amazon Protection of Configuration Updated spiders.txt Embed Links with SID in Description Link to comment Share on other sites More sharing options...
Heath34 Posted August 3, 2004 Share Posted August 3, 2004 Thanks. That fixed it. I'm an idiot:) Heath Quote Link to comment Share on other sites More sharing options...
Heath34 Posted August 3, 2004 Share Posted August 3, 2004 I just noticed that even though USA is selected as the country, there are some weird "States" listed in the State drop-down box (like Federated States of Micronesia & Patau). Is there a way to fix this list so that there are only US States? Quote Link to comment Share on other sites More sharing options...
stevel Posted August 3, 2004 Author Share Posted August 3, 2004 You can remove states you don't want under Zones in admin. Quote Steve Contributions: Country-State Selector Login Page a la Amazon Protection of Configuration Updated spiders.txt Embed Links with SID in Description Link to comment Share on other sites More sharing options...
Heath34 Posted August 3, 2004 Share Posted August 3, 2004 Thanks again! Great contribution... really helps! Heath Quote Link to comment Share on other sites More sharing options...
ChrisW123 Posted August 7, 2004 Share Posted August 7, 2004 Thanks Steve for the Great Contribution! It works perfectly the first time and is a huge improvement! -Chris. Quote Link to comment Share on other sites More sharing options...
oz16oz2 Posted August 19, 2004 Share Posted August 19, 2004 Fantastic contribution. Thanks for this, Steve. I haven't read this whole thread, but I'm wondering if there's a way to omit the "State/Province" box for countries that don't have States/Provinces? I'm in Australia, and New Zealand doesn't have any states, so those customers always wonder what to put in the state box (plus, if you copy and paste for invoicing/print-outs, it's got extra junk info in there). Also (and this is off-topic, but refers to the same page we're all looking at), is there an easy way to make the date of birth an optional field? Again, thanks for this contribution Steve. OZ Quote Link to comment Share on other sites More sharing options...
ecoloco Posted August 19, 2004 Share Posted August 19, 2004 (edited) Hello Steve!!, I just installed your contribution and I seem to have a problem on checkout_shipping_address.php and payment_shipping_address.php; when I change the country the page wil not reload and change the states. I have read the whole thread and tried the fix on the "tep_get_country_list" at the end of checkout_shipping_address.php but it didn't work. I don't have any template system. I tried the FireFox fix that you suggested and still not working. This is weird since I have the latest version of the contribution. Do you have any suggestions on how to fix? Thank You in advance. Your contribution is helping a lot. Edited August 19, 2004 by ecoloco Quote Link to comment Share on other sites More sharing options...
stevel Posted August 19, 2004 Author Share Posted August 19, 2004 Hugo, Thanks for the kind words. This symptom happens when the JavaScript function refresh_form fails. Try the alternative shown here. The original code works in some browsers, but not all. I have some tweaking I want to do and I will release an update of the contribution. Quote Steve Contributions: Country-State Selector Login Page a la Amazon Protection of Configuration Updated spiders.txt Embed Links with SID in Description Link to comment Share on other sites More sharing options...
ecoloco Posted August 21, 2004 Share Posted August 21, 2004 I tried that fix already Steve and still not working. Any other ideas? Thanks!! Quote Link to comment Share on other sites More sharing options...
stevel Posted August 21, 2004 Author Share Posted August 21, 2004 Do you have a URL I can look at? Quote Steve Contributions: Country-State Selector Login Page a la Amazon Protection of Configuration Updated spiders.txt Embed Links with SID in Description Link to comment Share on other sites More sharing options...
ecoloco Posted August 22, 2004 Share Posted August 22, 2004 I just fixed the problem Steve!. I looked for any mistakes or problems on your code on my own and everything looked like it was in its place. After several modifications I realized that only some part of the javascript code was working but not only in my store but also in other pages that used javascript. Obviously the problem was not your code but some problem with script handling. I am editing my store locally in a Windows Xp based system, and after some research it turned out that the Windows Update function included with the OS sometimes can accidentaly damage some core windows components. In my case is was the Windows Script component, which impacts IE and the whole windows system. I reinstalled version 5.6 of this component and everything is working now. So, maybe this can work for all of those that are working under windows and "mysteriously" the refresh function, or any other, stops working. Quote Link to comment Share on other sites More sharing options...
stevel Posted August 22, 2004 Author Share Posted August 22, 2004 Interesting. I have not seen this on my XP system. I will note that the refresh feature requires JavaScript to be enabled; I wonder if I could make something that worked with an explicit link to do the change in the absence of JavaScript. Ah, so many ideas, so little time... A good debugging technique if you are having trouble with the refresh is to enable script error reporting in your browser. It is usually a failure in the refresh_form script that is the problem. The other common error is to not be using the correct JavaScript file at all. Quote Steve Contributions: Country-State Selector Login Page a la Amazon Protection of Configuration Updated spiders.txt Embed Links with SID in Description Link to comment Share on other sites More sharing options...
qqvrec Posted August 29, 2004 Share Posted August 29, 2004 Hi, Just a small query. After a page has been refreshed is there a way of returning it to its original position (before the country selection was changed). I (think) I'm referring to the vertical and horizontal scroll. Thanks, Chris Quote Link to comment Share on other sites More sharing options...
stevel Posted August 29, 2004 Author Share Posted August 29, 2004 Hmm - I think so. Let me do some experiments. Quote Steve Contributions: Country-State Selector Login Page a la Amazon Protection of Configuration Updated spiders.txt Embed Links with SID in Description Link to comment Share on other sites More sharing options...
stevel Posted August 30, 2004 Author Share Posted August 30, 2004 Ok, two enhancements for the price of one (or none, since this is all free!) The refresh logic can be considerably simplified. 1) In catalog/includes/form_check.js.php, in function refresh_form, delete the line: form_name.state.value = ''; If you used the replacement logic suggested earlier in this thread, the entire change to this file is to add these lines, removing all previous changes: <?php // +Country-State Selector ?> function refresh_form(form_name) { form_name.action.value = 'refresh'; form_name.submit(); return true; } <?php // -Country-State Selector ?> 2) In catalog/create_account.php, replace the first change group (after $process = false;) with this // +Country-State Selector $refresh = false; if (isset($HTTP_POST_VARS['action']) && (($HTTP_POST_VARS['action'] == 'process') || ($HTTP_POST_VARS['action'] == 'refresh'))) { if ($HTTP_POST_VARS['action'] == 'process') $process = true; if ($HTTP_POST_VARS['action'] == 'refresh') $refresh = true; // -Country-State Selector 3) Same file, replace third change group with this: // +Country-State Selector } if ($HTTP_POST_VARS['action'] == 'refresh') {$state = '';} if (!isset($country)){$country = DEFAULT_COUNTRY;} // -Country-State Selector 4) In catalog/address_book_process.php, replace second change group with this: // +Country-State Selector if ($refresh) {$state = '';} if ($process) { // -Country-State Selector That takes care of the refresh, and it should work in any browser with JavaScript support.. Now as to Chris' request - this can almost be done. The almost is because many browsers don't support repositioning to a "select" object (drop-down box). What I recommend is moving the country input to above the Street Address. This eliminates the need for text that says to change the country first, and allows a more natural repositioning. You do that by moving the <tr></tr> group containing the country input field to above the one for street address. You have to do this in create_account.php and includes/modules/address_book_details.php and checkout_new_address.php Now make the following changes: 1) In create_account.php, replace: <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> with <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" <?php if ($refresh) {echo ' onLoad="document.create_account.street_address.focus();"';} ?> > 2) In address_book_process, replace: <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0"> with <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" <?php if ($refresh) {echo ' onLoad="document.addressbook.street_address.focus();"';} ?> > This change depends on your also making the one above for the refresh logic. Please note that this second change is optional - but for some stores I can see that it would help. The only problem I see is that the focus doesn't move until the page fully reloads, and if the user starts typing before the load is done, the effect can be disconcerting. Please try this out and let me know what you think. If nobody finds problems, I'll roll it in to an update. Quote Steve Contributions: Country-State Selector Login Page a la Amazon Protection of Configuration Updated spiders.txt Embed Links with SID in Description Link to comment Share on other sites More sharing options...
qqvrec Posted August 30, 2004 Share Posted August 30, 2004 Thanks for the info Steve. There was one other thing I forgot to ask you about. Say if the user fills out all the form info before selecting their country (even if at the top of the form), and the current country has no zones, but the customers country does have zones. For example, my default country is the UK which has no zones, but the customer is from the USA and he's entered his two letter state abbreviation in the state field. Is there a way of getting the drop-down box to display the state that corresponds to the abbreviation entered when the form refreshes? Chris Quote Link to comment Share on other sites More sharing options...
stevel Posted August 30, 2004 Author Share Posted August 30, 2004 It could be done, sure, but is a lot more work. You would bring back some of the code that is in the standard osC distribution for looking up abbreviations, and have it called in the right place. I'm sorry, but that's a bit beyond what I'm willing to do - if you want to try it, please do. It doesn't seem to have much benefit to me, especially if you move the country select earlier in the form. Quote Steve Contributions: Country-State Selector Login Page a la Amazon Protection of Configuration Updated spiders.txt Embed Links with SID in Description Link to comment Share on other sites More sharing options...
Justin Posted September 6, 2004 Share Posted September 6, 2004 Congrats on a terrific contribution. I can't begin to tell you how happy I was when I came across it. Kudos! As we all know, some countries don't have states or provinces, and customers from these countries often don't know what to put in this field. Some will put things like "N/A," which store owners must then tediously remove before shipping. Moreover, several overseas customers have actually contacted me to request that the state/province field be changed so that it is not mandatory. If some people are annoyed enough to contact me about this, that means there are many more that are annoyed but don't bother to vocalize it. For me, the ideal behavior would be to have the state/province field be mandatory only when there is a pop-up (i.e., only when states/provinces are available for that country). When displaying an input field for the state/province (i.e., when no states/provinces are available for that country), that field shouldn't be mandatory. So, I decided to move the line for the "required" indicator up a few lines so that it's only displayed when states/provinces are available for that country. The state/provide block in my create_account.php now looks like this: // +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); if (tep_not_null(ENTRY_STATE_TEXT)) echo ' <span class="inputRequirement">' . ENTRY_STATE_TEXT; } else { echo tep_draw_input_field('state'); } // -Country-State Selector Unfortunately, this change is only aesthetic -- the javascript validation still complains if you try to submit the form without filling in the input field box for state/province. This makes my change above rather pointless, since now I'm telling customers that the state/province isn't mandatory even though the javascript validation will later say that it is indeed mandatory. Might there be a way to accomplish this feat properly? :) Sincere thanks in advance, Justin Quote Link to comment Share on other sites More sharing options...
stevel Posted September 6, 2004 Author Share Posted September 6, 2004 (edited) You could remove the JavaScript validation for STATE entirely, as they are guaranteed to supply one if there are zones defined for the country, and if not, you don't care about it. Remove or comment out (with a leading //) this line in form_check.js.php: <?php if (ACCOUNT_STATE == 'true') echo ' check_input("state", ' . ENTRY_STATE_MIN_LENGTH . ', "' . ENTRY_STATE_ERROR . '");' . "\n"; ?> Or, I think, you can set the minimum value for STATE in Admin to 0. I like this idea, actually... I'll incorporate it into the next revision. Thanks. Edited September 6, 2004 by stevel Quote Steve Contributions: Country-State Selector Login Page a la Amazon Protection of Configuration Updated spiders.txt Embed Links with SID in Description Link to comment Share on other sites More sharing options...
Justin Posted September 7, 2004 Share Posted September 7, 2004 I'm glad to hear my suggestion was of use. :D Thanks for the two solutions. I had already tried the latter method, which unfortunately doesn't appear to work. Commenting out the JavaScript validation, on the other hand, sounds like just the tip I was looking for. I'll give that a whirl tomorrow. Thanks again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.