Automattic\WooCommerce\Blocks\BlockTypes

FeaturedCategory::get_item()protectedWC 1.0

Returns the featured category.

Method of the class: FeaturedCategory{}

No Hooks.

Return

\WP_Term|null.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_item( $attributes );
$attributes(array) (required)
Block attributes.
Default: empty array

FeaturedCategory::get_item() code WC 9.0.1

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;
}