WordPress at Your Fingertips
function is not described

WC_Order_Data_Store_CPT::query() public WC 3.1.0

Query for Orders matching specific criteria.

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

No Hooks.

Return

Array|Object.

Usage

$WC_Order_Data_Store_CPT = new WC_Order_Data_Store_CPT();
$WC_Order_Data_Store_CPT->query( $query_vars );
$query_vars(array) (required)
query vars from a WC_Order_Query.

Changelog

Since 3.1.0 Introduced.

Code of WC_Order_Data_Store_CPT::query() WC 5.7.1

public function query( $query_vars ) {
	$args = $this->get_wp_query_args( $query_vars );

	if ( ! empty( $args['errors'] ) ) {
		$query = (object) array(
			'posts'         => array(),
			'found_posts'   => 0,
			'max_num_pages' => 0,
		);
	} else {
		$query = new WP_Query( $args );
	}

	if ( isset( $query_vars['return'] ) && 'ids' === $query_vars['return'] ) {
		$orders = $query->posts;
	} else {
		update_post_caches( $query->posts ); // We already fetching posts, might as well hydrate some caches.
		$order_ids = wp_list_pluck( $query->posts, 'ID' );
		$orders = $this->compile_orders( $order_ids, $query_vars, $query );
	}

	if ( isset( $query_vars['paginate'] ) && $query_vars['paginate'] ) {
		return (object) array(
			'orders'        => $orders,
			'total'         => $query->found_posts,
			'max_num_pages' => $query->max_num_pages,
		);
	}

	return $orders;
}