Code Duplication    Length = 7-7 lines in 5 locations

includes/api/class-wc-rest-products-controller.php 1 location

@@ 109-115 (lines=7) @@
106
		}
107
108
		// Filter product type by slug.
109
		if ( ! empty( $request['type'] ) ) {
110
			$tax_query[] = array(
111
				'taxonomy' => 'product_type',
112
				'field'    => 'slug',
113
				'terms'    => $request['type'],
114
			);
115
		}
116
117
		// Filter by attribute and term.
118
		if ( ! empty( $request['attribute'] ) && ! empty( $request['attribute_term'] ) ) {

includes/api/v1/class-wc-rest-products-controller.php 1 location

@@ 168-174 (lines=7) @@
165
		}
166
167
		// Filter product type by slug.
168
		if ( ! empty( $request['type'] ) ) {
169
			$tax_query[] = array(
170
				'taxonomy' => 'product_type',
171
				'field'    => 'slug',
172
				'terms'    => $request['type'],
173
			);
174
		}
175
176
		// Filter by attribute and term.
177
		if ( ! empty( $request['attribute'] ) && ! empty( $request['attribute_term'] ) ) {

includes/api/v2/class-wc-rest-products-v2-controller.php 1 location

@@ 229-235 (lines=7) @@
226
		}
227
228
		// Filter product type by slug.
229
		if ( ! empty( $request['type'] ) ) {
230
			$tax_query[] = array(
231
				'taxonomy' => 'product_type',
232
				'field'    => 'slug',
233
				'terms'    => $request['type'],
234
			);
235
		}
236
237
		// Filter by attribute and term.
238
		if ( ! empty( $request['attribute'] ) && ! empty( $request['attribute_term'] ) ) {

includes/data-stores/class-wc-product-data-store-cpt.php 2 locations

@@ 1742-1748 (lines=7) @@
1739
		}
1740
1741
		// Handle product categories.
1742
		if ( ! empty( $query_vars['category'] ) ) {
1743
			$wp_query_args['tax_query'][] = array(
1744
				'taxonomy' => 'product_cat',
1745
				'field'    => 'slug',
1746
				'terms'    => $query_vars['category'],
1747
			);
1748
		}
1749
1750
		// Handle product tags.
1751
		if ( ! empty( $query_vars['tag'] ) ) {
@@ 1761-1767 (lines=7) @@
1758
		}
1759
1760
		// Handle shipping classes.
1761
		if ( ! empty( $query_vars['shipping_class'] ) ) {
1762
			$wp_query_args['tax_query'][] = array(
1763
				'taxonomy' => 'product_shipping_class',
1764
				'field'    => 'slug',
1765
				'terms'    => $query_vars['shipping_class'],
1766
			);
1767
		}
1768
1769
		// Handle total_sales.
1770
		// This query doesn't get auto-generated since the meta key doesn't have the underscore prefix.