🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Change Product Image in Magento 2 Checkout Cart

By Sanjay JethvaUpdated on Jul 16, 2025 1 min read

Magento 2 checkout cart page is the intermediate point that proceeds to finalize the purchase. The product image displayed on the checkout cart page gives the customer a quick overview of the items they are about to purchase.

However, when the product has multiple colors and options the image might not match the desired custom selection of the customer.
Moreover, when a store owner wants to give a free product based on a condition, and that product belongs to the customer’s selected configured one.

In that case, what if a store owner needs to display an image of the main product in the free one?

Any solution? Here is the quick solution. Apply the below method to change product image in Magento 2 checkout cart!

Method to Change Product Image in Magento 2 Checkout Cart

1. Use the below code in the di.xml file at app/code/Vendor/Extension/etc

<type name="Magento\Checkout\Block\Cart\Item\Renderer">
    <plugin name="product_image_checkout_cart" type="Vendore\Extension\Plugin\CheckoutCart\NewImage" sortOrder="1"/>
</type>

2. Create the NewImage.php file at Vendor/Extension/Plugin/CheckoutCart

<?php

namespace Vendore\Extension\Plugin\CheckoutCart;

class NewImage

{

    public function afterGetImage($item, $result)

    {

     if(CONDITION) {

     $result->setImageUrl(IMAGE_URL);

     }

     return $result;

    }

}

That’s it!

Feel free to share the solution with Magento Community via social media.

Thank You.

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.