Cart Product Image is Variant Image rather than Product Image

I would like to have it so that when viewing the cart the product image reflects the product variant image rather than the product image.



I am guessing the following element in customer/views/checkout/components/cart_items.tpl would need to be changed:


<br />
<div class="product-image"><br />
<a href="{$index_script}?dispatch=products.view&product_id={$product.product_id}"><br />
{include file="common_templates/image.tpl" image_width=100 [COLOR="Red"]images=$product.main_pair[/COLOR] object_type="product"}<br />
</a><br />
</div><br />

```<br />
<br />
I guess there will need to be some kind of 'if' statement to check if there are variants and to bring back the image that relates to the variant.  If there are no variants that it shows the main product image.<br />
<br />
Might the 'if' look something like this taken from product_options.tpl:<br />
```php
variant_images[{$id}][{$po.option_id}] = {$ldelim}{$rdelim};<br />
{if $var.image_pair}<br />
variant_images[{$id}][{$po.option_id}][{$var.variant_id}] = {$ldelim}<br />
'image_path': '{$var.image_pair.icon.image_path|escape:javascript}'<br />
{$rdelim}<br />
{/if}<br />

```<br />
<br />
Any ideas or suggestions would be gratefully received :grin: <br />
<br />
Fived<br />
<br />
[COLOR="Red"]EDIT: [/COLOR]please jump to [URL="http://forum.cs-cart.com/showpost.php?p=63472&postcount=13"]http://forum.cs-cart.com/showpost.php?p=63472&postcount=13[/URL] to see solution!<br />
<br />
.

Hey Fived, I think the cart already works this way, at least it seems to for me. I think all you have to do is setup option combinations for your variants and assign images to them. See page 90 of the user manual for more info on this but basically all you do is first add your options set and checkmark “inventory” (even if you don’t do anything with inventory) and then once you click on Option Combinations, click “rebuild combinations” and a list of all your options will be displayed and you can assign images to each one.



I think the difference between this route and the regular assigning images to variants route is twofold. One, you can setup little thumbnail swatches for your variant images and then assign larger images to each swatch so that when you click on a swatch or select a variant from the drop down your big image is replaced. Two, your variants are assigned images which then display on the wish list and cart. Not to mention a list of other powerful things you can do with your options :slight_smile:



You can see an example of this @ our site: [url]http://www.wildchildclothes.com/dev/newborns/sweatshirt.html[/url]



What I’ve done is create a global color option set with all my color thumbnails that show up under the color drop down for each product. The beauty in this system is that I can add the global set to a product and get all my color thumbnails and then use the option combinations to assign my specific images to each color for each article of clothing. It’s been a bit of work getting all this figured out and working but I think it will be worth it in the end because of what it does for the customer experience.



I hope this has been informative for you and get’s you on the right path for what you want to do. Let me know if I can be of further assistance.


  • Jonah

P.S. - I highly recommend playing around with this a bit to determine a good workflow for your setup and to get to understand how all this works…

Thanks for your reply Jonah, sorry for delay in replying only I didnt get a notification through the forum :rolleyes:



I think maybe I didnt explain myself very well! I had previously gone through all the process that you mentioned in your post and my cart was not reflecting the product variant image, it was showing the product main image. This is why I posted to the forum.



So Jonah when you are in your cart page ie the page just before checkout(this is not product detail page) in the list of products that are included in your shopping cart do your images reflect your variant or your main product image?



I will now also try to see why the forum didnt notify of a reply :?



Thanks Corinna

No problem :slight_smile:



Yes, when I am on the cart page of my site, for any products where I’ve setup option combinations, if I switch to a different option that has an image, it swaps the image right there. You can try it out on our site if you go to the link I posted earlier - it’s going live sometime tomorrow and the link will be valid until then.



Check it out, and then try setting up those option combinations - they work wonders!


  • Jonah

Hi Jonah,

I just wanted to tell you that your site is very nice. I went in to take a look around and test the option colors. You’re right, it does the work the way you say it does which is what I thought I remembered from my site, too. Good luck with your new store…I think it’s a very well laid out site.



Btw…how did you get that notification box to appear in the middle of the screen when the item is added to the cart? I really like that!



Regards,

Stephanie

www.Products4Pets.com - soon to be on CS Cart 2.0.8

[quote][URL=“http://www.wildchildclothes.com/dev/newborns/sweatshirt.html”]http://www.wildchildclothes.com/dev[/URL][/quote]

Very nice site but it’s a pity that the site doesn’t like IE6,7&8 at all.

@joe: Hey take it easy… I’m working on the different browsers right now - I said it’s going live sometime tomorrow :wink:



But I’ll tell you what, there is no way I’m going to work to make IE6 work - instead I’ve installed IE6 Update - I’m done spending hours upon hours to make a site work in a 10 year old browser! That is of course unless a client is willing to pay… But the Wild Child site is my parents business and I’m making the calls here!



@scase: Thanks for the praise! I made a couple edits to the CSS for the notification box to get it positioned in the middle of the screen. It wasn’t too hard and I’d be happy to share if you can’t figure it out.

[quote name=‘jonahcoyote’]@joe: Hey take it easy… I’m working on the different browsers right now - I said it’s going live sometime tomorrow :wink:



But I’ll tell you what, there is no way I’m going to work to make IE6 work - instead I’ve installed IE6 Update - I’m done spending hours upon hours to make a site work in a 10 year old browser! That is of course unless a client is willing to pay… But the Wild Child site is my parents business and I’m making the calls here!



@scase: Thanks for the praise! I made a couple edits to the CSS for the notification box to get it positioned in the middle of the screen. It wasn’t too hard and I’d be happy to share if you can’t figure it out.[/QUOTE]

IE6 is the most evil thing exists in the world.

Again, the website looks really great!

Jonah! I love your website :o



I have definitely followed the setting up of options and variants with images correctly. So I guess it can only be a code issue. Perhaps one that I have played with, that is pivotal. I have checked back to other templates to see the differences and I can’t see anywhere that might be an issue.



Could I possibly ask a really huge favour could you possible copy the code that you have for your cart_items.tpl. I am wondering if something is amiss.



Thank you for your continued support Jonah.



Still not getting email notification of forum responses, so I will try to check back regularly.

Oh and by the way I am with you on IE6, no more development unless clients pays :wink:

Thanks for the praise! Here ya go:


```php {* $Id: cart_items.tpl 7580 2009-06-15 10:58:34Z lexa $ *}



{capture name=“cartbox”}



{if $mode == "checkout"}
{if $cart.coupons|floatval}{/if}
{hook name="checkout:form_data"}
{/hook}
{/if}

{if $cart_products}

{assign var="prods" value=false}
{foreach from=$cart_products item="product" key="key" name="cart_products"}
{hook name="checkout:items_list"}
{if !$cart.products.$key.extra.parent}

{if $prods}


{else}
{assign var="prods" value=true}
{/if}
{if $mode == "cart"}

{/if}

{if $use_ajax == true && $cart.amount != 1}
{assign var="ajax_class" value="cm-ajax"}
{/if}

{$product.product|unescape}{if !$product.exclude_from_calculate} {$lang.remove}{/if}


{$lang.sku}: {$product.product_code}





{if $product.exclude_from_calculate}{/if}

{$lang.qty}:
{if $product.qty_content && $product.is_edp != "Y"}

{foreach from=$product.qty_content item="var"}
{$var}
{/foreach}

{else}

{/if}
{if $product.is_edp == "Y" || $product.exclude_from_calculate}

{/if}
{if $product.is_edp == "Y"}

{/if}
x {include file="common_templates/price.tpl" value=$product.display_price span_id="product_price_`$key`" class="sub-price"}
= {include file="common_templates/price.tpl" value=$product.display_subtotal span_id="product_subtotal_`$key`" class="price"}
{if $product.zero_price_action == "A"}

{/if}


{assign var="name" value="product_options_$key"}
{capture name=$name}
{if $product.product_options}
{include file="views/products/components/product_options.tpl" product_options=$product.product_options product=$product name="cart_products" id=$key location="cart" disable_ids=$disable_ids form_name="checkout_form"}
{/if}

{hook name="checkout:product_info"}
{if $product.exclude_from_calculate}
{$lang.free}
{elseif $product.discount|floatval || $product.taxes}




{if $product.discount|floatval}{/if}
{if $product.taxes}{/if}





{if $product.discount|floatval}{/if}
{if $product.taxes}{/if}





{$lang.price} {$lang.quantity} {$lang.discount} {$lang.tax} {$lang.subtotal}
{include file="common_templates/price.tpl" value=$product.base_price span_id="original_price_`$key`" class="none"} {$product.amount} {include file="common_templates/price.tpl" value=$product.discount span_id="discount_subtotal_`$key`" class="none"} {include file="common_templates/price.tpl" value=$product.tax_summary.total span_id="tax_subtotal_`$key`" class="none"} {include file="common_templates/price.tpl" span_id="product_subtotal_2_`$key`" value=$product.display_subtotal class="none"}

{/if}
{/hook}
{/capture}

{if $smarty.capture.$name|trim}

{$lang.text_click_here}




{$smarty.capture.$name}

{/if}


{/if}
{/hook}
{/foreach}
{/if}

{hook name="checkout:extra_list"}
{/hook}


{/capture}
{if $mode == "cart"}
{assign var="class" value="mainbox-cart-body-flex"}
{else}
{assign var="class" value=""}
{/if}
{include file="common_templates/mainbox_cart.tpl" title=$lang.cart_items content=$smarty.capture.cartbox mainbox_body=$class}
```

Jonah…you are a star…thank you for your help.



I compared the files and there was one tiny, critical element missing from my cart_items.tpl



So for any in the future that may play with the code and the cart product images does not correctly reflect the variant image, the code in red is what is critical!:


```php





{include file=“common_templates/image.tpl” image_width=100 images=$product.main_pair object_type=“product” [COLOR=“Red”]obj_id=$key[/COLOR]}


```

Thank you again,
Fived

[quote name=‘jonahcoyote’]

You can see an example of this @ our site: [URL]http://www.wildchildclothes.com/dev/newborns/sweatshirt.html[/URL]

[/quote]



Any chance of getting to know whether that dropdown is dynamic or static?

Very nice look overall

@Fived: I do what I can :wink: - I’m glad that worked out your problem!



@JesseLee: Thanks, what dropdown are you talking about?


  • Jonah

[quote name=‘jonahcoyote’]

@JesseLee: Thanks, what dropdown are you talking about?

Ahhh yes, that dropdown is dynamic. It’s the Top Menu with the main menu items as our main categories and the dropdowns sub-categories of those main cats. The look though is all done with custom CSS by me.