Automattic\WooCommerce\Blocks\Domain\Services
CheckoutFields::filter_fields_for_location
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() CheckoutFields::filter fields for location WC 10.4.2
public function filter_fields_for_location( array $fields, string $location ) {
$location = $this->prepare_location_name( $location );
return array_filter(
$fields,
function ( $key ) use ( $location ) {
return $this->get_field_location( $key ) === $location;
},
ARRAY_FILTER_USE_KEY
);
}