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 / redirects-shopify.html
Created April 7, 2017 14:23
shopify straight to checkout/stay on page.
{% assign send_to_cart = true %}
{% assign send_to_checkout = false %}
{% for tag in product.tags %}
{% if tag contains "no__redirect" %}
{% assign send_to_cart = false %}
{% endif %}
{% if tag contains "send_to_checkout" %}
{% assign send_to_checkout = true %}
{% endif %}
@joe-dempsey
joe-dempsey / shopify_sidebar_filters.liquid
Created April 11, 2017 10:24
Shopify sidebar filters
{% comment %} let's buid a sidebar collection navi menu in Shopify {% endcomment %}
{% comment %} note - we use this - https://semantic-ui.com/introduction/getting-started.html {% endcomment %}
{% comment %} initiate plugin via footer and load assets in header {% endcomment %}
{{ 'semantic.min.css' | asset_url | script_tag }}
{{ 'jquery.min.js' | asset_url | script_tag }}
{{ 'jquery.min.js' | asset_url | script_tag }}
{% comment %} links should be collections and submenus must exist {% endcomment %}
@joe-dempsey
joe-dempsey / count_in_liquid.liquid
Created April 21, 2017 12:27
How to count in Liquid for Shopify
{% assign counter = 0 %}
{% for something in somethings %}
{% assign counter = counter | plus: 1 %}
{% endfor %}
{{ counter }}
@joe-dempsey
joe-dempsey / image cycle shopify
Created April 21, 2017 14:10
cycle images Shopify
{% capture current %}{% cycle 1, 2, 3, 4, 5, 6 %}{% endcapture %}
{{ 'collection-' | append: current | placeholder_svg_tag: 'placeholder-svg' }}
@joe-dempsey
joe-dempsey / device target
Created April 21, 2017 16:00
target devices with js
// useful example
if ($(window).width() < 1024) {
$( ".header__item-language" ).insertBefore( "#lang_inject_mobile" );
}
$( window ).resize(function() {
// position the lang picker when resizing
if ($(window).width() < 1024) {
@joe-dempsey
joe-dempsey / tag filter shopify
Created April 22, 2017 09:40
Tag filter via theme options Shopify
{% comment %}Tag filters{% endcomment %}
{% comment %}https://help.shopify.com/themes/customization/collections/filtering-a-collection-with-multiple-tag-drop-down{% endcomment %}
{% comment %}Modified so they can be captured in theme options.{% endcomment %}
{% comment %}first grab and assign some stuff{% endcomment %}
{% capture tags_list %}{{ section.settings.tags_list | prepend: "'," | append: "'" }}{% endcapture %}
{% if collection.url.size == 0 %}
{% assign collection_url = '/collections/all' %}
{% else %}
@joe-dempsey
joe-dempsey / Shopify autofil checkout fields
Created May 8, 2017 11:28
Shopify autofil checkout fields
Turns out you can construct the URL like this to autofill the fields:
checkoutUrl = variant.checkoutUrl()
checkoutUrl += "&checkout[email]=#{email}" +
"&checkout[billing_address][first_name]=#{firstName}" +
"&checkout[billing_address][last_name]=#{lastName}" +
"&checkout[billing_address][address1]=#{address}" +
"&checkout[billing_address][city]=#{city}" +
"&checkout[billing_address][country]=#{country}" +
"&checkout[billing_address][zip]=#{postalCode}"
@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 / article next previous.liquid
Created May 11, 2017 09:32
Shopify Blog preview next article
{% if blog.next_article %}
<b>{{ 'blogs.article.newer_post' | t | link_to: blog.next_article }}</b><span> | </span>
{% endif %}
<b>{{ 'All Articles' | link_to: blog.url }}</b>
@joe-dempsey
joe-dempsey / landing-code.liquid
Created May 18, 2017 13:10
landing page for mikkel
{% section 'slideshow-landing' %}
{% section 'slideshow-landing-mobile' %}
{% section 'featured-content-landing' %}
{% section 'mobile_extras' %}
{% section 'tiled-images-landing' %}
{% section 'featured-collection-landing' %}
{% section 'tiled-images-landing-2' %}
{% section 'featured-collection-landing-2' %}
{% section 'tiled-images-landing-3' %}