Formatting the address

Using placeholders #

By default, the WooCommerce Print Address Labels plugin uses the address as formatted by WooCommerce, which is different for each country. You can override this behavior by building your own address format using placeholders.

Here’s a simple example:

[shipping_first_name] [shipping_last_name]
[shipping_postcode] [shipping_city]

Here’s a list of placeholders that you can use, excluding any custom fields:

In addition to these default address fields, you can also display custom fields from the order, like [VAT Number] if you are using WooCommerce EU VAT Numbers plugin. Simply put the custom field name between brackets, minus a leading underscore if it has one: so a custom field with the name _delivery_date would become [delivery_date].

Here’s a list of placeholders that you can use, excluding any custom fields:

Billing fieldsShipping fieldsOther data

Using HTML #

With these placeholders, you not only have full control over the contents of the address, but you can also use HTML to format each element separately.

<span style="font-size: 10pt;">[order_number]</span>
<b>[shipping_first_name] [shipping_last_name]</b>
[shipping_postcode] [shipping_city]

You can even add images, using the html <img> tag, like a logo above the address:

<img style="width: 3cm;" src="" alt="" />

WooCommerce wide #

This is recommended for experienced users only, if you want full control over the address format per country, woocommerce wide.

WooCommerce already preformats the address for you if you use the [shipping_address] or [billing_address] tag. One thing this does is that it omits the country name if it’s the same as the shop base country, and it also uses specific per-country formats. If you want to preserve the per-country format but just change the format for a specific country, you can do this WooCommerce wide (emails, backend, and also the address labels) with a filter, woocommerce_localisation_address_formats. Read this if you haven’t worked with filters or functions.php before: How to use filters.

Here’s an example that changes the address format for the US, putting the company name before the customer name:

add_filter( 'woocommerce_localisation_address_formats', 'woocommerce_custom_address_format', 20 );
function woocommerce_custom_address_format( $formats ) {
    $formats[ 'US' ]  = "{company}\n{name}\n{address_1}\n{address_2}\n{city}, {state_code} {postcode}\n{country}";
    return $formats;

Some pointers here:

  • \n stands for a linebreak
  • US is the country code
  • You can use the following placeholders:
    • {first_name}
    • {last_name}
    • {name}
    • {company}
    • {address_1}
    • {address_2}
    • {city}
    • {state}
    • {state_code}
    • {postcode}
    • {country}
  • …and their uppercase versions:
    • {first_name_upper}
    • {last_name_upper}
    • {name_upper}
    • {company_upper}
    • {address_1_upper}
    • {address_2_upper}
    • {city_upper}
    • {state_upper}
    • {postcode_upper}
    • {country_upper

If you want to print the country name even for domestic addresses, you can use another filter, woocommerce_formatted_address_force_country_display:

add_filter( 'woocommerce_formatted_address_force_country_display', '__return_true' );