Display a product’s featured image instead of the variation thumbnail in cart

When you have images linked to individual product variations, the cart will display those variation thumbnails.

Featured Image:

Product-Featured-Image

Variation Image:

Product-Variation-Image

However, if you want the cart to display the product’s featured image, you can add the following custom code snippet to your child theme’s functions.php file:

// Add this to your child theme's functions.php file
function wc_custom_cart_thumb( $thumb, $cart_item ) {
    return get_the_post_thumbnail( $cart_item['product_id'], 'shop_thumbnail' );
}
add_filter( 'woocommerce_cart_item_thumbnail', 'wc_custom_cart_thumb', 10, 2 );
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s