Automattic\WooCommerce\EmailEditor\Integrations\WooCommerce\Renderer\Blocks

Product_Collection::build_attribute_queryprivateWC 1.0

Build attribute query from woocommerceAttributes block attributes.

Method of the class: Product_Collection{}

No Hooks.

Returns

Array.

Usage

// private - for code of main (parent) class only
$result = $this->build_attribute_query( $attributes ): array;
$attributes(array) (required)
Attribute filters from block attributes.

Product_Collection::build_attribute_query() code WC 10.4.3

private function build_attribute_query( array $attributes ): array {
	$attribute_queries = array();

	foreach ( $attributes as $attribute ) {
		if ( ! empty( $attribute['taxonomy'] ) && ! empty( $attribute['termId'] ) ) {
			$attribute_queries[] = array(
				'taxonomy' => $attribute['taxonomy'],
				'field'    => 'term_id',
				'terms'    => array( (int) $attribute['termId'] ),
			);
		}
	}

	return $attribute_queries;
}