WooCommerce Address Fields Generator
Relabel, reorder and add WooCommerce address fields across checkout, My Account and the admin, with country locale overrides handled.
<?php
/**
* WooCommerce address fields.
*
* woocommerce_default_address_fields covers checkout, My Account addresses
* and the admin order screen at once, which the checkout-only filter does not.
*/
/**
* Relabels and reorders the address fields.
*
* @param array $fields Address fields.
* @return array
*/
function my_store_address_fields( $fields ) {
if ( isset( $fields['address_1'] ) ) {
$fields['address_1']['label'] = __( 'Street address', 'my-store' );
$fields['address_1']['placeholder'] = __( 'House number and street name', 'my-store' );
}
return $fields;
}
add_filter( 'woocommerce_default_address_fields', 'my_store_address_fields' );
Output is valid and updates as you type.
Fix the highlighted fields to update the output.
Relabel, reorder and extend WooCommerce address fields in the one filter that covers checkout, My Account and the admin order screen together, with the country rules that would otherwise undo your changes.
How to use
- Use
woocommerce_default_address_fieldsfor anything about the address itself. The checkout-only filter leaves My Account and the admin showing the old labels. - Set priorities in tens, as core does, so there is room to insert something between two fields later.
- Turn on the locale override if you change what is required. Country rules run after your filter and put it back.
- Add a custom field only when the order genuinely needs it. Every extra field costs conversions at checkout.
- Show any custom field on the admin order screen. A value nobody in the warehouse can see was never really collected.
Example
function acme_address_fields( $fields ) {
if ( isset( $fields['address_1'] ) ) {
$fields['address_1']['label'] = __( 'Street address', 'acme' );
$fields['address_1']['priority'] = 50;
}
return $fields;
}
add_filter( 'woocommerce_default_address_fields', 'acme_address_fields' );
The isset() check matters: another plugin may have removed the field, and assigning into a missing key creates a half-built field that renders as an empty row.
Pitfalls
- Country locales override required flags per country, and they run after this filter. Making postcode optional here lasts until the customer selects a country that requires one.
woocommerce_checkout_fieldscovers checkout only. Address labels also appear in My Account and in the admin, which is why the default address filter is the better place.- Priorities decide the visual order. Two fields with the same priority sort unpredictably.
- A custom checkout field is not saved automatically unless it is in the billing or shipping group, where WooCommerce saves it as
_billing_<key>. - The Checkout block, default since WooCommerce 8.3, does not use these filters. It has its own registration API for additional fields.
- Changing a label does not change the key. Exports, integrations and accounting systems still see
billing_address_1. - Every field you add is a field a customer has to fill in. Checkout length is one of the most reliable predictors of abandonment.
- Fields in the shipping group are hidden when the order needs no shipping, so anything you always need belongs in billing.
Compatibility
woocommerce_default_address_fields, woocommerce_checkout_fields and woocommerce_get_country_locale have been stable since WooCommerce 2.x and still apply to the classic shortcode checkout in WooCommerce 8 and 9. The Checkout block uses woocommerce_register_additional_checkout_field() instead, which arrived in 8.9. WC_Order::get_meta() needs WooCommerce 3.0. The generated code targets PHP 7.0 and up, and the tool runs entirely in your browser.
Frequently asked questions
Why did my required change stop working?
Which filter should I use?
woocommerce_default_address_fields for address fields, because it covers checkout, My Account and the admin. Use the checkout filter only for fields that exist at checkout alone.Does this work with the Checkout block?
Where is my custom field stored?
_billing_<key> or _shipping_<key>, saved by WooCommerce because the field sits in that group.How do I reorder the fields?
priority. Core uses tens, so 45 puts a field between 40 and 50.