woocommerce_<type>fields

Important note on this filter: Changes to address fields can and will be overridden by the woocommerce_default_address_fields.

Description

apply_filters( 'woocommerce_<type>fields', (unknown) $address_fields, (number) $country ); 

The locales/default locales apply on top based on country selection. If you want to change things like the required status of an address field, filter woocommerce_default_address_fields instead.

Parameters (2)

0. $address_fields (unknown)
The address fields.
1. $country (number)
The country.

Usage

To run the hook, copy the example below.
  1. $address_fields = apply_filters( 'woocommerce_{$type}fields', $address_fields, $country ); 
  2.  
  3. if ( !empty( $address_fields ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the woocommerce_<type>fields callback 
  2. function filter_woocommerce_typefields( $address_fields, $country ) { 
  3. // make filter magic happen here... 
  4. return $address_fields
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( "woocommerce_{$type}fields", 'filter_woocommerce_typefields', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( "woocommerce_{$type}fields", 'filter_woocommerce_typefields', 10, 2 ); 

Defined (1)

The filter is defined in the following location(s).

/includes/class-wc-countries.php  
  1. return apply_filters( 'woocommerce_' . $type . 'fields', $address_fields, $country );