Skip to content

Instantly share code, notes, and snippets.

View loughlincodes's full-sized avatar

Loughlin McSweeney loughlincodes

View GitHub Profile
@loughlincodes
loughlincodes / tabs | tabbed-description.liquid
Last active April 11, 2022 17:53 — forked from tairli/tabbed-description.liquid
Tabs / Tabbed Product description snippet for Shopify
{% comment %}
if combine_pretext is false, the text before the first <h6> will be shown above all tabs, otherwise added to the first tab
{% endcomment %}
{% assign combine_pretext = false %}
{% assign description = tabbed-description | default: product.description %}
{% if description contains "<h6>" %}
{% assign tab_heads = '' %}
{% assign tab_texts = '' %}
{% assign pretext = '' %}
@loughlincodes
loughlincodes / gist:7496ff59fa3788a979c4c27c463041d2
Created May 22, 2019 14:50
Hide <br/> tags and replace with a space
br{
content:' ';
}
br:after{
content:' ';
}
// To get list of themes
theme get --list -p=[your-api-password] -s=[your-store.myshopify.com]
theme get -l -p=[your-api-password] -s=[your-store.myshopify.com]
// To download the theme
theme get --password=[your-api-password] --store=[your-store.myshopify.com] --themeid=[your-theme-id]
theme get -p=[your-api-password] -s=[your-store.myshopify.com] -t=[your-theme-id]
// To watch for changes on host
theme watch
@loughlincodes
loughlincodes / gist:d774bdd9ac121a1e2d554ec855c0632c
Last active March 25, 2021 19:33
Section schema for blocks in Pages
<div class="some-div">
{% for block in section.blocks %}
{% case block.type %}
{% when 'image' %}
image
{% when 'headline' %}
headline
@loughlincodes
loughlincodes / gist:55349fda58b89a61e6af0370f6c56603
Created July 24, 2019 11:15
Get product image via Shopify JS API
{% comment %}
This is based on getting a product from a block entry in the customiser using the "product" type.
all_products[] only allows 20 items so better to get the product info per product asynchronously
{% endcomment %}
<div class="stub" data-handle="{{ block.settings.image }}">
<a href="/products/{{ block.settings.image }}" target="_blank">
@loughlincodes
loughlincodes / gist:2238988f2ce50eeee8fe9a21abc40556
Created August 8, 2019 13:31
How to pass vars to snippets in Shopify
Method 1: Declare variables right above the snippet:
{% assign snippet_variable = ‘this is it’ %}
{% assign snippet_variable_two = ‘this is also it’ %}
{% include ‘snippet’ %}
Method 2: Include variable into include command:
{% include ‘snippet’, snippet_variable: ‘this is it’, snippet_variable_two: ‘this is also it’ %}
There was a filthy rumour being spread at Unite 2019 that snippets were scheduled to be removed.
@loughlincodes
loughlincodes / metafields.liquid
Created August 29, 2019 12:07
Display all Shopify metafields in a particular namespace
{% for field in product.metafields.namespace %}
<li>{{ field | first }}: {{ field | last }}</li>
{% endfor %}
@loughlincodes
loughlincodes / gist:0f98ace464acd1f47cd887b5c7c31158
Created October 8, 2019 12:11
Shopify Loox Reviews - get total reviews
<div class="reviews">
{% assign looxstats = shop.metafields.loox["global_stats"] | split: "," %}
{% assign looxstar = looxstats[0] | round %}
{% assign looxcount = looxstats[1] | times:100 | money_without_currency | remove: '.00' %}
<a href="pages/happy-customers">Reviews (<span class="looxstars">{% for i in (1..looxstar) %}&#9733;{% endfor %}</span> {{ looxcount }})</a>
</div> <!-- end review -->
@loughlincodes
loughlincodes / announcement-bar.liquid
Last active October 14, 2019 12:40
Announcement Bar Section (with Blocks - Max 3)
<div class="announcement-bar">
<p>
{% for block in section.blocks %}
<span>{{ block.settings.text }}</span>{% if forloop.last != true %}<span class="middot">&middot;</span>{% endif %}
{% endfor %}
</p>
@loughlincodes
loughlincodes / html-head-boilerplate.html
Created October 20, 2019 10:09 — forked from nunosans/html-head-boilerplate.html
HTML Head Boilerplate & Reference
<!doctype html>
<html>
<head>
<!-- Priority tags. These must come first. -->
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge; chrome=1"> <!-- Render Chrome if available or using latest version of Internet Explorer (Recommended). -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<!-- Document Title -->
<title>Page Title</title>
<!-- Allows control over where resources are loaded from. Place as early in the document as possible, only applies to content below this tag. -->