# Reorder the Billing and Shipping Fields

> Changes the order of checkout address fields, for example country first and postcode before city, to match how addresses are written in your market.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, checkout, fields, address
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-reorder-checkout-fields/

## Code

```php
$wpide_field_order = array( // Field => priority (lower = higher up).
    'country'    => 5,
    'first_name' => 10,
    'last_name'  => 20,
    'company'    => 30,
    'postcode'   => 40,
    'city'       => 45,
    'address_1'  => 50,
    'address_2'  => 60,
    'state'      => 70,
);

add_filter( 'woocommerce_default_address_fields', function ( $fields ) use ( $wpide_field_order ) {
    foreach ( $wpide_field_order as $key => $priority ) {
        if ( isset( $fields[ $key ] ) ) {
            $fields[ $key ]['priority'] = $priority;
        }
    }

    return $fields;
}, 20 );

add_filter( 'woocommerce_get_country_locale', function ( $locales ) use ( $wpide_field_order ) {
    foreach ( $locales as $country => $fields ) {
        foreach ( $fields as $key => $field ) {
            if ( isset( $field['priority'], $wpide_field_order[ $key ] ) ) {
                $locales[ $country ][ $key ]['priority'] = $wpide_field_order[ $key ];
            }
        }
    }

    return $locales;
}, 20 );
```

## Notes

Lower numbers come first; field keys have no billing_ or shipping_ prefix and apply to both address forms.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Reorder the Billing and Shipping Fields" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
