Skip to content

Instantly share code, notes, and snippets.

View liamgriffin's full-sized avatar

Liam Griffin liamgriffin

  • Shopify
  • Galway, Ireland
View GitHub Profile
@liamgriffin
liamgriffin / price.liquid
Created July 11, 2024 09:17
Modification of Dawns price.liquid snippet to display the price on collection pages as the lowest available variants price
{% comment %}
Renders a list of product's price (regular, sale)
Accepts:
- product: {Object} Product Liquid object (optional)
- use_variant: {Boolean} Renders selected or first variant price instead of overall product pricing (optional)
- show_badges: {Boolean} Renders 'Sale' and 'Sold Out' tags if the product matches the condition (optional)
- price_class: {String} Adds a price class to the price element (optional)
- show_compare_at_price: {Boolean} Renders the compare at price if the product matches the condition (optional)
@liamgriffin
liamgriffin / swatch.liquid
Created January 30, 2024 08:44
Color Swatches Visual Component
<span
{% if swatch_value %}
class="swatch{% if shape == 'square' %} swatch--square{% endif %}"
style="--swatch--background: {{ swatch_value }}"
{% else %}
class="swatch swatch--unavailable{% if shape == 'square' %} swatch--square{% endif %}"
{% endif %}
></span>
@liamgriffin
liamgriffin / swatch-input-label.liquid
Created January 30, 2024 08:43
Color Swatches Input Label
<label
for="{{ id }}"
title="{{ value }}"
class="swatch-input__label{% if shape == 'square' %} swatch-input__label--square{% endif %}"
>
{% render 'swatch', swatch: value.swatch, shape: shape %}
<span class="visually-hidden">{{ value }}</span>
{{ help_text }}
</label>
@liamgriffin
liamgriffin / product-variant-options.liquid
Created January 30, 2024 08:41
Color Swatches Picker Logic
if value.swatch.image
assign image_url = value.swatch.image | image_url: width: 50
assign swatch_value = 'url(' | append: image_url | append: ')'
elsif value.swatch.color
assign swatch_value = 'rgb(' | append: value.swatch.color.rgb | append: ')'
else
assign swatch_value = nil
endif
@liamgriffin
liamgriffin / variant-picker-and-options.liquid
Created January 30, 2024 08:38
Color Swatches - Variant Picker and Options
{%- for option in product.options_with_values -%}
{%- liquid
assign swatch_count = option.values | map: 'swatch' | compact | size
assign picker_type = block.settings.picker_type
if swatch_count > 0 and block.settings.swatch_shape != 'none'
if block.settings.picker_type == 'dropdown'
assign picker_type = 'swatch_dropdown'
else
assign picker_type = 'swatch'
@liamgriffin
liamgriffin / videos.liquid
Created December 21, 2022 08:45
Shopify theme section that displays videos that are both hosted externally and on the Shopify admin
<div class='video-section'>
<h2>{{ section.settings.heading }}</h2>
{% for block in section.blocks %}
{% case block.type %}
{% when 'video-stored' %}
<div class="stored-video" {{ block.shopify_attributes }}>
{{ block.settings.video | media_tag }}
</div>
{% when 'external-video' %}
<div class ="external-video"{{ block.shopify_attributes }}>
@liamgriffin
liamgriffin / video-by-upload.liquid
Created December 21, 2022 08:43
Shopify theme section that displays videos which are uploaded via the Shopify admin
<div class="video-section">
<h2>{{ section.settings.heading }}</h2>
{{ section.settings.video | video_tag }}
</div>
{% schema %}
{
"name": "Video",
"settings": [
{
@liamgriffin
liamgriffin / external-video.liquid
Created December 21, 2022 08:42
Shopify theme section that displays an externally hosted video
<div class="video-section">
<h2>{{ section.settings.heading }}</h2>
{%- if section.settings.video_url.type == 'youtube' -%}
<iframe src="https://www.youtube.com/embed/{{ section.settings.video_url.id }}" class="youtube" allow="autoplay; encrypted-media" title="{{ section.settings.description | escape }}"></iframe>
{%- else -%}
<iframe src="https://player.vimeo.com/video/{{ section.settings.video_url.id }}" class="vimeo" allow="autoplay; encrypted-media" title="{{ section.settings.description | escape }}"></iframe>
{%- endif -%}
</div>
{% schema %}
@liamgriffin
liamgriffin / acscsac.liquid
Created September 7, 2022 14:02
test gist
dlkcnda
@liamgriffin
liamgriffin / text-block.json
Created March 2, 2022 16:16
How to work with Metafields
"text": {
"type": "text",
"settings": {
"text": "{{ product.metafields.my_fields.country.value }}",
"text_style": "uppercase"
}
},