Wordpress getting the woocommerce thumnail when printing

I am trying to get the thumnail image when I print the order information for a woocommerce order, but I am getting some errors.

This is my code:

<?php $items = wcdn_get_order_items(); if( sizeof( $items ) > 0 ) : foreach( $items as $item ) : ?><tr>
                            <td class="description"><?php echo $item['name']; ?> <br><br>Excerpt:<?php $excerpt = $item['product']->post->post_excerpt; echo $excerpt; ?>
                                                             <br><br>Image:<?php echo $item['product']->post->post_thumbnail; ?>

The excert bit works fine, but I am am not getting the image - I am not getting a php error, but there is no image either - I am just trying to get the thumbnail.

My knowledge of wordpress/php isnt brilliant, so any advice would be greatly appreciated.

Solutions

Could you not use get_the_post_thumbnail(); ? It would give you an image you could use. In your example it would be something like:

<?php $items = wcdn_get_order_items(); if( sizeof( $items ) > 0 ) : foreach( $items as $item ) : ?><tr>
          <td class="description"><?php echo $item['name']; ?> <br><br>Excerpt:<?php $excerpt = $item['product']->post->post_excerpt; echo $excerpt; ?>
          <br><br>Image:<?php echo get_the_post_thumbnail($item['product']->post->ID);  ?>

I am not entirely sure what id to give the function, but i am sure you will figure that out.

Tags: PHP / Html / Css

Similar questions

How to show thumnail picture/featured picture of the post in excerpt feed
So I'm using feedburner for my feeds and using that option to only show excerpt/summary of the blog posts, the only problem is that with this option and not the full posts into the feed, it won't show me the images, the featured images of that post. Is there a way I can do that? Thank you
Getting top Image From the Gallery and printing out a thumbnail with Exact Dimensions
I'm looking for a plugin that pulls an Image from a Wordpress Posts Gallery (Note NOT the Featured Thumbnail, we have thousands of posts and can't retroactively go back and set a Featured image for each post..) Also some of the plugins I've tested don't let you specify exact dimensions, the Wordpress Get The Image Plugin let's you pull an image fro...
Getting WP Functions to Return rather than Printing Immediately
I'm trying to build an array within "The Loop" of values provided from various functions like the_title(), the_excerpt(), the_permalink() and others. I'd like to do something similar to what follows. The unfortunate thing is that most of these functions immediately print their results rather than returning them. Furthermore, I have checked the avai...
Getting jQuery for loop printing my function by incrementing values
I am dealing with strange issue, but that should be a simple solution as my mind totally stuck I don't know where I am going wrong, simply I want to put my function thrice as shown below in example: If my function is : I simply want it to be two times more by just incrementing my selector value like '#gallery-v' to '#gallery-v1' and for '#filterlis...
error in printing form in woocommerce
I am creating a payment gateway plugin for woocommerce form my payment gateway. After i click on the checkout page through my payment gateway. I am getting an syntax error.I think i am not wrong below is my process_payment function code its give me an error SyntaxError: Unexpected token < I think i am using the correct syntax for printing form i...
Printing values of Product Array in Woocommerce
Unfortunately I'm not as strong as I'd like to be in pHp, so I might be asking a pretty basic question. I'm just trying to figure out why I can't print the individual values of the product array. print_r($product) returns: I tried But that doesn't work. So then I tried But that prints an error. My feeling is that the first option is working, just i...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.