AbstractProductGrid::set_categories_query_args() – Set categories query args.

You appear to be a bot. Output may be restricted

Description

Set categories query args.

Usage

AbstractProductGrid::set_categories_query_args( $query_args );

Parameters

$query_args
( array ) required – Query args.

Returns

void

Source

File name: woocommerce/packages/woocommerce-blocks/src/BlockTypes/AbstractProductGrid.php
Lines:

1 to 18 of 18
  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,
      );
    }
  }
 

 View on GitHub View on Trac