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 / toggle images on hover shopify.liquid
Last active October 14, 2018 16:12
toggle images on hover on shopify
{% comment %}
for ref -- toggle images using data source,
{% endcomment %}
<div class="product-item__image-wrapper">
<img
src="{{ product.featured_image | img_url: image_size }}"
@joe-dempsey
joe-dempsey / related products by tags.liquid
Created July 12, 2017 13:39
Related products by tags shopify
@joe-dempsey
joe-dempsey / product-color-shopify.liquid
Created June 30, 2017 13:24
Product colors shopify
{% comment %}
<!-- this loop is not so easy -->
<!-- need to accomodate for US/UK spellings -->
{% for option in product.options %}
{% if option contains 'Color' or option contains 'color' or option contains 'Colors' or option contains 'colors' or option contains 'Colour' or option contains 'colour' or option contains 'Colours' or option contains 'colours' %}
<p class="product-color">{{ product.variants.first.options[forloop.index0] }}</p>
{% endif %}
{% endfor %}
{% endcomment %}
@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 / template name.liquid
Created June 15, 2017 12:48
get a template name and use for summat shopify template name in liquid
{{ template | replace: '.', '_' | handelize }}
@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>
@joe-dempsey
joe-dempsey / slick-theme.css.liquid
Created May 31, 2017 10:24
slick theme shopified - use this .css.liquid file and upload the fonts/assets to the assets section of the theme
@charset 'UTF-8';
/* Slider */
.slick-loading .slick-list
{
background: #fff url('{{ 'ajax-loader.gif' | asset_url }}') center center no-repeat;
}
@joe-dempsey
joe-dempsey / shopify-loop.liquid
Created May 30, 2017 10:18
example of shopify i loop to build old skool sectionless stuff - keeping for basic maintenance needs/examples.
<section class="homepage-section animate wow fadeIn">
{% if settings.display-wide %}
{% else %}
<div class="row">
<div class="desktop-12 tablet-6 mobile-3">
{% endif %}
{% if settings.homepage-display == 'video' %}
<div class="videoWrapper">
{{ settings.video-embed }}
@joe-dempsey
joe-dempsey / de-duplication-shopify-pixels.liquid
Last active August 25, 2017 15:51
de-duplication and Shopify checkout when not using Shopify Plus - set source ref for Shopify and show conditional checkeckout pixels
{% comment %}
Here we have some de-duplication code for when the client is not on Shopify Plus and needs to de-duplicate tracking pixels in the checkout.
If using Shopify Plus a cookie based JS solution may be better.
This is a bit of a hack (but works).
{% endcomment %}
{% comment %}
to go in theme file
{% endcomment %}
{% layout none %}<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/css" href="rss.css" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<atom:link href="{{shop.url}}/pages/feed" rel="self" type="application/rss+xml" />
<products>{% paginate collections.all.products by 1000 %}{% for product in collections.all.products %}
<product>
<ProductCategory>{{ product.type }}</ProductCategory>
<ProductName>{{ product.title | strip_html | strip_newlines | escape | replace: '&', 'and' }}</ProductName>
<ProductSKU>{{ product.sku }}</ProductSKU>
<ProductPrice>{{ product.price | money }}</ProductPrice>