Automattic\WooCommerce\Blocks\BlockTypes

ProductCollection::extend_rest_query_allowed_params()publicWC 1.0

Extends allowed collection_params for the REST API

By itself, the REST API doesn't accept custom orderby values, even if they are supported by a custom post type.

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

Хуков нет.

Возвращает

Массив.

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

$ProductCollection = new ProductCollection();
$ProductCollection->extend_rest_query_allowed_params( $params );
$params(массив) (обязательный)
A list of allowed orderby values.

Код ProductCollection::extend_rest_query_allowed_params() WC 9.4.2

public function extend_rest_query_allowed_params( $params ) {
	$original_enum             = isset( $params['orderby']['enum'] ) ? $params['orderby']['enum'] : array();
	$params['orderby']['enum'] = array_unique( array_merge( $original_enum, $this->custom_order_opts ) );
	return $params;
}