Automattic\WooCommerce\Blocks\BlockTypes
ProductsByAttribute::set_block_query_args
Set args specific to this block
Method of the class: ProductsByAttribute{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->set_block_query_args( $query_args );
- $query_args(array) (required) (passed by reference — &)
- Query args.
ProductsByAttribute::set_block_query_args() ProductsByAttribute::set block query args code WC 10.8.1
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',
);
}
}