Automattic\WooCommerce\Blocks\BlockTypes

FeaturedCategory::get_item()protectedWC 1.0

Returns the featured category.

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

Хуков нет.

Возвращает

\WP_Term|null.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_item( $attributes );
$attributes(массив) (обязательный)
Block attributes.
По умолчанию: empty array

Код FeaturedCategory::get_item() WC 8.7.0

protected function get_item( $attributes ) {
	$id = absint( $attributes['categoryId'] ?? 0 );

	$category = get_term( $id, 'product_cat' );
	if ( ! $category || is_wp_error( $category ) ) {
		return null;
	}

	return $category;
}