WordPress at Your Fingertips
function is not described

WC_REST_Orders_Controller::prepare_objects_query() protected WC 3.0.0

Prepare objects query.

{} It's a method of the class: WC_REST_Orders_Controller{}

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->prepare_objects_query( $request );
$request(WP_REST_Request) (required)
Full details about the request.

Changelog

Since 3.0.0 Introduced.

Code of WC_REST_Orders_Controller::prepare_objects_query() WC 5.7.1

protected function prepare_objects_query( $request ) {
	// This is needed to get around an array to string notice in WC_REST_Orders_V2_Controller::prepare_objects_query.
	$statuses = $request['status'];
	unset( $request['status'] );
	$args = parent::prepare_objects_query( $request );

	$args['post_status'] = array();
	foreach ( $statuses as $status ) {
		if ( in_array( $status, $this->get_order_statuses(), true ) ) {
			$args['post_status'][] = 'wc-' . $status;
		} elseif ( 'any' === $status ) {
			// Set status to "any" and short-circuit out.
			$args['post_status'] = 'any';
			break;
		} else {
			$args['post_status'][] = $status;
		}
	}

	// Put the statuses back for further processing (next/prev links, etc).
	$request['status'] = $statuses;

	return $args;
}