I would like to add image on my account view order pages in Woocommerce.some one I am able to get the image but the size is too large and I don't know where I need to add this code:
<?php
// Get a list of all items that belong to the order
$products = $order->get_items();
// Loop through the items and get the product image
foreach( $products as $product ) {
$product_obj = new WC_Product( $product["product_id"] );
echo $product_obj->get_image();
}
?>
Any help will be appreciated
Here is the location on the View order pages, wher I would like to add the product image:
Instead of getting the main image, you just need to fetch the thumbnail via get_the_post_thumbnail():
Write it on woocommerce/template/order/ordr-details-item.php
this will give you a 80x80 size image change it according to your neesd.
The following hooked function will do the job (You may need to add some CSS style rules):
Code goes in function.php file of your active child theme (or active theme). Tested and works.
Note the
WC_Product
methodget_image()
uses Wordpressget_the_post_thumbnail()
internally.