I've been trying to add a product thumbnail image linking to product on customer Recent Orders page, My Account in woocommerce. I have managed to get the Image Thumbnail in place thanks to Anand from this question here : Add Product Thumbnail to My Account - Recent Orders - Woocommerce, but now I'm strugling to make this thumb a permalink that links to the actual product.
So I know that this is the code to get the image thumbnail in place :
<?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();
}
?>
I've been trying to turn the thumbnail into a permalink like this :
<?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 '<a href="'.get_permalink($product_id).'"><?php echo $product_obj->get_image();?></a>';
}
?>
Or like this :
echo '<a href="'.get_permalink($product_id).'">'echo $product_obj->get_image()'</a>';
Or this :
<a href="<?php echo $url = get_permalink( $product_id ); ?>">
<?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();
}
?>
But just can't seem to be anywhere near .. ?