RESTAPI 2 Add possibility to filter by product_cat

For products it would be nice to be able to filter by product cat.

usage: filter[product_cat]=CATSLUG
This commit is contained in:
Florian Ludwig 2014-10-17 16:53:14 +02:00
parent 44ad43216e
commit 29f152633b
1 changed files with 5 additions and 0 deletions

View File

@ -485,6 +485,11 @@ class WC_API_Products extends WC_API_Resource {
unset( $args['type'] );
}
// filter products by category
if( ! empty( $args['product_cat'] ) ) {
$query_args['product_cat'] = $args['product_cat'];
}
$query_args = $this->merge_query_args( $query_args, $args );
return new WP_Query( $query_args );