Automattic\WooCommerce\Blocks\BlockTypes

FeaturedProduct::get_item_image_id │ protected │ WC 1.0

Returns the featured product image attachment ID.

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

Хуков нет.

Возвращает

int.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_item_image_id( $product );
$product(WC_Product) (обязательный)
Product object.

Код FeaturedProduct::get_item_image_id() WC 11.3.0

protected function get_item_image_id( $product ) {
	$image_id = $product->get_image_id();
	if ( $image_id ) {
		return (int) $image_id;
	}

	if ( $product->get_parent_id() ) {
		$parent_product = wc_get_product( $product->get_parent_id() );
		if ( $parent_product ) {
			return (int) $parent_product->get_image_id();
		}
	}

	return 0;
}