How to add the product image to the template?

Use below filter function to add the product thumbnail image below the product description on the template. Add the code to your functions.php file within your theme.

function add_product_image( $description, $item_id, $item ) {
	$product = $item->get_product();

	if ( $product ) {
		$description = sprintf( '<table style="border:none;padding:0;margin:0;"><tr><td width="10%%" style="border:none;padding:0;"><img src="%s" width="50" height="50"/></td><td width="40%%" style="border:none;padding:0;text-align:left;">%s</td></tr></table>', wp_get_attachment_url( $product->get_image_id() ), $description );
	}

	return $description;
}
add_filter( 'wpi_item_description_data', 'add_product_image', 10, 3 );

Still need help? Contact Us Contact Us