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 10.4.0
protected function get_item( $attributes ) {
$id = absint( $attributes['productId'] ?? 0 );
$product = wc_get_product( $id );
if ( ! $product || ( ProductStatus::PUBLISH !== $product->get_status() && ! current_user_can( 'read_product', $id ) ) ) {
return null;
}
return $product;
}