Automattic\WooCommerce\Blocks\BlockTypes
ProductQuery::build_query()
Return a custom query based on attributes, filters and global WP_Query.
Метод класса: ProductQuery{}
Хуков нет.
Возвращает
Массив
.
Использование
$ProductQuery = new ProductQuery(); $ProductQuery->build_query( $query );
- $query(WP_Query) (обязательный)
- The WordPress Query.
Код ProductQuery::build_query() ProductQuery::build query WC 8.7.0
public function build_query( $query ) { $parsed_block = $this->parsed_block; if ( ! $this->is_woocommerce_variation( $parsed_block ) ) { return $query; } $common_query_values = array( 'meta_query' => array(), 'posts_per_page' => $query['posts_per_page'], 'orderby' => $query['orderby'], 'order' => $query['order'], 'offset' => $query['offset'], 'post__in' => array(), 'post_status' => 'publish', 'post_type' => 'product', 'tax_query' => array(), ); $handpicked_products = isset( $parsed_block['attrs']['query']['include'] ) ? $parsed_block['attrs']['query']['include'] : $common_query_values['post__in']; $merged_query = $this->merge_queries( $common_query_values, $this->get_global_query( $parsed_block ), $this->get_custom_orderby_query( $query['orderby'] ), $this->get_queries_by_custom_attributes( $parsed_block ), $this->get_queries_by_applied_filters(), $this->get_filter_by_taxonomies_query( $query ), $this->get_filter_by_keyword_query( $query ) ); return $this->filter_query_to_only_include_ids( $merged_query, $handpicked_products ); }