WC_API_Products::query_products() private WC 2.1
Helper method to get product post objects
{} It's a 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. |
Code of WC_API_Products::query_products() WC API Products::query products WC 5.0.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 );
}