Automattic\WooCommerce\Blocks\BlockTypes
FeaturedProduct::get_item_image_id
Returns the featured product image attachment ID.
Method of the class: FeaturedProduct{}
No Hooks.
Returns
int.
Usage
// protected - for code of main (parent) or child class $result = $this->get_item_image_id( $product );
- $product(WC_Product) (required)
- Product object.
FeaturedProduct::get_item_image_id() FeaturedProduct::get item image id code WC 11.1.2
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;
}