/**
  * Get the states for a given country
  */
 public function ajax_get_country_states()
 {
     $address_id = isset($_POST['address_id']) ? $_POST['address_id'] : '';
     if (empty($address_id)) {
         wp_send_json_error(__('Address ID must be specified', 'cuar'));
     }
     // Check nonce
     $nonce_action = 'cuar_' . $address_id;
     $nonce_name = 'cuar_nonce';
     if (!isset($_POST[$nonce_name]) || !wp_verify_nonce($_POST[$nonce_name], $nonce_action)) {
         wp_send_json_error(__('Trying to cheat?', 'cuar'));
     }
     $country = isset($_POST['country']) ? $_POST['country'] : null;
     if ($country == null) {
         wp_send_json_success(array('states' => null));
     }
     $states = CUAR_CountryHelper::getStates($country);
     $statesAsHtml = '';
     foreach ($states as $code => $label) {
         $statesAsHtml .= '<option value="' . esc_attr($code) . '">' . $label . '</option>' . "\n";
     }
     wp_send_json_success(array('states' => empty($states) ? null : $states, 'htmlOptions' => $statesAsHtml));
 }
        echo $label;
        ?>
</option>
                <?php 
    }
    ?>
            </select>
        </div>
        <?php 
}
?>
        <?php 
if (!in_array('state', $excluded_fields)) {
    ?>
        <?php 
    $country_states = CUAR_CountryHelper::getStates($address['country']);
    ?>
        <div class="form-group cuar-address-state" <?php 
    if (empty($country_states)) {
        echo 'style="display: none;"';
    }
    ?>
>
            <label for="<?php 
    echo $address_id;
    ?>
_state" class="control-label"><?php 
    _e('State/Province', 'cuar');
    ?>
</label>