Automattic\WooCommerce\Blocks\BlockTypes

FeaturedProduct::get_item()protectedWC 1.0

Returns the featured product.

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

Хуков нет.

Возвращает

\WP_Term|null.

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

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

Код FeaturedProduct::get_item() WC 8.7.0

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

	$product = wc_get_product( $id );
	if ( ! $product ) {
		return null;
	}

	return $product;
}