CheckoutWC uses WooCommerce’s billing and shipping address fields, with its own layout. You can hide or require the optional fields, shorten the form, and put the countries you sell to most at the top of the list, mostly without code. For fields WooCommerce doesn’t have, see Add custom checkout fields.
When you’d use this
- You don’t need a company name or a second address line, or you need them every time.
- You want a shorter form, such as one full name field instead of first and last name.
- You ship to countries where the house number is entered separately.
- Most customers come from a few countries and you want those first in the list.
To remove fields from the billing address only, or to always ask for a separate billing address, see Billing address options.
Show, hide or require company and address line 2
Company and address line 2 each have a WooCommerce setting with three choices: Hidden, Optional or Required. It applies to both the billing and shipping addresses.
- Go to CheckoutWC » Checkout Editor and open Addresses.
- Set Company Field and Address 2 Field to Hidden, Optional or Required.
- Click Save Changes.
These are WooCommerce’s own settings, so changing them in the Checkout Editor changes them for WooCommerce too, and changing them in WooCommerce changes them here.
To require address line 2 for only one address, a developer can use a snippet instead. This one requires it for the shipping address only; change shipping and shipping_address_2 to billing and billing_address_2 for the billing address only:
add_filter( 'woocommerce_checkout_fields', function ( $fields ) {
$fields['shipping']['shipping_address_2']['required'] = true;
return $fields;
} );
Add it in the PHP Snippets box (CheckoutWC » Advanced, Scripts tab), a code snippets plugin or your child theme’s functions.php.
When a field is optional, Hide Optional Address Fields Behind Links (on by default, under CheckoutWC » Pages » Checkout » Field Options) shows it as a link, “Add Company (optional)” or “Add Address Line 2 (optional)”, that customers click to open the field.
Shorten the address form
On CheckoutWC » Pages, Checkout tab, under Field Options. The Checkout Editor’s Addresses section has the same options.
- Enable Full Name Field: replaces the first and last name fields with one Full name field. CheckoutWC splits it into first and last name for the order. Customers must enter at least two words, or they see “Please enter your first and last name.” Off by default.
- Enable Separate House Number and Street Name Address Fields: asks for the house number and street name in two fields, then combines them into the address in the order that’s normal for the customer’s country. Separate fields can’t be used with Google or Fetchify address autocomplete; see Set up address autocomplete. Off by default.
- Separate Address Fields Display Order: chooses which of the two fields comes first on the form.
Put your main countries first
Turn on Enable Highlighted Countries under Field Options, then choose the countries in Highlighted Countries. They appear at the top of the billing and shipping country lists, above the rest, and at the top of the phone number country list.
Code snippets for address fields
These need a developer. Add them in the PHP Snippets box (CheckoutWC » Advanced, Scripts tab), a code snippets plugin or your child theme’s functions.php. The PHP Snippets box runs on storefront requests but not in the WordPress admin, so a snippet that must also apply to emails sent when you change an order there goes in a code snippets plugin or functions.php.
Change the address line 2 label
CheckoutWC labels address line 2 “Apartment, suite, unit, etc.” To use your own wording:
add_filter( 'woocommerce_default_address_fields', function ( $fields ) {
$fields['address_2']['label'] = $fields['address_2']['placeholder'] = 'Apartment number';
return $fields;
}, 200000 );
Remove the postcode field
This removes the postcode from both addresses and widens the country and state fields to fill the row:
add_filter( 'woocommerce_default_address_fields', function ( $fields ) {
unset( $fields['postcode'] );
$fields['country']['columns'] = 6;
$fields['state']['columns'] = 6;
return $fields;
}, 100100 );
Some payment gateways need a postcode to approve a card, so test a payment after removing it.
Reorder address fields
Fields are placed by priority, lowest first. The defaults are first name 10, last name 20, company 30, address line 1 40, address line 2 50, country 60, postcode 70, state 80, city 90 and phone 100. This example moves the city before the country:
add_filter( 'cfw_address_field_priorities', function ( $priorities ) {
$priorities['city'] = 55;
return $priorities;
} );
To change a field’s width as well, set its columns (out of 12) with woocommerce_default_address_fields, as in Remove the postcode field.
Always show the country in addresses
WooCommerce leaves the country out of formatted addresses when it matches your store’s country. To always show it:
add_filter( 'woocommerce_formatted_address_force_country_display', '__return_true' );
Common issues
The state field label is cut off
In some languages, WooCommerce’s state label is too long for the field, for example German’s “Bundesland / Landkreis (optional)”. The cleanest fix is to change that translation with a translation plugin such as Loco Translate; the text comes from WooCommerce, not CheckoutWC. Or widen the field with a snippet:
add_filter( 'woocommerce_default_address_fields', function ( $fields ) {
$fields['country']['columns'] = 6;
$fields['state']['columns'] = 6;
$fields['postcode']['columns'] = 6;
$fields['city']['columns'] = 6;
return $fields;
}, 100100 );
The company field disappeared after switching to the checkout block
When a store’s checkout page uses WooCommerce’s checkout block, WooCommerce can set the company field to hidden if it was never saved. Set Company Field to Optional or Required in the Checkout Editor’s Addresses section.
“Please enter your first and last name.”
The Full name field needs at least two words. If a customer types an email address there, they see “Please enter a name, not an email address.”