Automattic\WooCommerce\Blocks\BlockTypes
ProductQuery::get_filter_by_stock_status_query()
Return a query that filters products by stock status.
Method of the class: ProductQuery{}
No Hooks.
Return
Array
.
Usage
// private - for code of main (parent) class only $result = $this->get_filter_by_stock_status_query();
ProductQuery::get_filter_by_stock_status_query() ProductQuery::get filter by stock status query code WC 9.4.2
private function get_filter_by_stock_status_query() { $filter_stock_status_values = get_query_var( StockFilter::STOCK_STATUS_QUERY_VAR ); if ( empty( $filter_stock_status_values ) ) { return array(); } $filtered_stock_status_values = array_filter( explode( ',', $filter_stock_status_values ), function( $stock_status ) { return in_array( $stock_status, StockFilter::get_stock_status_query_var_values(), true ); } ); if ( empty( $filtered_stock_status_values ) ) { return array(); } return array( // Ignoring the warning of not using meta queries. // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query 'meta_query' => array( array( 'key' => '_stock_status', 'value' => $filtered_stock_status_values, 'operator' => 'IN', ), ), ); }