From a855ebc27dbf57b7534c0c165f4937d7f5c680ef Mon Sep 17 00:00:00 2001 From: VoHoTv <58689798+VoHoTv@users.noreply.github.com> Date: Mon, 5 Jul 2021 10:48:34 +0200 Subject: [PATCH] Fix filtering by product type on Store API (#4422) * Fixed $tax_query being set to an empty array * Remove whitespace causing PHP coding standards test to fail * Cleanup: add line break Co-authored-by: Michael P. Pfeiffer --- src/StoreApi/Utilities/ProductQuery.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/StoreApi/Utilities/ProductQuery.php b/src/StoreApi/Utilities/ProductQuery.php index 89a87156ee5..efd2a6e9e31 100644 --- a/src/StoreApi/Utilities/ProductQuery.php +++ b/src/StoreApi/Utilities/ProductQuery.php @@ -41,6 +41,9 @@ public function prepare_objects_query( $request ) { $args['post_type'] = [ 'product', 'product_variation' ]; } + // Taxonomy query to filter products by type, category, tag, shipping class, and attribute. + $tax_query = []; + // Filter product type by slug. if ( ! empty( $request['type'] ) ) { if ( 'variation' === $request['type'] ) { @@ -88,9 +91,6 @@ public function prepare_objects_query( $request ) { } } - // Taxonomy query to filter products by type, category, tag, shipping class, and attribute. - $tax_query = []; - $operator_mapping = [ 'in' => 'IN', 'not_in' => 'NOT IN',