woocommerce_admin_billing_fields хук-фильтрWC 1.4.0

Provides an opportunity to modify the list of order billing fields displayed on the admin.

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

add_filter( 'woocommerce_admin_billing_fields', 'wp_kama_woocommerce_admin_billing_fields_filter', 10, 3 );

/**
 * Function for `woocommerce_admin_billing_fields` filter-hook.
 * 
 * @param array          $array   Billing fields.
 * @param WC_Order|false $order   Order object.
 * @param string         $context Context of fields (view or edit).
 *
 * @return array
 */
function wp_kama_woocommerce_admin_billing_fields_filter( $array, $order, $context ){

	// filter...
	return $array;
}
$array(массив)
Billing fields.
$order(WC_Order|false)
Order object.
$context(строка)
Context of fields (view or edit).

Список изменений

С версии 1.4.0 Введена.

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

WC_Meta_Box_Order_Data::get_billing_fields()
woocommerce_admin_billing_fields
woocommerce/includes/admin/meta-boxes/class-wc-meta-box-order-data.php 53-105
return apply_filters(
	'woocommerce_admin_billing_fields',
	array(
		'first_name' => array(
			'label' => __( 'First name', 'woocommerce' ),
			'show'  => false,
		),
		'last_name'  => array(
			'label' => __( 'Last name', 'woocommerce' ),
			'show'  => false,
		),
		'company'    => array(
			'label' => __( 'Company', 'woocommerce' ),
			'show'  => false,
		),
		'address_1'  => array(
			'label' => __( 'Address line 1', 'woocommerce' ),
			'show'  => false,
		),
		'address_2'  => array(
			'label' => __( 'Address line 2', 'woocommerce' ),
			'show'  => false,
		),
		'city'       => array(
			'label' => __( 'City', 'woocommerce' ),
			'show'  => false,
		),
		'postcode'   => array(
			'label' => __( 'Postcode / ZIP', 'woocommerce' ),
			'show'  => false,
		),
		'country'    => array(
			'label'   => __( 'Country / Region', 'woocommerce' ),
			'show'    => false,
			'class'   => 'js_field-country select short',
			'type'    => 'select',
			'options' => array( '' => __( 'Select a country / region…', 'woocommerce' ) ) + WC()->countries->get_allowed_countries(),
		),
		'state'      => array(
			'label' => __( 'State / County', 'woocommerce' ),
			'class' => 'js_field-state select short',
			'show'  => false,
		),
		'email'      => array(
			'label' => __( 'Email address', 'woocommerce' ),
		),
		'phone'      => array(
			'label' => __( 'Phone', 'woocommerce' ),
		),
	),
	$order,
	$context
);

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

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 );