Automattic\WooCommerce\Blocks\Domain\Services

CheckoutFields::filter_fields_for_location()publicWC 1.0

From a set of fields, returns only the ones for a given location.

Метод класса: CheckoutFields{}

Хуков нет.

Возвращает

Массив. The filtered fields.

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

$CheckoutFields = new CheckoutFields();
$CheckoutFields->filter_fields_for_location( $fields, $location );
$fields(массив) (обязательный)
The fields to filter.
$location(строка) (обязательный)
The location to validate the field for (address|contact|order).

Код CheckoutFields::filter_fields_for_location() WC 9.4.2

public function filter_fields_for_location( array $fields, string $location ) {
	if ( 'additional' === $location ) {
		wc_deprecated_argument( 'location', '8.9.0', 'The "additional" location is deprecated. Use "order" instead.' );
		$location = 'order';
	}

	return array_filter(
		$fields,
		function ( $key ) use ( $location ) {
			return $this->is_field( $key ) && $this->get_field_location( $key ) === $location;
		},
		ARRAY_FILTER_USE_KEY
	);
}