Automattic\WooCommerce\Blocks\BlockTypes
ProductsByAttribute::set_block_query_args()
Set args specific to this block
Метод класса: ProductsByAttribute{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->set_block_query_args( $query_args );
- $query_args(массив) (обязательный) (передается по ссылке — &)
- Query args.
Код ProductsByAttribute::set_block_query_args() ProductsByAttribute::set block query args WC 8.7.0
protected function set_block_query_args( &$query_args ) { if ( ! empty( $this->attributes['attributes'] ) ) { $taxonomy = sanitize_title( $this->attributes['attributes'][0]['attr_slug'] ); $terms = wp_list_pluck( $this->attributes['attributes'], 'id' ); $query_args['tax_query'][] = array( 'taxonomy' => $taxonomy, 'terms' => array_map( 'absint', $terms ), 'field' => 'term_id', 'operator' => 'all' === $this->attributes['attrOperator'] ? 'AND' : 'IN', ); } }