Automattic\WooCommerce\Blocks\BlockTypes
ProductCategories::fill_category_children()
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() ProductCategories::fill category children WC 7.5.1
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; }