From 879139d81ebd913ee657de10c0e1a52786ef8db7 Mon Sep 17 00:00:00 2001 From: Gerhard Date: Wed, 7 Nov 2018 14:16:05 -0500 Subject: [PATCH] Apply priority filtering on additional filters to accomodate pages like my account edit address. --- includes/class-wc-countries.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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; } }