Skip to content

Instantly share code, notes, and snippets.

@bradjmiller
Created March 1, 2012 01:45
Show Gist options
  • Save bradjmiller/1946527 to your computer and use it in GitHub Desktop.
Save bradjmiller/1946527 to your computer and use it in GitHub Desktop.
Display associated image of product variant in cart.liquid
<a href="{{ item.product.url }}" title="{{ item.product.title | escape }}">
{% assign found = false %}
{% for img in item.product.images %}
{% if found == false and item.variant.title contains img.alt %}
<img src="{{ img | product_img_url: 'thumb' }}" alt="{{ item.alt | escape }}" />
{% assign found = true %}
{% endif %}
{% endfor %}
{% if found == false %}
<img src="{{ item.product.featured_image | product_img_url: 'thumb' }}" alt="{{ item.product.featured_image.alt | escape }}" />
{% endif %}
</a>
@JoshMT
Copy link

JoshMT commented Aug 30, 2012

Hey Brad,
New to all this coding, but have a good understanding. Are we just adding this code to the cart.liquid? or are we removing some code and replacing it with this? Your help would be amazing. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment