Address field sorting was not working due to wrong data name
Fixes #14533
This commit is contained in:
parent
be96e8c8a1
commit
3b6e7d9d14
|
@ -74,10 +74,10 @@ jQuery( function( $ ) {
|
|||
}
|
||||
}
|
||||
|
||||
if ( thislocale[ key ].sort ) {
|
||||
field.data( 'priority', thislocale[ key ].sort );
|
||||
} else if ( locale['default'][ key ].sort ) {
|
||||
field.data( 'priority', locale['default'][ key ].sort );
|
||||
if ( thislocale[ key ].priority ) {
|
||||
field.data( 'priority', thislocale[ key ].priority );
|
||||
} else if ( locale['default'][ key ].priority ) {
|
||||
field.data( 'priority', locale['default'][ key ].priority );
|
||||
}
|
||||
|
||||
} else if ( locale['default'][ key ] ) {
|
||||
|
@ -106,8 +106,8 @@ jQuery( function( $ ) {
|
|||
}
|
||||
}
|
||||
|
||||
if ( locale['default'][ key ].sort ) {
|
||||
field.data( 'priority', locale['default'][ key ].sort );
|
||||
if ( locale['default'][ key ].priority ) {
|
||||
field.data( 'priority', locale['default'][ key ].priority );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
jQuery(function(a){function b(a,b){b?(a.find("label").append(' <abbr class="required" title="'+wc_address_i18n_params.i18n_required_text+'">*</abbr>'),a.addClass("validate-required")):(a.find("label abbr").remove(),a.removeClass("validate-required"))}if("undefined"==typeof wc_address_i18n_params)return!1;var c=wc_address_i18n_params.locale.replace(/"/g,'"'),d=a.parseJSON(c);a(document.body).bind("country_to_state_changing",function(c,e,f){var g,h=f;g="undefined"!=typeof d[e]?d[e]:d.default;var i=h.find("#billing_postcode_field, #shipping_postcode_field"),j=h.find("#billing_city_field, #shipping_city_field"),k=h.find("#billing_state_field, #shipping_state_field");i.attr("data-o_class")||(i.attr("data-o_class",i.attr("class")),j.attr("data-o_class",j.attr("class")),k.attr("data-o_class",k.attr("class")));var l=a.parseJSON(wc_address_i18n_params.locale_fields);a.each(l,function(a,c){var e=h.find(c);g[a]?(g[a].label&&e.find("label").html(g[a].label),g[a].placeholder&&e.find("input").attr("placeholder",g[a].placeholder),b(e,!1),"undefined"==typeof g[a].required&&d.default[a].required===!0?b(e,!0):g[a].required===!0&&b(e,!0),"state"!==a&&(g[a].hidden===!0?e.hide().find("input").val(""):e.show()),g[a].sort?e.data("priority",g[a].sort):d.default[a].sort&&e.data("priority",d.default[a].sort)):d.default[a]&&("state"!==a&&("undefined"==typeof d.default[a].hidden||d.default[a].hidden===!1?e.show():d.default[a].hidden===!0&&e.hide().find("input").val("")),"postcode"!==a&&"city"!==a&&"state"!==a||(d.default[a].label&&e.find("label").html(d.default[a].label),d.default[a].placeholder&&e.find("input").attr("placeholder",d.default[a].placeholder)),d.default[a].required===!0&&0===e.find("label abbr").length&&b(e,!0),d.default[a].sort&&e.data("priority",d.default[a].sort))});var m=a(".woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields__field-wrapper, .woocommerce-address-fields__field-wrapper, .woocommerce-additional-fields__field-wrapper .woocommerce-account-fields");m.each(function(b,c){var d=a(c).find(".form-row"),e=d.first().parent(),f=0;d.each(function(){a(this).data("priority")||a(this).data("priority",f+1),f=a(this).data("priority")}),d.sort(function(b,c){var d=a(b).data("priority"),e=a(c).data("priority");return d>e?1:d<e?-1:0}),d.detach().appendTo(e)})})});
|
||||
jQuery(function(a){function b(a,b){b?(a.find("label").append(' <abbr class="required" title="'+wc_address_i18n_params.i18n_required_text+'">*</abbr>'),a.addClass("validate-required")):(a.find("label abbr").remove(),a.removeClass("validate-required"))}if("undefined"==typeof wc_address_i18n_params)return!1;var c=wc_address_i18n_params.locale.replace(/"/g,'"'),d=a.parseJSON(c);a(document.body).bind("country_to_state_changing",function(c,e,f){var g,h=f;g="undefined"!=typeof d[e]?d[e]:d.default;var i=h.find("#billing_postcode_field, #shipping_postcode_field"),j=h.find("#billing_city_field, #shipping_city_field"),k=h.find("#billing_state_field, #shipping_state_field");i.attr("data-o_class")||(i.attr("data-o_class",i.attr("class")),j.attr("data-o_class",j.attr("class")),k.attr("data-o_class",k.attr("class")));var l=a.parseJSON(wc_address_i18n_params.locale_fields);a.each(l,function(a,c){var e=h.find(c);g[a]?(g[a].label&&e.find("label").html(g[a].label),g[a].placeholder&&e.find("input").attr("placeholder",g[a].placeholder),b(e,!1),"undefined"==typeof g[a].required&&d.default[a].required===!0?b(e,!0):g[a].required===!0&&b(e,!0),"state"!==a&&(g[a].hidden===!0?e.hide().find("input").val(""):e.show()),g[a].priority?e.data("priority",g[a].priority):d.default[a].priority&&e.data("priority",d.default[a].priority)):d.default[a]&&("state"!==a&&("undefined"==typeof d.default[a].hidden||d.default[a].hidden===!1?e.show():d.default[a].hidden===!0&&e.hide().find("input").val("")),"postcode"!==a&&"city"!==a&&"state"!==a||(d.default[a].label&&e.find("label").html(d.default[a].label),d.default[a].placeholder&&e.find("input").attr("placeholder",d.default[a].placeholder)),d.default[a].required===!0&&0===e.find("label abbr").length&&b(e,!0),d.default[a].priority&&e.data("priority",d.default[a].priority))});var m=a(".woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields__field-wrapper, .woocommerce-address-fields__field-wrapper, .woocommerce-additional-fields__field-wrapper .woocommerce-account-fields");m.each(function(b,c){var d=a(c).find(".form-row"),e=d.first().parent(),f=0;d.each(function(){a(this).data("priority")||a(this).data("priority",f+1),f=a(this).data("priority")}),d.sort(function(b,c){var d=a(b).data("priority"),e=a(c).data("priority");return d>e?1:d<e?-1:0}),d.detach().appendTo(e)})})});
|
|
@ -1925,7 +1925,7 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
|
|||
$field = '';
|
||||
$label_id = $args['id'];
|
||||
$sort = $args['priority'] ? $args['priority'] : '';
|
||||
$field_container = '<p class="form-row %1$s" id="%2$s" data-sort="' . esc_attr( $sort ) . '">%3$s</p>';
|
||||
$field_container = '<p class="form-row %1$s" id="%2$s" data-priority="' . esc_attr( $sort ) . '">%3$s</p>';
|
||||
|
||||
switch ( $args['type'] ) {
|
||||
case 'country' :
|
||||
|
|
Loading…
Reference in New Issue