Skip to content

Instantly share code, notes, and snippets.

@JamieS
Forked from bradjmiller/cart-snippet.liquid
Created March 9, 2012 15:52
Show Gist options
  • Save JamieS/2007201 to your computer and use it in GitHub Desktop.
Save JamieS/2007201 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment