diff --git a/includes/class-wc-countries.php b/includes/class-wc-countries.php index 535477b8d38..c42f7df3211 100644 --- a/includes/class-wc-countries.php +++ b/includes/class-wc-countries.php @@ -704,7 +704,11 @@ class WC_Countries { unset( $fields['address_2'] ); } - return apply_filters( 'woocommerce_default_address_fields', $fields ); + $default_address_fields = apply_filters( 'woocommerce_default_address_fields', $fields ); + // Sort each of the fields based on priority. + uasort( $default_address_fields, 'wc_checkout_fields_uasort_comparison' ); + + return $default_address_fields; } /** @@ -1280,6 +1284,10 @@ class WC_Countries { * on country selection. If you want to change things like the required status of an * address field, filter woocommerce_default_address_fields instead. */ - return apply_filters( 'woocommerce_' . $type . 'fields', $address_fields, $country ); + $address_fields = apply_filters( 'woocommerce_' . $type . 'fields', $address_fields, $country ); + // Sort each of the fields based on priority. + uasort( $address_fields, 'wc_checkout_fields_uasort_comparison' ); + + return $address_fields; } }