WordPress at a glance
function is not described

WC_REST_Legacy_Orders_Controller::query_args() public WC 1.0

Deprecated from version 3.0. It is no longer supported and can be removed in future releases. It is recommended to replace this function with the same one.

Query args.

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

No Hooks.

Return

Array.

Usage

$WC_REST_Legacy_Orders_Controller = new WC_REST_Legacy_Orders_Controller();
$WC_REST_Legacy_Orders_Controller->query_args( $args, $request );
$args(array) (required)
-
$request(WP_REST_Request) (required)
-

Changelog

Deprecated 3.0

Code of WC_REST_Legacy_Orders_Controller::query_args() WC 5.0.0

<?php
public function query_args( $args, $request ) {
	global $wpdb;

	// Set post_status.
	if ( 'any' !== $request['status'] ) {
		$args['post_status'] = 'wc-' . $request['status'];
	} else {
		$args['post_status'] = 'any';
	}

	if ( ! empty( $request['customer'] ) ) {
		if ( ! empty( $args['meta_query'] ) ) {
			$args['meta_query'] = array();
		}

		$args['meta_query'][] = array(
			'key'   => '_customer_user',
			'value' => $request['customer'],
			'type'  => 'NUMERIC',
		);
	}

	// Search by product.
	if ( ! empty( $request['product'] ) ) {
		$order_ids = $wpdb->get_col( $wpdb->prepare( "
			SELECT order_id
			FROM {$wpdb->prefix}woocommerce_order_items
			WHERE order_item_id IN ( SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE meta_key = '_product_id' AND meta_value = %d )
			AND order_item_type = 'line_item'
		 ", $request['product'] ) );

		// Force WP_Query return empty if don't found any order.
		$order_ids = ! empty( $order_ids ) ? $order_ids : array( 0 );

		$args['post__in'] = $order_ids;
	}

	// Search.
	if ( ! empty( $args['s'] ) ) {
		$order_ids = wc_order_search( $args['s'] );

		if ( ! empty( $order_ids ) ) {
			unset( $args['s'] );
			$args['post__in'] = array_merge( $order_ids, array( 0 ) );
		}
	}

	return $args;
}