Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection

Controller::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.

Method of the class: Controller{}

No Hooks.

Return

Array.

Usage

$Controller = new Controller();
$Controller->extend_rest_query_allowed_params( $params );
$params(array) (required)
A list of allowed orderby values.

Controller::extend_rest_query_allowed_params() code WC 9.6.1

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->query_builder->get_custom_order_opts() ) );
	return $params;
}