Download & Extend

"Invalid state. Try to use the state code." - with no state set.

Project:e-Commerce
Version:6.x-4.3
Component:address
Category:bug report
Priority:critical
Assigned:Unassigned
Status:active
Issue tags:e-commerce, state verification error

Issue Summary

Go to user profile and add an address: user/1/ec_address/add
Use an address for the US or UK (not tried others).
Leave the state field blank, or enter "London", or "TX", or "Texas", or random curses.

eg:
First Name: *
firstname

Last Name: *
lastname

Country: *
United States

State / Province:
Texas

City: *
Austin

Address Line 1: *
address1

Address Line 2:
address2

Zip / Postal Code:
12345

Whatever you put in that field, it will never suggest any options, and will never permit you to submit the form, always displaying:
"Invalid state. Try to use the state code."

Also, the fields in that address form are in the wrong order.

Comments

#1

I have the same problem..

#2

Version:6.x-4.0-beta6» 6.x-4.0-rc13
Priority:normal» critical

I am also experiencing this problem

#3

Status:active» postponed (maintainer needs more info)

I can't seem to replicate this, Using TX as the state works fine.

If you could create a test which replicates this then I would be able to fit it.

#4

I had the State/Province problem as well after updating to rc13

GB and USA giving the "Try to use the state code" error.

Here's a quick workaround that doesn't appear to have any side-effects (apart from loss of state validation):

Delete the "Implementation of hook_checkout_validate()" code from ec_customer.checkout.inc to get the Checkout working.
Delete the "Validate an address being saved" code from ec_address.admin.inc to get the manual add working.

Not sure why state validation isn't working for me - perhaps something I haven't got installed/configured?

#5

With the country set to United Kingdom, I have not managed to find any string at all which gets accepted.

An easy way to disable the check on the State field would probably be the most sensible option for UK based e-commerce sites.

#6

No problems after installing the Oct' 13th Snapshot.
Tested a few valid and invalid UK addresses and checkout is working fine.

#7

Version:6.x-4.0-rc13» 6.x-4.x-dev

I can confirm that this bug still exists on a fresh install of 6.x-4-dev.

I have set up the the store for UNITED STATES. The test address used TX and TEXAS for states. Same result with both.Can't complete the payment page with the outstanding error.

#8

Status:postponed (maintainer needs more info)» active

I also have this on the rc15 release on a new install.
Store is set to in UK. Only valid country is UK.

But the drop down list of countries on the cart still shows ALL countries (even though the others are not allowed).

Trying to add an address to the user directly (user/1/ec_address/add) doesn't work at all. I get http 500.

#9

I have had this problem on all of the latest releases but Zound's suggestion seems to have worked.

Many thanks

#10

Just sharing what might be a minimal solution for anyone experiencing problems with this field.

In our case, on rc13, it seemed to work as expected, but some international customers were confused about what to put into the "State" field.

For tax purposes, we must distinguish US - Texas customers from all others, but that's the only distinction we must make. So the simplest solution I found was to hack the _ec_store_location_states function in ec_store/ec_store.localization.inc, by adding this code at the very top of the function:

  if ($country != 'US') {
    return array();
  }

That fixed it up for us - US customers must enter a State, anyone else can do whatever they please.

Those people having trouble might be able to put one line: "return array();" at the top of the function I hacked to completely disable the validation for all countries. Whether that works or not (and if it does, what value is being passed in for country) might be useful debugging information for gordon...

#11

Hi,
I have this problem. I am using rc15 in the uk and each time I try to complete the checkout info and place the order I receive the 'Invalid state. Try to use the state code' message. I have tried the fixes above and they haven't made any difference? I am new to drupal and a bit confused about whether I am making the changes correctly.

Would it be possible for someone to attach the edited .inc files or maybe give clearer instructions about exactly what content to delete or where to add the code as in post #10? I only need to sell in the uk as my products are specific to the uk.
Very grateful for any help
Mike

#12

Status:active» fixed

this is fixed now. it was a problem between upper and lower case entry

#13

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#14

Version:6.x-4.x-dev» 6.x-4.3
Status:closed (fixed)» active

Not fixed. Please describe how to avoid state verification for all non-USA countries, and how even to hide the state field for them.

nobody click here