Automattic\WooCommerce\Internal\RestApi\Routes\V4\Orders\Schema

OrderItemSchema::get_imageprivateWC 1.0

Get image.

Method of the class: OrderItemSchema{}

No Hooks.

Returns

String.

Usage

// private - for code of main (parent) class only
$result = $this->get_image( $order_item );
$order_item(WC_Order_Item_Product) (required)
Order item instance.

OrderItemSchema::get_image() code WC 10.4.3

private function get_image( WC_Order_Item_Product $order_item ) {
	$product = $order_item->get_product();

	if ( ! $product instanceof \WC_Product ) {
		return '';
	}

	$image_id = $product->get_image_id() ? $product->get_image_id() : 0;
	return $image_id ? wp_get_attachment_image_url( $image_id, 'full' ) : '';
}