Automattic\WooCommerce\Blocks\BlockTypes
ProductsByAttribute::set_block_query_args() protected WC 1.0
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 5.1.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',
);
}
}