Automattic\WooCommerce\StoreApi\Schemas\V1
ShopperListItemSchema::get_images
Get the main image for a shopper list item.
Returns the product's main image only — shopper list rows are compact and the gallery isn't needed at the row level.
Method of the class: ShopperListItemSchema{}
No Hooks.
Returns
Array.
Usage
// private - for code of main (parent) class only $result = $this->get_images( $product ): array;
- $product(WC_Product) (required)
- Live product instance.
ShopperListItemSchema::get_images() ShopperListItemSchema::get images code WC 10.9.4
private function get_images( \WC_Product $product ): array {
$image_id = (int) $product->get_image_id();
if ( $image_id <= 0 ) {
return array();
}
$image = $this->image_attachment_schema->get_item_response( $image_id );
return $image ? array( $image ) : array();
}