How to display items thumbnail of the order in WooCommerce?

I would like to display the thumbnails of all items in the orders I received from my customers. I'm using Add products thumbnail to Woocommerce admin orders list answer code but sometimes I got error with the notice:

"Error message: Uncaught Error: Call to a member function get_image_id() on bool in".

I wonder how can I solve this problem?


I am checking as you share the link, It's working fine but if you got an issue should be a versioning issue or something missing.

I have few/small changes, I hope this is helpful for you.

// Add a new custom column name "Product Image" to admin order list
add_filter( 'manage_edit-shop_order_columns', 'woo_admin_orders_list_add_column', 10, 1 );

function woo_admin_orders_list_add_column( $columns ){
    $columns['custom_column'] = __( 'Product Image', 'woocommerce' );

    return $columns;

// The data of the new custom column value in admin order list
add_action( 'manage_shop_order_posts_custom_column' , 'woo_add_product_image_order_column', 10, 2 );

function woo_add_product_image_order_column( $column, $post_id ){
    global $order;

    if( 'custom_column' === $column ){
        $count = 0;

        $order = wc_get_order($post_id);
        // Loop through order items
        foreach( $order->get_items() as $item ) {
            $product = $item->get_product(); // The WC_Product Object
            $style   = $count > 0 ? ' style="padding-left:6px;"' : '';

            // Display product thumbnail
            printf( '<span%s>%s</span>', $style, $product->get_image( array( 50, 50 ) ) );


Similar questions

Get the order item Id in WooCommerce order items
With WooCommerce, I am trying to change the download URLs for order items. Originally I was using the order ID but that only allows one subscription per order. So I need the customer to be able to purchase more than one subscription. Here is the code I currently have: Everything works except I am not able to get the order item ID. Any help would be...
Woocommerce: Order items not showing in order email
All my orders are created with the on-hold state by default until payment is confirmed and then the state turns to processing. I created a hook to send the on-hold email every time a new order is created to ensure every user will receive an email once the order is created. The email is being sent, but for some reason, the order items are not being ...
Send new order email to CC if order has items from a certain category in WooCommerce
I want to send admin new order e-mail to cc, if order has items from a parent product category: I am using the code below but this doesn't seem to work. The mail is being sent but I receive a notification for an undefined variable. The person in CC does not receive the message either Someone who wants to take a closer look at this?
Get order items stock status when order was created in WooCommerce
There is an issue when including "stock status" of the purchased items on the client email. If the client orders the last unit of an item, even though when he ordered it was clearly instock (available for immediate shipping), then the stock status turns to outofstock/onbackorder and the email that is sent to the client (which I assume is ...
Adding prefix to WooCommerce order number if order has items from a specific product category
In a webshop that can only have one item in the cart, I need to add a prefix to the order number when the order contains an item from a specific category For this I wrote the following code: Now I need the following function to run if $category_in_order: But I cant seem to find out. Can I add a filter and function whitin an if statement?
Add a custom column to order items and make it sortable in WooCommerce admin order details page
I have been working to add a item product attribute to the admin order details page - which I have managed. You can see the extra column titled "Packing Weight". However, I would ideally like to order the items in the order by this column e.g. Very Soft, Soft, Hard. I am happy to change the values of packing weight to a numeric scale 1 - ...

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.