Automattic\WooCommerce\Internal\ProductFilters

QueryClauses::add_attribute_clauses │ public │ WC 1.0

Add query clauses for filtering products by attributes.

Method of the class: QueryClauses{}

No Hooks.

Returns

array.

Usage

$QueryClauses = new QueryClauses();
$QueryClauses->add_attribute_clauses( $args, $chosen_attributes ): array;
$args(array) (required)
Query args.
$chosen_attributes(array) (required)

Chosen attributes array.

  • {$taxonomy:(array)
    Attribute taxonomy name} {
    @type string[] $terms      Chosen terms' slug.
    @type string   $query_type Query type. Accepts 'and' or 'or'.

QueryClauses::add_attribute_clauses() code WC 11.3.0

public function add_attribute_clauses( array $args, array $chosen_attributes ): array {
	if ( empty( $chosen_attributes ) ) {
		return $args;
	}

	if ( 'yes' !== get_option( 'woocommerce_attribute_lookup_enabled' ) ) {
		return $this->add_attribute_taxonomy_clauses( $args, $chosen_attributes );
	}

	return $this->add_attribute_lookup_table_clauses( $args, $chosen_attributes );
}