The hook woocommerce_checkout_fields
only allow customizations on checkout page and will not affect the My account "Addresses" section fields.
The following will affect both My account "Addresses" section fields and checkout fields, allowing to make billing and shipping fields customized also on the related my account section.
1) For addresses fields (both billing and shipping) on My account and checkout:
In some cases you need to use this filter for addresses fields and it's applied to all billing and shipping default fields:
// Billing and Shipping fields on my account edit-addresses and checkout
add_filter( 'woocommerce_default_address_fields' , 'custom_override_default_address_fields' );
function custom_override_default_address_fields( $fields ) {
$fields['first_name']['label'] = 'First name';
$fields['last_name']['label'] = 'Last name';
$fields['company']['label'] = 'Company name';
$fields['address_1']['label'] = 'Street address';
$fields['address_2']['label'] = 'Apartment, unit, etc.';
$fields['city']['label'] = 'City';
$fields['country']['label'] = 'Country';
$fields['state']['label'] = 'County/State';
$fields['postcode']['label'] = 'Postcode';
return $fields;
}
You can use WooCommerce conditional tags is_account_page() and is_checkout() to target my account pages or checkout page…
2) For Billing fields on my account edit-addresses and checkout:
// Billing fields on my account edit-addresses and checkout
add_filter( 'woocommerce_billing_fields' , 'custom_billing_fields' );
function custom_billing_fields( $fields ) {
// Billing Fields
$fields['billing_first_name']['label'] = 'First name';
$fields['billing_last_name']['label'] = 'Last name';
$fields['billing_company']['label'] = 'Company name';
$fields['billing_address_1']['label'] = 'Street address';
$fields['billing_address_2']['label'] = 'Apartment, unit, etc.';
$fields['billing_city']['label'] = 'City';
$fields['billing_country']['label'] = 'Country';
$fields['billing_state']['label'] = 'County/State';
$fields['billing_postcode']['label'] = 'Postcode';
$fields['billing_email']['label'] = 'Email';
$fields['billing_phone']['label'] = 'Phone';
return $fields;
}
3) For Shipping fields on my account edit-addresses and checkout
// Shipping fields on my account edit-addresses and checkout
add_filter( 'woocommerce_shipping_fields' , 'custom_shipping_fields' );
function custom_shipping_fields( $fields ) {
// Shipping Fields
$fields['shipping_first_name']['label'] = 'First name';
$fields['shipping_last_name']['label'] = 'Last name';
$fields['shipping_company']['label'] = 'Company name';
$fields['shipping_address_1']['label'] = 'Street address';
$fields['shipping_address_2']['label'] = 'Apartment, unit, etc.';
$fields['shipping_city']['label'] = 'City';
$fields['shipping_country']['label'] = 'Country';
$fields['shipping_state']['label'] = 'County/State';
$fields['shipping_postcode']['label'] = 'Postcode';
$fields['shipping_email']['label'] = 'Email';
$fields['shipping_phone']['label'] = 'Phone';
return $fields;
}
4) All (other) fields only on checkout:
// All fields only on checkout
add_filter( 'woocommerce_checkout_fields' , 'other_custom_checkout_fields' );
function other_custom_checkout_fields( $fields ) {
// Account Fields
$fields['account']['account_username']['label'] = 'Username or email';
$fields['account']['account_password']['label'] = 'Password';
// Order Fields
$fields['order']['order_comments']['label'] = 'Order notes';
return $fields;
}
5) Also depending on the selected country, you should need to use the filters:
woocommerce_country_locale_field_selectors
woocommerce_get_country_locale_default
Those are located on WC_Country
Class.
Code goes in functions.php file of your active child theme (or active theme).
Related official documentation: Customizing checkout fields using actions and filters