WC_Order_Data_Store_CPT::query()
Query for Orders matching specific criteria.
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. |
WC_Order_Data_Store_CPT::query() WC Order Data Store CPT::query code WC 8.7.0
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; }