Automattic\WooCommerce\Blocks\BlockTypes
ProductQuery::get_product_visibility_query()
Return a query for product visibility depending on their stock status.
Метод класса: ProductQuery{}
Хуков нет.
Возвращает
Массив
. Tax query for product visibility.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_product_visibility_query( $stock_query );
- $stock_query(массив) (обязательный)
- Stock status query.
Код ProductQuery::get_product_visibility_query() ProductQuery::get product visibility query WC 9.2.3
private function get_product_visibility_query( $stock_query ) { $product_visibility_terms = wc_get_product_visibility_term_ids(); $product_visibility_not_in = array( is_search() ? $product_visibility_terms['exclude-from-search'] : $product_visibility_terms['exclude-from-catalog'] ); // Hide out of stock products. if ( empty( $stock_query ) && 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) { $product_visibility_not_in[] = $product_visibility_terms['outofstock']; } return array( 'tax_query' => array( array( 'taxonomy' => 'product_visibility', 'field' => 'term_taxonomy_id', 'terms' => $product_visibility_not_in, 'operator' => 'NOT IN', ), ), ); }