woocommerce_(type)fields хук-фильтрWC 1.0

Important note on this filter: Changes to address fields can and will be overridden by the woocommerce_default_address_fields. 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.

Использование

add_filter( 'woocommerce_(type)fields', 'wp_kama_woocommerce_typefields_filter', 10, 2 );

/**
 * Function for `woocommerce_(type)fields` filter-hook.
 * 
 * @param  $address_fields 
 * @param  $country        
 *
 * @return 
 */
function wp_kama_woocommerce_typefields_filter( $address_fields, $country ){

	// filter...
	return $address_fields;
}
$address_fields
-
$country
-

Где вызывается хук

WC_Countries::get_address_fields()
woocommerce_(type)fields
woocommerce/includes/class-wc-countries.php 1727
$address_fields = apply_filters( 'woocommerce_' . $type . 'fields', $address_fields, $country );

Где используется хук в WooCommerce

woocommerce/src/Admin/Features/ProductBlockEditor/Init.php 64
add_filter( 'woocommerce_admin_get_user_data_fields', array( $this, 'add_user_data_fields' ) );
woocommerce/src/Blocks/Domain/Services/CheckoutFieldsAdmin.php 32
add_filter( 'woocommerce_admin_billing_fields', array( $this, 'admin_address_fields' ), 10, 3 );
woocommerce/src/Blocks/Domain/Services/CheckoutFieldsAdmin.php 33
add_filter( 'woocommerce_admin_billing_fields', array( $this, 'admin_contact_fields' ), 10, 3 );
woocommerce/src/Blocks/Domain/Services/CheckoutFieldsAdmin.php 34
add_filter( 'woocommerce_admin_shipping_fields', array( $this, 'admin_address_fields' ), 10, 3 );
woocommerce/src/Blocks/Domain/Services/CheckoutFieldsAdmin.php 35
add_filter( 'woocommerce_admin_shipping_fields', array( $this, 'admin_order_fields' ), 10, 3 );
woocommerce/src/Blocks/Domain/Services/CheckoutFieldsFrontend.php 41
add_filter( 'woocommerce_save_account_details_required_fields', array( $this, 'edit_account_form_required_fields' ), 10, 1 );
woocommerce/src/Blocks/Domain/Services/CheckoutFieldsFrontend.php 42
add_filter( 'woocommerce_edit_account_form_fields', array( $this, 'edit_account_form_fields' ), 10, 1 );
woocommerce/src/Internal/Admin/ActivityPanels.php 35
add_filter( 'woocommerce_admin_get_user_data_fields', array( $this, 'add_user_data_fields' ) );
woocommerce/src/Internal/Admin/Analytics.php 60
add_filter( 'woocommerce_admin_get_user_data_fields', array( $this, 'add_user_data_fields' ) );
woocommerce/src/Internal/Admin/Homescreen.php 41
add_filter( 'woocommerce_admin_get_user_data_fields', array( $this, 'add_user_data_fields' ) );
woocommerce/src/Internal/Admin/MobileAppBanner.php 32
add_filter( 'woocommerce_admin_get_user_data_fields', array( $this, 'add_user_data_fields' ) );