Skip to content

Instantly share code, notes, and snippets.

View joe-dempsey's full-sized avatar

joe dempsey joe-dempsey

View GitHub Profile
@joe-dempsey
joe-dempsey / collection filter.liquid
Last active July 8, 2023 03:10
collection filter updated
<div class="desktop-2 tablet-6 mobile-3" id="aside">
<div id="sidebar">
<div class="desc-accordion">
@joe-dempsey
joe-dempsey / how to show related products shopify
Created June 19, 2018 09:43
show related products shopify
@joe-dempsey
joe-dempsey / brands_slider.liquid
Created May 31, 2017 13:28
Logo slider shopify section - uses slick slider with liquified slick-theme.css
{% if section.settings.show_brands_slider %}
<div data-section-id="{{ section.id }}" id="slick-{{ section.id }}" class="slickslider brands-responsive{% if section.settings.slideshow_width == 'contained' %} container mb30 {% else %} mt-30 {% endif %}" data-section-type="brands-slideshow-section">
{% for block in section.blocks %}
<div class="center brand-slide">
{% if block.settings.brand_link %}<a href="{{ block.settings.brand_link }}">{% endif %}
<img src="{{ block.settings.slideshow_image | img_url: '133x' }}" alt="{{ block.settings.slideshow_image.alt }}">
{% if block.settings.brand_link %}</a>{% endif %}
</div>
{% endfor %}
</div>
<!-- here we're going to add a % discount which is a calculation of the sale and product price -->
<!-- quite simple - capture the value and then display it -->
<!-- see newer version at end -->
<!-- capture the % discount -->
{% capture discount %}
{{ product.compare_at_price_max | minus:product.price | times:100 | divided_by:product.compare_at_price_max }}% <!-- percentage maths -->
{% endcapture %}
@joe-dempsey
joe-dempsey / odd-even-in-liquid.liquid
Created May 10, 2017 14:38
using modulo in liquid to case odd even in a loop
{% comment %}
Here we loop through a blog and use modulo to case odd/even.
Dead simple.
{% endcomment %}
{% for article in blog.articles %}
{% assign mod = forloop.index | modulo: 2 %}
@joe-dempsey
joe-dempsey / gist:d4326d7a08790129bcc07a7c08667662
Created January 16, 2017 17:01
dynamic href lang tags liquid shopify
{% comment %}
Here we have 2 stores:
www.urbanexcess.com
www.usd.urbanexcess.com
set dynamic href lang tags for each to avoid dup. content issues
{% endcomment %}
@joe-dempsey
joe-dempsey / shopify colors for a product.liquid
Last active January 31, 2023 16:12
Shopify colors for a product.
{% capture option_titles %}Color,color,Colour,colour{% endcapture %}
<div class="color_swatches_collection">
{% assign option_titles = option_titles | split:',' %}
{% for option in product.options %}
{% if option_titles contains option %}
{% capture option_index %}option{{ forloop.index }}{% endcapture %}
{% assign option_values = product.variants | map: option_index | uniq %}
{% if option_values.size != 0 %}
{% for opt in option_values %}
<div style="background-color:{{ opt | downcase }};" class="option_circles"></div>
@joe-dempsey
joe-dempsey / gist:dd361351452a0114b3fca2dca28e8763
Last active September 28, 2022 16:12
Shopify loops (useful for debugging)
looping variants:
{% for variant in product.variants %}
<p>{{ variant.title }}</p>
{% endfor %}
... more coming soon...
@joe-dempsey
joe-dempsey / pre-order-shopify.liquid
Created June 23, 2017 08:56
Shopify check if a product is pre-order (available for sale but not in stock)
{% assign product_qty = 0 %}
{% for variant in product.variants %}
{% if variant.inventory_quantity > 0 %}
{% assign product_qty = product_qty | plus: variant.inventory_quantity %}
{% endif %}
{% endfor %}
{% assign pre_order = false %}
{% comment %}the product is available for sale but has 0 stock - e.g. so is pre-order{% endcomment %}
@joe-dempsey
joe-dempsey / Shopify add color swatches to collection pages.txt
Created June 4, 2018 12:29
Shopify add color swatches/dots to collection pages.
{% capture option_titles %}Color,color,Colour,colour{% endcapture %}
{% assign option_titles = option_titles | split:',' %}
{% for option in product.options %}
{% if option_titles contains option %}
{% capture option_index %}option{{ forloop.index }}{% endcapture %}
{% assign option_values = product.variants | map: option_index | uniq %}
{% if option_values.size != 1 %}
{% for opt in option_values %}