Show Product Thumbnail On Checkout & Thank You Page

Quick Summary

  • Filter woocommerce_cart_item_name and woocommerce_order_item_name to put a small product thumbnail before each name on checkout and the thank you page.
  • An is_checkout check keeps images off the cart page, and the thank you page passes because it is a checkout endpoint.
  • The filters only affect the shortcode-based checkout, and a deleted product breaks the thank you page image unless you add a check.

The classic WooCommerce checkout lists the products in the order review table by name only. These two filters put product thumbnails in front of the item names: one on the checkout page and one on the thank you page shown after the order is placed. Add both to your child theme’s functions.php file.

Thumbnail on the checkout page

PHP
//CHECKOUT PAGE
add_filter( 'woocommerce_cart_item_name', 'ts_product_image_on_checkout', 10, 3 );
 
function ts_product_image_on_checkout( $name, $cart_item, $cart_item_key ) {
     
    /* Return if not checkout page */
    if ( ! is_checkout() ) {
        return $name;
    }
     
    /* Get product object */
    $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
 
    /* Get product thumbnail */
    $thumbnail = $_product->get_image();
 
    /* Add wrapper to image and add some css */
    $image = '<div class="ts-product-image" style="width: 52px; height: 45px; display: inline-block; padding-right: 7px; vertical-align: middle;">'
                . $thumbnail .
            '</div>'; 
 
    /* Prepend image to name and return it */
    return $image . $name;
}
  • woocommerce_cart_item_name filters the product name of each cart item. The is_checkout() check means the image is only added on the checkout, not on the cart page.
  • get_image() returns the product image as an <img> tag, and the function puts it in front of the name.

Thumbnail on the thank you page

PHP
//THANK YOU PAGE
add_filter( 'woocommerce_order_item_name', 'ts_product_image_on_order_pay', 10, 3 );
  
function ts_product_image_on_order_pay( $name, $item, $extra ) {
      
    /* Return if not checkout page */
    if ( ! is_checkout() ) {
        return $name;
    }
      
    $product_id = $item->get_product_id();
    /* Get product object */
    $_product = wc_get_product( $product_id );
  
    /* Get product thumbnail */
    $thumbnail = $_product->get_image();
  
    /* Add wrapper to image and add some css */
    $image = '<div class="ts-product-image" style="width: 52px; height: 45px; display: inline-block; padding-right: 7px; vertical-align: middle;">'
                . $thumbnail .
            '</div>'; 
  
    /* Prepend image to name and return it */
    return $image . $name;
}
  • woocommerce_order_item_name does the same for the items of an order. The thank you page is an endpoint of the checkout page, so the is_checkout() check lets it through.
  • get_product_id() returns the parent product for a variation, so variable products show the main product image. $item->get_product() returns the variation itself if you want its own image.
  • If a product has been deleted, wc_get_product() returns false and the get_image() call fails, so a check for that is worth adding.

Both wrappers use the ts-product-image class with inline sizes of 52 by 45 pixels. You can move those styles to your stylesheet and target the class instead. The filters work with the shortcode-based checkout; the Checkout block renders its own order summary.

Courtesy of the original article on techiesandesh.com.

If your checkout and thank-you pages need a custom design, that’s part of my WooCommerce development work.

Share on X (opens in a new tab) Share on LinkedIn (opens in a new tab) Share on Facebook (opens in a new tab)

ChatGPT (opens in a new tab) Claude (opens in a new tab) Gemini (opens in a new tab) Perplexity (opens in a new tab) Grok (opens in a new tab)

More Insights

See More