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

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

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

add_filter( 'woocommerce_admin_shipping_fields', 'wp_kama_woocommerce_admin_shipping_fields_filter', 10, 3 );

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

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

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

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

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

WC_Meta_Box_Order_Data::get_shipping_fields()
woocommerce_admin_shipping_fields
woocommerce/includes/admin/meta-boxes/class-wc-meta-box-order-data.php 125-174
return apply_filters(
	'woocommerce_admin_shipping_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,
			'type'    => 'select',
			'class'   => 'js_field-country select short',
			'options' => array( '' => __( 'Select a country / region…', 'woocommerce' ) ) + WC()->countries->get_shipping_countries(),
		),
		'state'      => array(
			'label' => __( 'State / County', 'woocommerce' ),
			'class' => 'js_field-state select short',
			'show'  => false,
		),
		'phone'      => array(
			'label' => __( 'Phone', 'woocommerce' ),
		),
	),
	$order,
	$context
);

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

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