Automattic\WooCommerce\Blocks

QueryFilters::stock_filter_clauses()privateWC 1.0

Add query clauses for stock filter.

Method of the class: QueryFilters{}

No Hooks.

Return

Array.

Usage

// private - for code of main (parent) class only
$result = $this->stock_filter_clauses( $args, $wp_query );
$args(array) (required)
Query args.
$wp_query(\WP_Query) (required)
WP_Query object.

QueryFilters::stock_filter_clauses() code WC 9.4.2

private function stock_filter_clauses( $args, $wp_query ) {
	if ( ! $wp_query->get( 'filter_stock_status' ) ) {
		return $args;
	}

	$args['join']   = $this->append_product_sorting_table_join( $args['join'] );
	$args['where'] .= ' AND wc_product_meta_lookup.stock_status IN ("' . implode( '","', array_map( 'esc_sql', explode( ',', $wp_query->get( 'filter_stock_status' ) ) ) ) . '")';

	return $args;
}