Automattic\WooCommerce\Blocks\BlockTypes
FeaturedProduct::get_item
Returns the featured product.
Метод класса: FeaturedProduct{}
Хуков нет.
Возвращает
\WP_Term|null.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_item( $attributes );
- $attributes(массив) (обязательный)
- Block attributes.
По умолчанию:empty array
Код FeaturedProduct::get_item() FeaturedProduct::get item WC 11.3.0
protected function get_item( $attributes ) {
$id = absint( $attributes['productId'] ?? 0 );
$product = wc_get_product( $id );
if ( ! $product || ! $product->is_viewable() ) {
return null;
}
return $product;
}