WC_REST_Orders_Controller::prepare_objects_query()
Prepare objects query.
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. |
WC_REST_Orders_Controller::prepare_objects_query() WC REST Orders Controller::prepare objects query code WC 9.5.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; }