State field default status. Closes #1268.
This commit is contained in:
parent
08ae311d43
commit
68399b3e4f
|
@ -972,6 +972,7 @@ class WC_Countries {
|
|||
|
||||
$fields = woocommerce_array_overlay( $fields, $locale[$country] );
|
||||
|
||||
// If default country has postcode_before_city switch the fields round
|
||||
if ( isset( $locale[$country]['postcode_before_city'] ) ) {
|
||||
$fields['city']['class'] = array('form-row-last');
|
||||
$fields['city']['clear'] = true;
|
||||
|
@ -990,6 +991,7 @@ class WC_Countries {
|
|||
|
||||
$fields = $switch_fields;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Prepend field keys
|
||||
|
|
|
@ -650,9 +650,6 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
|
|||
break;
|
||||
case "state" :
|
||||
|
||||
$field = '<p class="form-row ' . implode( ' ', $args['class'] ) .'" id="' . $key . '_field">
|
||||
<label for="' . $key . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label']. $required . '</label>';
|
||||
|
||||
/* Get Country */
|
||||
$country_key = $key == 'billing_state'? 'billing_country' : 'shipping_country';
|
||||
|
||||
|
@ -668,20 +665,35 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
|
|||
|
||||
$states = $woocommerce->countries->get_states( $current_cc );
|
||||
|
||||
if ( ! empty( $states ) ) {
|
||||
// Dropdown
|
||||
$field .= '<select name="' . $key . '" id="' . $key . '" class="state_select"><option value="">'.__( 'Select a state…', 'woocommerce' ) .'</option>';
|
||||
foreach ( $states as $ckey => $cvalue ) {
|
||||
if ( is_array( $states ) && empty( $states ) ) {
|
||||
|
||||
$field = '<p class="form-row ' . implode( ' ', $args['class'] ) .'" id="' . $key . '_field" style="display: none">';
|
||||
$field .= '<label for="' . $key . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label']. $required . '</label>';
|
||||
$field .= '<input type="hidden" class="hidden" name="' . $key . '" id="' . $key . '" value="" />';
|
||||
$field .= '</p>' . $after;
|
||||
|
||||
} elseif ( is_array( $states ) ) {
|
||||
|
||||
$field = '<p class="form-row ' . implode( ' ', $args['class'] ) .'" id="' . $key . '_field">';
|
||||
$field .= '<label for="' . $key . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label']. $required . '</label>';
|
||||
$field .= '<select name="' . $key . '" id="' . $key . '" class="state_select">
|
||||
<option value="">'.__( 'Select a state…', 'woocommerce' ) .'</option>';
|
||||
|
||||
foreach ( $states as $ckey => $cvalue )
|
||||
$field .= '<option value="' . $ckey . '" '.selected( $value, $ckey, false ) .'>'.__( $cvalue, 'woocommerce' ) .'</option>';
|
||||
}
|
||||
|
||||
$field .= '</select>';
|
||||
$field .= '</p>' . $after;
|
||||
|
||||
} else {
|
||||
// Input
|
||||
|
||||
$field = '<p class="form-row ' . implode( ' ', $args['class'] ) .'" id="' . $key . '_field">';
|
||||
$field .= '<label for="' . $key . '" class="' . implode( ' ', $args['label_class'] ) .'">' . $args['label']. $required . '</label>';
|
||||
$field .= '<input type="text" class="input-text" value="' . $value . '" placeholder="' . $args['placeholder'] . '" name="' . $key . '" id="' . $key . '" />';
|
||||
$field .= '</p>' . $after;
|
||||
|
||||
}
|
||||
|
||||
$field .= '</p>' . $after;
|
||||
|
||||
break;
|
||||
case "textarea" :
|
||||
|
||||
|
|
Loading…
Reference in New Issue