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:
parent
44ad43216e
commit
29f152633b
|
@ -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 );
|
||||
|
|
Loading…
Reference in New Issue