Hello.
I’m trying to figure out how to change the representative image of a product on the Cart page. I know by default this image is set to the first image uploaded for the product. However, for my situation, my first image is great to display by default on the product page but I want the Cart’s image to be different and a little simpler. How am I able to do this? I have a Dawn 2.0 theme.
Thanks!
2 Likes
@JonCarag
no sorry its not possible
If you need this customization you can contact me(please provide context).
UX: warning don’t casually swap images at different phases of what’s shown to be put in the cart between product ,cart , and checkout pages it’s a good way to confuse customers . Make sure you a/b test stuff like this if the variant-image a customer sees when they click add-to-cart will be swapped for another at a later time, especially if that image is no where on the product page.
Depending on theme this should just be solved by giving each variant it’s own image.
https://shopify.dev/api/liquid/objects#line_item-image
This can of course be a problem if you only have products that don’t have multiple variants.
If you cannot have multiple variants on a product then you actually need to invert the situation to avoid other problems* and instead on product pages make some other image swap into the place of the featured image,
If you must do swap the image in the cart then themes /cart template you would need to iterate through the line-items and access each line-items product object to get to other images, or some other construct depending on where this other image lives.
See dawn reference of example cart code https://github.com/Shopify/dawn/blob/main/sections/main-cart-items.liquid#L69
*But this can be a moot point for as soon as a visitor goes to /checkout the images shown will default to the default image. Unless you are on shopify Plus you cannot modify the checkout.
And you would also have to update ALL notification templates to reference some other media.
1 Like
“… and instead on product pages make some other image swap into the place of the featured image.”
Can you comment on which API/calls you had in mind for that?
Thank you.
(Why? Well, I’d like to do that swap on the fly each time a user changes some product customization parameter in the browser. And, naturally, that custom featured image should not affect other visitors’ view of the same product page.)
Hi PaulNewton,
I want similar feature to be implemented at my store, when I add the product to cart or Buy, I want to update the image of selected variant with the first variant’s image, irrespective of which variant is selected. Is this possible? If so please guide me how to do it.
PREVIEW
This is very helpful and close to the solution – but for Dawn you need to modify cart-drawer.liquid and not main-cart-items.liquid
1 Like
@nicholasm1
Please share your store URL so I can take a look and provide the right solution. If there’s anything specific you need help with, feel free to mention it!