How to Add Custom Address Format in Woocommerce Based on Country

WooCommerce has various address format based on the input countries. You can add any custom address format by applying condition for specific country. Its easy to implement by adding below code in your WordPress child theme functions.php file.

Create WooCommerce Custom Address Format

Add this code in function.php file of your child theme. You can mention any country code instead of ‘CA’. In this format \n is used to create a new line.

WooCommerce Address format Tags

These tags are available in WooCommerce to construct an formatted address.

{address_1} — First line of address.
{address_2} — Second line of address.
{street_number} — Separate street number if {address_1} does not mentioned

You can find all countries address format in WooCommerce in get_address_formats() method. This method is located under \woocommerce\includes\class-wc-countries.php file.

Leave a Comment