wc_countries - states selection dropdown - woocommerce
<p>I am struggling to set up a form with a default WooCommerce country and states selection dropdowns.</p>

<p>Basically, I want to show Country selection and then state selection based on the country selection. So if the user chooses UK, the new dropdown with states selection will show.</p>

<p>I got as far as this:</p>

<pre><code>&lt;?php
global $woocommerce;
$countries_obj   = new WC_Countries();
$countries   = $countries_obj-&gt;__get('countries');
$default_country = $countries_obj-&gt;get_base_country();
$default_county_states = $countries_obj-&gt;get_states( $default_country );

echo '&lt;div id="ships_from_countries_field"&gt;' . __('Countries') . '';

    woocommerce_form_field('my_country_field', array(
           'type'       =&gt; 'select',
           'class'      =&gt; array( 'chzn-drop' ),
           'label'      =&gt; __('Item ships from - country'),
           'placeholder'    =&gt; __('Select a Country'),
           'options'    =&gt; $countries
            )
     );
 echo '&lt;/div&gt;';

 echo '&lt;div id="ships_from_state_field"&gt;' . __('States') . '';

     woocommerce_form_field('my_state_field', array(
            'type'       =&gt; 'select',
            'class'      =&gt; array( 'chzn-drop' ),
            'label'      =&gt; __('Item ships from - state'),
            'placeholder'    =&gt; __('Select a State'),
            'options'    =&gt; $default_county_states
             )
      );
  echo '&lt;/div&gt;';
  ?&gt;
</code></pre>

<p>Countries dropdown is displaying countries and states dropdown displaying states of the shop base - UK</p>

<p>But how do I make them work together and save the values?</p>

<p>Cannot find any info, anybody has any experience making this work?</p>