Before I describe my problem, just going to mention that I tried Commerce Addressbook and Commerce Extra (address populate) modules.
- The first one is not suitable in general for my project (because it's based on billing address when the mother address used in this project is always user's one entered on registration) and
- The latter is in alpha stage and has many issues (and still doesn't sort my problem)
The problem is that I cannot prepopulate County/State field on commerce checkout billing address form.
When using hook_form_alter, I can successfully prepopulate all fields, except county. The reason for this is that county drop down is loaded with ajax and dependent on Country value. It's getting created when the form is built so before the hook_alter_form is applied.
So for example let's say my billing address defaults to Ireland (one can setup a default value under customer profile -> billing information). A user registered using address in USA. When the user comes to billing form on checkout, gets all fields prepopulated with the address he/she registered with and country says United Stated, but county/state dropdown stays defaulted to Ireland (lists irish counties).
One needs to select other country than USA and then select USA again for ajax to load the proper county/states dropdown
I cannot seem to find a workaround for this. Any advice?