WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\BlockTypes

AbstractProductGrid::set_categories_query_args() protected WC 1.0

Set categories query args.

{} It's a method of the class: AbstractProductGrid{}

No Hooks.

Return

null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->set_categories_query_args( $query_args );
$query_args(array) (required) (passed by reference — &)
Query args.

Code of AbstractProductGrid::set_categories_query_args() WC 5.7.1

protected function set_categories_query_args( &$query_args ) {
	if ( ! empty( $this->attributes['categories'] ) ) {
		$categories = array_map( 'absint', $this->attributes['categories'] );

		$query_args['tax_query'][] = array(
			'taxonomy'         => 'product_cat',
			'terms'            => $categories,
			'field'            => 'term_id',
			'operator'         => 'all' === $this->attributes['catOperator'] ? 'AND' : 'IN',

			/*
			 * When cat_operator is AND, the children categories should be excluded,
			 * as only products belonging to all the children categories would be selected.
			 */
			'include_children' => 'all' === $this->attributes['catOperator'] ? false : true,
		);
	}
}