<th scope="row" class="titledesc"> <label for="apg_sms_settings[campo_envio]"> <?php _e('Shipping mobile field:', 'apg_sms'); ?> </label> <span class="woocommerce-help-tip" data-tip="<?php _e('Select the shipping mobile field', 'apg_sms'); ?> "></span> </th> <td class="forminp forminp-number"><select id="apg_sms_settings[campo_envio]" name="apg_sms_settings[campo_envio]" class="wc-enhanced-select" tabindex="<?php echo $tab++; ?> "> <?php $pais = new WC_Countries(); $campos = $pais->get_address_fields($pais->get_base_country(), 'shipping_'); //Campos ordinarios $campos_personalizados = apply_filters('woocommerce_checkout_fields', array()); if (isset($campos_personalizados['shipping'])) { $campos += $campos_personalizados['shipping']; } foreach ($campos as $valor => $campo) { $chequea = isset($configuracion['campo_envio']) && $configuracion['campo_envio'] == $valor ? ' selected="selected"' : ''; if (isset($campo['label'])) { echo '<option value="' . $valor . '"' . $chequea . '>' . $campo['label'] . '</option>' . PHP_EOL; } } ?> </select></td> </tr> <?php
public function loading_states() { check_ajax_referer('wc_crm_loading_states', 'security'); $country = $_REQUEST['country']; $state = $_REQUEST['state']; $id = $_REQUEST['id']; $countries = new WC_Countries(); $filds = $countries->get_address_fields($country, ''); unset($filds['first_name']); unset($filds['last_name']); unset($filds['company']); $filds['country']['options'] = $countries->get_allowed_countries(); $filds['country']['type'] = 'select'; if ($country != '') { $filds['country']['value'] = $country; $states = $countries->get_allowed_country_states(); if (!empty($states[$country])) { $filds['state']['options'] = $states[$country]; $filds['state']['type'] = 'select'; } } $statelabel = $filds['state']['label']; $postcodelabel = $filds['postcode']['label']; $citylabel = $filds['city']['label']; $html = array(); $state_html = ''; if ($id == '_shipping_country') { $dd = '_shipping_state'; } else { $dd = '_billing_state'; } if (isset($filds['state']['options']) && !empty($filds['state']['options'])) { $state_html .= '<select id="' . $dd . '" class="form-row-wide address-field ajax_chosen_select' . $dd . '" style="width: 220px;" name="' . $dd . '">'; foreach ($filds['state']['options'] as $key => $value) { $state_html .= '<option value = "' . $key . '" ' . ($state == $key ? 'selected="selected"' : '') . '> ' . $value . '</option>'; } $state_html .= '</select>'; } else { $state_html .= '<input type="text" id="' . $dd . '" name="' . $dd . '" value="' . $state . ' " class="form-row-left address-field" />'; } $html['state_html'] = $state_html; $html['state_label'] = $statelabel; $html['zip_label'] = $postcodelabel; $html['city_label'] = $citylabel; echo json_encode($html); die; }