Code Duplication    Length = 8-10 lines in 3 locations

includes/data-stores/class-wc-product-variable-data-store-cpt.php 1 location

@@ 139-146 (lines=8) @@
136
			$visible_only_args                = $all_args;
137
			$visible_only_args['post_status'] = 'publish';
138
139
			if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) {
140
				$visible_only_args['tax_query'][] = array(
141
					'taxonomy' => 'product_visibility',
142
					'field'    => 'name',
143
					'terms'    => 'outofstock',
144
					'operator' => 'NOT IN',
145
				);
146
			}
147
			$children['all']     = get_posts( apply_filters( 'woocommerce_variable_children_args', $all_args, $product, false ) );
148
			$children['visible'] = get_posts( apply_filters( 'woocommerce_variable_children_args', $visible_only_args, $product, true ) );
149

includes/widgets/class-wc-widget-products.php 1 location

@@ 129-138 (lines=10) @@
126
			);
127
		}
128
129
		if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) {
130
			$query_args['tax_query'][] = array(
131
				array(
132
					'taxonomy' => 'product_visibility',
133
					'field'    => 'term_taxonomy_id',
134
					'terms'    => $product_visibility_term_ids['outofstock'],
135
					'operator' => 'NOT IN',
136
				),
137
			); // WPCS: slow query ok.
138
		}
139
140
		switch ( $show ) {
141
			case 'featured':

includes/widgets/class-wc-widget-recently-viewed.php 1 location

@@ 71-80 (lines=10) @@
68
			'orderby'        => 'post__in',
69
		);
70
71
		if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) {
72
			$query_args['tax_query'] = array(
73
				array(
74
					'taxonomy' => 'product_visibility',
75
					'field'    => 'name',
76
					'terms'    => 'outofstock',
77
					'operator' => 'NOT IN',
78
				),
79
			); // WPCS: slow query ok.
80
		}
81
82
		$r = new WP_Query( apply_filters( 'woocommerce_recently_viewed_products_widget_query_args', $query_args ) );
83