WC_REST_Orders_V2_Controller::get_objects()protectedWC 1.0

Get objects.

Method of the class: WC_REST_Orders_V2_Controller{}

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_objects( $query_args );
$query_args(array) (required)
Query args.

WC_REST_Orders_V2_Controller::get_objects() code WC 7.7.0

protected function get_objects( $query_args ) {
	// Do not use WC_Order_Query for the CPT datastore.
	if ( ! OrderUtil::custom_orders_table_usage_is_enabled() ) {
		return parent::get_objects( $query_args );
	}

	$query   = new \WC_Order_Query(
		array_merge(
			$query_args,
			array(
				'paginate' => true,
			)
		)
	);
	$results = $query->get_orders();

	return array(
		'objects' => $results->orders,
		'total'   => $results->total,
		'pages'   => $results->max_num_pages,
	);
}