Skip to content

Instantly share code, notes, and snippets.

View justincron's full-sized avatar

Justin Cron justincron

View GitHub Profile
@rickydazla
rickydazla / product-grid-item.liquid
Last active December 17, 2017 02:16
Shopify Collection thumbnail:hover image swap
<a href="{{ product.url | within: collection }}">
{% assign imgSize = 'medium' %}
{% assign canSwap = false %}
{% if product.images.size > 1 %}
{% assign canSwap = true %}
{% assign swapImg = product.images[1] %}
{% assign swapImgSrc = swapImg.src | product_img_url: imgSize %}
{% assign swapImgAlt = swapImg.alt | escape %}
{% endif %}
<img{% if canSwap %} class="has-swap"{% endif %} src="{{ product.featured_image.src | product_img_url: imgSize }}" alt="{{ product.featured_image.alt | escape }}">
@ivandurst
ivandurst / product-grid-item.liquid
Created July 1, 2016 22:44
Shopify add a tag to a product that's on sale
{% comment %}
Add a tag to a product that's on sale. Add this in your template for displaying a product in a grid, for me it's called product-grid-item.liquid
{% endcomment %}
{% assign on_sale = false %}
{% if product.compare_at_price > product.price %}
{% assign on_sale = true %}
@anilmeena
anilmeena / display-variants-dropdown-shopify-collection.liquid
Created April 8, 2017 11:00
Shopify Display Multiple Variant Drop-down on Collection Page
<form action="/cart/add" method="post" style="text-align:center;">
<select name="id">
{% for variant in product.variants %}
{% if variant.available %}
<option value="{{ variant.id }}">{{ variant.title }} - {{ variant.price | money }}</option>
{% else %}
<option disabled="disabled">{{ variant.title }} - Sold Out</option>
{% endif %}
{% endfor %}
</select>