WC_Order_Data_Store_CPT::query( array $query_vars )
Query for Orders matching specific criteria.
Description Description
Parameters Parameters
- $query_vars
-
(Required) query vars from a WC_Order_Query.
Return Return
(array|object)
Source Source
File: includes/data-stores/class-wc-order-data-store-cpt.php
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 ); } $orders = ( isset( $query_vars['return'] ) && 'ids' === $query_vars['return'] ) ? $query->posts : array_filter( array_map( 'wc_get_order', $query->posts ) ); 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; }
Changelog Changelog
Version | Description |
---|---|
3.1.0 | Introduced. |