WC_API_Products::query_products()
Helper method to get product post objects
Method of the class: WC_API_Products{}
No Hooks.
Return
WP_Query
.
Usage
// private - for code of main (parent) class only $result = $this->query_products( $args );
- $args(array) (required)
- request arguments for filtering query
Changelog
Since 2.1 | Introduced. |
WC_API_Products::query_products() WC API Products::query products code WC 7.7.0
private function query_products( $args ) { // set base query arguments $query_args = array( 'fields' => 'ids', 'post_type' => 'product', 'post_status' => 'publish', 'meta_query' => array(), ); if ( ! empty( $args['type'] ) ) { $types = explode( ',', $args['type'] ); $query_args['tax_query'] = array( array( 'taxonomy' => 'product_type', 'field' => 'slug', 'terms' => $types, ), ); unset( $args['type'] ); } $query_args = $this->merge_query_args( $query_args, $args ); return new WP_Query( $query_args ); }