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:
Mike Jolley 2024-07-26 12:53:37 +01:00 committed by GitHub
parent cdf89ee951
commit 7195ec2e32
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 7 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fixed placeholders in the classic cart shipping calculator to update with country selection.

View File

@ -41,9 +41,9 @@ jQuery( function( $ ) {
thislocale = locale['default']; thislocale = locale['default'];
} }
var $postcodefield = thisform.find( '#billing_postcode_field, #shipping_postcode_field' ), var $postcodefield = thisform.find( '#billing_postcode_field, #shipping_postcode_field, #calc_shipping_postcode_field' ),
$cityfield = thisform.find( '#billing_city_field, #shipping_city_field' ), $cityfield = thisform.find( '#billing_city_field, #shipping_city_field, #calc_shipping_city_field' ),
$statefield = thisform.find( '#billing_state_field, #shipping_state_field' ); $statefield = thisform.find( '#billing_state_field, #shipping_state_field, #calc_shipping_state_field' );
if ( ! $postcodefield.attr( 'data-o_class' ) ) { if ( ! $postcodefield.attr( 'data-o_class' ) ) {
$postcodefield.attr( 'data-o_class', $postcodefield.attr( 'class' ) ); $postcodefield.attr( 'data-o_class', $postcodefield.attr( 'class' ) );
@ -74,7 +74,7 @@ jQuery( function( $ ) {
if ( if (
typeof fieldLocale.placeholder === 'undefined' && typeof fieldLocale.placeholder === 'undefined' &&
typeof fieldLocale.label !== '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( 'placeholder', fieldLocale.label );
field.find( ':input' ).attr( 'data-placeholder', fieldLocale.label ); field.find( ':input' ).attr( 'data-placeholder', fieldLocale.label );

View File

@ -104,12 +104,15 @@ jQuery( function( $ ) {
placeholder = $statebox.attr( 'placeholder' ) || $statebox.attr( 'data-placeholder' ) || '', placeholder = $statebox.attr( 'placeholder' ) || $statebox.attr( 'data-placeholder' ) || '',
$newstate; $newstate;
if ( placeholder === wc_country_select_params.i18n_select_state_text ) {
placeholder = '';
}
if ( states[ country ] ) { if ( states[ country ] ) {
if ( $.isEmptyObject( states[ country ] ) ) { if ( $.isEmptyObject( states[ country ] ) ) {
$newstate = $( '<input type="hidden" />' ) $newstate = $( '<input type="hidden" />' )
.prop( 'id', input_id ) .prop( 'id', input_id )
.prop( 'name', input_name ) .prop( 'name', input_name )
.prop( 'placeholder', placeholder )
.attr( 'data-input-classes', input_classes ) .attr( 'data-input-classes', input_classes )
.addClass( 'hidden ' + input_classes ); .addClass( 'hidden ' + input_classes );
$parent.hide().find( '.select2-container' ).remove(); $parent.hide().find( '.select2-container' ).remove();