Having set my default store location (admin/ecsettings/location) to Canada, when shoppers add an address (user/37/address/add?destination=cart/checkout) and choose their Country as "United States" -> the State drop down select has no values - only "Please choose..." is available.

When I set my default store location to USA, shoppers can choose Canada as an address book Country (and the Province/State resets nicely), or they can choose USA as the destination... and (super dupes) they get to select a State.

Comments

mariuss’s picture

Priority: Normal » Critical

Same here. I know where the problem is, and a possible workaround, but can't figure what the proper, long term, solution is.

The address_form_fields function creates two form elements, one called state (type select) and one called province (type textfield). There is JavaScript code in address.js that shows one or the other based on what country you selected. It seems that state shows only for US and province for everything else.

Note: the above JavaScript implies that only US can have a dropdown with states, even though in theory you can add states/provinces for any country by creating store/store_custom.inc similar to store/store_locations.inc. See store_build_states in store.module.

Now, the problem is that the state dropdown is built statically when the form is generated by using the default country (aka default store location). When the country is changed from the countries dropdown the list of states is not affected.

The workaround: since the state dropdown is used for US only, I think it is pretty safe to hard code the US country code (that is "us") when the state dropdown is built.

In address.module, around line 397, change this:

  $states = store_build_states($country);

to this:

  $states = store_build_states("us");