From 29f152633bd670d52bb208328a284ea8200ad109 Mon Sep 17 00:00:00 2001 From: Florian Ludwig Date: Fri, 17 Oct 2014 16:53:14 +0200 Subject: [PATCH] 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 --- includes/api/class-wc-api-products.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/api/class-wc-api-products.php b/includes/api/class-wc-api-products.php index 5b5c7fbf2f5..8002f9c8899 100644 --- a/includes/api/class-wc-api-products.php +++ b/includes/api/class-wc-api-products.php @@ -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 );