Trigger a country select on page load to ensure the address-i18n is fired on first page load.

This commit is contained in:
Gerhard 2018-10-29 13:39:54 +02:00
parent d1c90c5972
commit c0acd73d31
1 changed files with 109 additions and 110 deletions

View File

@ -6,8 +6,7 @@ jQuery( function( $ ) {
return false;
}
var locale_json = wc_address_i18n_params.locale.replace( /"/g, '"' ),
locale = $.parseJSON( locale_json );
var locale_json = wc_address_i18n_params.locale.replace( /"/g, '"' ), locale = $.parseJSON( locale_json );
function field_is_required( field, is_required ) {
if ( is_required ) {
@ -27,11 +26,8 @@ jQuery( function( $ ) {
}
}
$( document.body )
// Handle locale
.bind( 'country_to_state_changing', function( event, country, wrapper ) {
$( document.body ).bind( 'country_to_state_changing', function( event, country, wrapper ) {
var thisform = wrapper, thislocale;
if ( typeof locale[ country ] !== 'undefined' ) {
@ -129,4 +125,7 @@ jQuery( function( $ ) {
rows.detach().appendTo( wrapper );
} );
});
// Make sure the locales are loaded on first page load.
$( '#billing_country' ).trigger( 'change' );
});