Adding a custom checkout field to the address format

This documentation is for the Advanced Checkout Fields for WooCommerce plugin.

WooCommerce shows all the default address fields in on the order received page and the emails. If you're adding custom fields these will not automatically be added to the address format, nor is there a feature in the plugin available to add this.

In this doc I will explain how you can add a custom field that you created to the address format as its is shown on the order confirmation page and emails. Adding custom fields to the address formatting is not official part of the plugin and this doc involves a code snippet that may need further modification to fully fit your needs.

There's also a option to add the custom fields to the order confirmation page / emails, though this cannot be automatically shown at the address and will be displayed in the 'customer details' table.

Adding a custom field to the address format

When you've added a custom field there's also the input for a unique ID to be entered (first field in the list). This ID is needed in the code snippet to call up the correct custom field.

In the example below I'll show how you can modify the default address format and the one for the US. Further below you'll find a code snippet that shows the formats that are currently set and used in WooCommerce so you can easily copy a existing format if needed.

The address formats are based on their 2 letter country codes. If needed you can add more rows in the code snippet above to change the address format for other countries.

Default formats in WooCommerce

For reference purposes, you can find the default formats of the addresses in WooCommerce here:

https://github.com/woocommerce/woocommerce/blob/0b4054d3aa1fcafc286fb5dddd996a0e10d6c450/includes/class-wc-countries.php#L408-L451

Still need help? Contact Us Contact Us