Fix shortcode cart shipping calculator placeholder (#49684)
* Reset default placeholder in country select JS * Handle shipping calculator in address-i18n * changelog
This commit is contained in:
parent
cdf89ee951
commit
7195ec2e32
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Fixed placeholders in the classic cart shipping calculator to update with country selection.
|
|
@ -41,9 +41,9 @@ jQuery( function( $ ) {
|
|||
thislocale = locale['default'];
|
||||
}
|
||||
|
||||
var $postcodefield = thisform.find( '#billing_postcode_field, #shipping_postcode_field' ),
|
||||
$cityfield = thisform.find( '#billing_city_field, #shipping_city_field' ),
|
||||
$statefield = thisform.find( '#billing_state_field, #shipping_state_field' );
|
||||
var $postcodefield = thisform.find( '#billing_postcode_field, #shipping_postcode_field, #calc_shipping_postcode_field' ),
|
||||
$cityfield = thisform.find( '#billing_city_field, #shipping_city_field, #calc_shipping_city_field' ),
|
||||
$statefield = thisform.find( '#billing_state_field, #shipping_state_field, #calc_shipping_state_field' );
|
||||
|
||||
if ( ! $postcodefield.attr( 'data-o_class' ) ) {
|
||||
$postcodefield.attr( 'data-o_class', $postcodefield.attr( 'class' ) );
|
||||
|
@ -74,7 +74,7 @@ jQuery( function( $ ) {
|
|||
if (
|
||||
typeof fieldLocale.placeholder === 'undefined' &&
|
||||
typeof fieldLocale.label !== 'undefined' &&
|
||||
! field.find( 'label' ).length
|
||||
! field.find( 'label:not(.screen-reader-text)' ).length
|
||||
) {
|
||||
field.find( ':input' ).attr( 'placeholder', fieldLocale.label );
|
||||
field.find( ':input' ).attr( 'data-placeholder', fieldLocale.label );
|
||||
|
|
|
@ -104,12 +104,15 @@ jQuery( function( $ ) {
|
|||
placeholder = $statebox.attr( 'placeholder' ) || $statebox.attr( 'data-placeholder' ) || '',
|
||||
$newstate;
|
||||
|
||||
if ( placeholder === wc_country_select_params.i18n_select_state_text ) {
|
||||
placeholder = '';
|
||||
}
|
||||
|
||||
if ( states[ country ] ) {
|
||||
if ( $.isEmptyObject( states[ country ] ) ) {
|
||||
$newstate = $( '<input type="hidden" />' )
|
||||
.prop( 'id', input_id )
|
||||
.prop( 'name', input_name )
|
||||
.prop( 'placeholder', placeholder )
|
||||
.attr( 'data-input-classes', input_classes )
|
||||
.addClass( 'hidden ' + input_classes );
|
||||
$parent.hide().find( '.select2-container' ).remove();
|
||||
|
@ -154,8 +157,8 @@ jQuery( function( $ ) {
|
|||
$newstate = $( '<input type="text" />' )
|
||||
.prop( 'id', input_id )
|
||||
.prop( 'name', input_name )
|
||||
.prop('placeholder', placeholder)
|
||||
.attr('data-input-classes', input_classes )
|
||||
.prop( 'placeholder', placeholder )
|
||||
.attr( 'data-input-classes', input_classes )
|
||||
.addClass( 'input-text ' + input_classes );
|
||||
$parent.show().find( '.select2-container' ).remove();
|
||||
$statebox.replaceWith( $newstate );
|
||||
|
|
Loading…
Reference in New Issue