Automattic\WooCommerce\StoreApi\Routes\V1\Ucp
AbstractCatalogRoute::get_context
Extract the recognized context fields from a request.
Метод класса: AbstractCatalogRoute{}
Хуков нет.
Возвращает
array.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_context( $request ): array;
- $request(WP_REST_Request) (обязательный)
- Request object.
Код AbstractCatalogRoute::get_context() AbstractCatalogRoute::get context WC 11.3.0
protected function get_context( \WP_REST_Request $request ): array {
$raw = $request->get_param( 'context' );
if ( ! is_array( $raw ) ) {
return array();
}
$context = array();
foreach ( array( 'address_country', 'address_region', 'postal_code', 'intent', 'language', 'currency' ) as $key ) {
if ( isset( $raw[ $key ] ) && is_scalar( $raw[ $key ] ) && '' !== (string) $raw[ $key ] ) {
$context[ $key ] = (string) $raw[ $key ];
}
}
return $context;
}