Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Country-State Selector


stevel

Recommended Posts

If you just wanted to get rid of the 1 in that box, use the following code in your /includes/functions/ajax.php

 

Find this:

if ( tep_db_num_rows($zones_query) ) {
		$output .= tep_draw_pull_down_menu('zone_id', $zones_array, $default_zone);	  
	} else {
		$output .= tep_draw_input_field('state', $default_zone);
	}

 

Replace with this:

if ( tep_db_num_rows($zones_query) ) {
		$output .= tep_draw_pull_down_menu('zone_id', $zones_array, $default_zone);	  
	} else {
		if ($default_zone != '1') {
		$output .= tep_draw_input_field('state', $default_zone);
		}
		else
		{
		$output .= tep_draw_input_field('state', '');
		}
	}

Installed Modules:

Dynamenu, InfoBox Admin, Master Products v.1.2, Header Tags Controller, Multiple Products Manager, Quick Edit in Admin, Secure Admin, Ultimate SEO URL's, EZ Secure Order, Easy Populate v.2.76d MS2, AuthorizeNet_AIM, ChangeFinal Breadcrumb Title, FedEx Labels, Fedex Direct 2.06, How Did you Hear 1.5, Login a la Amazon, UPS XML 1.2.4, USPS Labels, USPS Methods API MS2

Link to comment
Share on other sites

I just installed the country-state selector contribution but when I go to create_account.php I am getting an error message.

 

Fatal error: Call to undefined function ajax_get_zones_html() in /home/sfrazier/public_html/store/create_account.php on line 423

 

 

I don't know where to fix this so I can get it working. Any help is appreciated.

 

Thanks!

Link to comment
Share on other sites

Well, there would have been an instruction to add that function to one of the files in catalog/includes/functions. Or you could install the 1.4 version that does not use Ajax.

Link to comment
Share on other sites

My apologies if this has been asked already.

 

Love this mod but just wondering if I can do this:

 

Prior to installing this mod, when the customer first entered the create account page the country drop down box looked like this:

 

PLEASE SELECT

 

United States

Canada

United Kingdom

Australlia

--------------------

 

Rest of the countries (it acutally listed the countries but of course I won't post them)

 

 

Since adding this mod that top portion is gone except "Please select" and I wonder if there is a way to add them like the above to this mod?

 

I never put the default country code on includes/language/english.php so the first parts shows "Please select"

 

Any assistance with this is greatly appreciated!

 

Thanks for the great mod.

Sincerely

Mike

Link to comment
Share on other sites

  • 4 weeks later...

I only wanted to show US and Canada in my country drop down, so there were two options. A). go into the database and delete all those countries that I didn't want. But if I decided to add one of those deleted countries back, I'd be hard pressed to remember the values associated with the records. I opted for method B)...

 

I added a column to the table of countries labeled 'active' and set the default to zero. Then I updated the table to set active=1 for those countries I wanted to show. Then in file /catalog/includes/functions/general.php I altered the query to get only those countries where active=1.

 

I did not build an interface for the admin, but the full instructions can be found on the contribution page: http://addons.oscommerce.com/info/2028

 

-- dmayo

Link to comment
Share on other sites

The bug fix written by Mthierfelder would remove the PHP error message but it causes the customer.php in the admin module loss the functionality for the "state" drop-down when you change the country drop-down.

 

 

The bug fix document says:

 

Replace:

 

if ($error == false) {

with:

 

// +Country-State Selector

} // End if (!$refresh)

if (($error == false) && ($refresh != 'true')) {

// -Country-State Selector

 

and replace the red-bold code with

 

// } End if (!$refresh)

 

After a few hours exploring the code, I finally noticed the bug actually exists in another place:

 

 

1. restore to its original code, i.e. the code from the original author is actually correct:

} // End if (!$refresh)

 

 

2. The bug exist here:

 

original documentation says:

-------------

Line 196:

 

Replace:

 

$processed = true;

with:

 

$processed = true;

// +Country-State Selector

} else if ($refresh == 'true') {

$cInfo = new objectInfo($HTTP_POST_VARS);

}

// -Country-State Selector

-------------

 

 

the correct code should be:

 

-------------

Line 196:

 

Replace:

 

$processed = true;

 

with:

 

$processed = true;

// +Country-State Selector

} else if ($refresh == 'true') {

$cInfo = new objectInfo($HTTP_POST_VARS);

// }

// -Country-State Selector

-------------

 

Doing so would let you have the dependent drop-down 'state' working in customer.php

 

If someone would issue a bug-fix pack. Please just do so as I haven't joined the community.

 

Thanks.

Link to comment
Share on other sites

Hi All,

 

I have an issue with the Create Account page being submitted with wrong states/provinces.

 

The user goes and fills out all the required fields and finally gets to the bottom where it needs the country information (which happens to be the last one on my template).

 

When you select a country, the form is to be refresh to determine the states or provinces. Here is the problem:

 

Since all the required data is already filled, when the user selects the country, instead of waiting for the user to select the state, it determines that ALL required data is filled and submits the form for account creation; with the first entry in the STATE list (Alabama or ALBERTA for Canada) as the state field. This is due to the onChange=refresh(create_account) in the file.

 

The only way around that I can think of is the shuffle the form around so that the password or other information comes after the country/state on teh form, so that when the country is selected, it sees that the form has missing informaiton (passwords), it complains that its still missing information and the user can then select the state and then password and continue BUT not the way I would like :-(

 

 

Can anyone help please with this issue? How can i make it so that when the country is selected, to only update/refresh the State field/dropdown OR if it needs to refresh the form, not to check if all field submit the form.

 

Also how can you check what version of the CountrySelect Cont you have installed?

Thanks

Jas

Link to comment
Share on other sites

Well, it's not supposed to work that way. This suggests that you have not correctly added the code that separates out the 'refresh' action.

 

Does the version you installed use "AJAX"?

Link to comment
Share on other sites

Hi Steve,

 

How can I check what version I have installed whether its AJAX or not.

 

I am getting all taxes messed up because everyone gets signed up as Alabama or Alberta :-)

 

Thanks for your help

Link to comment
Share on other sites

Hi Steve,

 

No there is no AJAX file. So I don't have the AJAX version. What would you recommend?

How can I fix or update that and fix this problem please

Thanks

Link to comment
Share on other sites

You can compare your files against the pre-edited versions supplied with the contribution and see what the differences are. I think you made an editing error.

Link to comment
Share on other sites

Steve,

 

What version should I use then? Is there any way of upgrading/removing the older version?

So i have the 1.4 version? just before going AJAX? can i download the latest package w/ AJAX and install that

 

thanks

Link to comment
Share on other sites

I have not tested the 1.5 AJAX version and can't help with it. If you're asking me, use the latest 1.4.x version. I don't know which specific version you have, but you can download the 1.4.x and compare against the pre-edited files.

Link to comment
Share on other sites

Jas.

 

I'm using the ajax ver 1.5.5 and it is working well for me. I installed it fresh with a new install of osC, so I couldn't tell you how to upgrade specifically. However, if you follow the 1.4x install directions backwards (and if you left the original code in the source files (which not all contribs have you do), then it should be fairly straight forward to undo your install of 1.4x. Then you could install 1.5x "fresh".

 

I also had some of the same type of issue as you (although the entire page doesn't reload with ajax version), and found it best to rearrange the form so that country comes first -- I know it's kinda' odd for those of us in the US to have that field before the city and/or state (not to mention having that field at all). It is important, imho, that there is a "please select country" option in the country dropdown so that the form won't submit unless a country has been chosen. That is why I trimmed the available countries down from the 140+ to just two -- US and Canada (I put up a contrib for doing this). I know that that is a bit centric of me, but I realize that 99.999999% of my sales come from those two countries, and if there's someone from another country, they end up emailing me.

 

Good luck.

Link to comment
Share on other sites

I thought I had this mod working but looks like it created another problem. After installing it, when in checkout_shipping_address.php, my shipping is now not showing.

 

I installed Shipping Methods and about pulled my hair out for to many days trying to get it to work. In the end it was because the test account I was using, the state was abbreviated. Seems the only way the shipping would work was if the state was exact and the full name, not abbreviated.

 

Once I changed it to the full name shipping worked. So after I got that finally working, I figured I better get the state text box changed to a selectable menu, other wise customers could type the state wrong or abbreviate the state and no shipping.

 

Here's where the problem seems to come in. With this mod, it adds the state as an abbreviation, not the full name.

 

Course oddly, when I look through the database, under orders it shows the full states name, yet on the site, when in checkout_shipping_address.php is is abbreviated. Also when I look in the database under address_book it shows no state entered. I am so confused.

 

Before, by default, the state field in checkout_shipping_address.php was a regular input box, and if i entered the full name of the state, the shipping worked. But if I abbreviated it, shipping did not work. So if it worked with full state, then one would assume the Shipping Methods mod works fine. One would also assume that this mod changes the state to abbreviated and hence messes up the shipping part?

 

Does this make sense? This is so frustrating, it took me forever to get the shipping working and now it's not working again...lol

Edited by ayeronnie
Link to comment
Share on other sites

This mod will display BOTH the state name and the abbreviation. All I can assume is that you did not install it correctly.

 

Not much help...lol

 

I guess I am trying to find out what this mod changes that would affect shipping. I don't know the code or how it works. It does not touch the checkout_shipping.php, yet, since I added the mod my shipping module is not even getting used. The shipping module for USPS has a debug feature, an e-mail is sent that shows the response from the USPS server. This debug feature does not even get called now. So as I said, it's like the shipping module is not getting used.

 

So, my question is, what could have gone wrong that would affect the shipping call on the checkout_shipping.php file? It worked before installing this, so what could I have messed up?

Link to comment
Share on other sites

The code changes the web control that selects the state, and allows for displaying the dropdown on initial load plus when the user changes the country. It does not change how the state is stored for the purpose of shipping (or anything else.) It makes no changes at all in shipping modules. Any problems with the state should be visible on the checkout_shipping page where the address is displayed.

 

There are many possibilities - such as leaving out one or more lines of code, putting a brace in the wrong place, etc. I usually recommend comparing, with a tool such as BeyondCompare2, your edited file and the pre-edited file provided in the contribution ZIP. Even if you have made other changes this may help you identify the problem.

 

Of course, if you added another contribution that changes the same code, you'll have to figure out how to merge the changes.

Link to comment
Share on other sites

The code changes the web control that selects the state, and allows for displaying the dropdown on initial load plus when the user changes the country. It does not change how the state is stored for the purpose of shipping (or anything else.) It makes no changes at all in shipping modules. Any problems with the state should be visible on the checkout_shipping page where the address is displayed.

 

There are many possibilities - such as leaving out one or more lines of code, putting a brace in the wrong place, etc. I usually recommend comparing, with a tool such as BeyondCompare2, your edited file and the pre-edited file provided in the contribution ZIP. Even if you have made other changes this may help you identify the problem.

 

Of course, if you added another contribution that changes the same code, you'll have to figure out how to merge the changes.

 

 

Thank you for the reply Steve. Actually I discovered it was a stupid little thing. Unknown to me, the client changed the shipping zone to only their state, so of course when I used a test account from another state, the shipping does not show, because it was not available. arrggh.. it's always something so simple.

 

So after backing out all the changes then discovering what had happened and putting in the mod all over again, it works perfectly. Of course..:)

 

I swear this will be the LAST OSC cart I do for any one! It's a great cart with tons of great mods but if it's not something you do all the time, and you don't know it well enough, it can get frustrating.

 

Again, thank you for the reply and sorry if I was a pain..:)

Link to comment
Share on other sites

Yes, that's a mistake I've made myself in the past, and it can be baffling. I also agree that osC is great but is not something you can be successful with on a casual basis.

Link to comment
Share on other sites

Jas.

 

I'm using the ajax ver 1.5.5 and it is working well for me. I installed it fresh with a new install of osC, so I couldn't tell you how to upgrade specifically. However, if you follow the 1.4x install directions backwards (and if you left the original code in the source files (which not all contribs have you do), then it should be fairly straight forward to undo your install of 1.4x. Then you could install 1.5x "fresh".

 

I also had some of the same type of issue as you (although the entire page doesn't reload with ajax version), and found it best to rearrange the form so that country comes first -- I know it's kinda' odd for those of us in the US to have that field before the city and/or state (not to mention having that field at all). It is important, imho, that there is a "please select country" option in the country dropdown so that the form won't submit unless a country has been chosen. That is why I trimmed the available countries down from the 140+ to just two -- US and Canada (I put up a contrib for doing this). I know that that is a bit centric of me, but I realize that 99.999999% of my sales come from those two countries, and if there's someone from another country, they end up emailing me.

 

Good luck.

 

Mayo,

 

Thanks. I tried that once and lost track :-P

Gonna attempt it again this weekend. Hopefully it will work with 1.5..5

 

Thanks

Link to comment
Share on other sites

  • 2 weeks later...

hi everyboy,

 

after a lot of research and code changings, I have used this contrib recently and its working fine - apart 2 behaviors:

 

1. my state list shows: Name of the State plus ()

 

i don't know what this () are doing there.

 

How can I remove it?

 

2. my address_book_process.php shows no changes. My default country is not appearing, neither my state list. I thought it was supposed to work as my create_account.php page, which is doing fine.

 

may somebody help to sort it out?

 

by the way, those little problems don't affect how great that contrib is! thank you!!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...