Automattic\WooCommerce\Internal\ProductFeed\Mapping

UcpProductMapper::term_names │ private │ WC 1.0

Index term names by slug for each variation attribute of a product.

Метод класса: UcpProductMapper{}

Хуков нет.

Возвращает

array. Attribute label => [ slug => term name ].

Использование

// private - только в коде основоного (родительского) класса
$result = $this->term_names( $item ): array;
$item(массив) (обязательный)
Store API item response of the variable product.

Код UcpProductMapper::term_names() WC 11.3.0

private function term_names( array $item ): array {
	$names = array();

	foreach ( (array) $item['attributes'] as $attribute ) {
		if ( empty( $attribute['has_variations'] ) ) {
			continue;
		}

		foreach ( (array) $attribute['terms'] as $term ) {
			$names[ (string) $attribute['name'] ][ (string) $term['slug'] ] = (string) $term['name'];
		}
	}

	return $names;
}