Automattic\WooCommerce\Blocks\BlockTypes

ProductCategories::fill_category_children()protectedWC 1.0

Build hierarchical tree of categories by appending children in the tree.

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

Хуков нет.

Возвращает

Массив.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->fill_category_children( $categories, $categories_by_parent );
$categories(массив) (обязательный)
List of terms.
$categories_by_parent(массив) (обязательный)
List of terms grouped by parent.

Код ProductCategories::fill_category_children() WC 8.7.0

protected function fill_category_children( $categories, $categories_by_parent ) {
	foreach ( $categories as $category ) {
		if ( ! empty( $categories_by_parent[ 'cat-' . $category->term_id ] ) ) {
			$category->children = $this->fill_category_children( $categories_by_parent[ 'cat-' . $category->term_id ], $categories_by_parent );
		}
	}
	return $categories;
}