I am trying to reorder the billing fields on the checkout page but everything I tried so far is not working.
Here is the snippet I am currently trying:
As @Byeongin correctly mentions in his answer, apart from the backend ordering (that @Frits answer covers) there is also ordering that happens via JavaSrcipt in the front-end when the user selects specific countries from the dropdown menu.
If you also want to stop this front-end reordering from happening, the best solution I've encountered so far would be to hook into the woocommerce_get_country_locale filter and remove the priority overrides that are added there.
Something like the following will do the trick (tested with WooCommerce v3.5.4):
add_filter( 'woocommerce_get_country_locale', function( $locale ) {
foreach ( $locale as $country_code => $locale_fields ) {
foreach ( $locale_fields as $field_key => $field_options ) {
if ( isset( $field_options['priority'] ) ) {
unset( $field_options['priority'] );
}
$locale[ $country_code ][ $field_key ] = $field_options;
}
}
return $locale;
} );