This commit is contained in:
Mike Jolley 2013-12-03 12:14:12 +00:00
parent d7d6ddbc84
commit af34b43ee6
4 changed files with 12 additions and 11 deletions

View File

@ -366,7 +366,7 @@ jQuery(document).ready(function($) {
}
// Handle locale fields
var locale_fields = $.parseJSON(wc_checkout_params.locale_fields);
var locale_fields = $.parseJSON( wc_checkout_params.locale_fields );
$.each( locale_fields, function( key, value ) {
@ -402,11 +402,12 @@ jQuery(document).ready(function($) {
if ( locale['default'][key]['required'] == true ) {
if (field.find('label abbr').size()==0) field.find('label').append( required );
}
if ( key !== 'state' && (typeof locale['default'][key]['hidden'] == 'undefined' || locale['default'][key]['hidden'] == false) ) {
if ( key !== 'state' ) {
if ( typeof locale['default'][key]['hidden'] == 'undefined' || locale['default'][key]['hidden'] == false ) {
field.show();
} else if ( locale['default'][key]['hidden'] == true ) {
field.hide().find('input').val('');
}
if ( key !== 'state' && locale['default'][key]['hidden'] == true ) {
field.hide();
}
}

File diff suppressed because one or more lines are too long

View File

@ -774,12 +774,12 @@ class WC_Countries {
}
/**
* Get locale fields
* Get JS selectors for fields which are shown/hidden depending on the locale.
*
* @access public
* @return array
*/
public function get_locale_fields() {
public function get_country_locale_field_selectors() {
$locale_fields = array (
'address_1' => '#billing_address_1_field, #shipping_address_1_field',
'address_2' => '#billing_address_2_field, #shipping_address_2_field',
@ -788,7 +788,7 @@ class WC_Countries {
'city' => '#billing_city_field, #shipping_city_field'
);
return apply_filters( 'woocommerce_locale_fields', $locale_fields );
return apply_filters( 'woocommerce_country_locale_field_selectors', $locale_fields );
}
/**

View File

@ -120,7 +120,7 @@ class WC_Frontend_Scripts {
'checkout_url' => add_query_arg( 'action', 'woocommerce_checkout', WC()->ajax_url() ),
'is_checkout' => is_page( wc_get_page_id( 'checkout' ) ) && empty( $wp->query_vars['order-pay'] ) && ! isset( $wp->query_vars['order-received'] ) ? 1 : 0,
'locale' => json_encode( WC()->countries->get_country_locale() ),
'locale_fields' => json_encode( WC()->countries->get_locale_fields() )
'locale_fields' => json_encode( WC()->countries->get_country_locale_field_selectors() )
) ) );
wp_localize_script( 'wc-cart', 'wc_cart_params', apply_filters( 'wc_cart_params', array(