Renders every metafield in a chosen namespace as a labelled key and value list.
{% comment %}
Display product metafields from a single namespace.
Paste into a product template or product section.
Set the namespace below to match the one you created in the Shopify admin
(Settings > Custom data > Products).
{% endcomment %}
{%- assign field_group = product.metafields.details -%}
{%- if field_group != blank -%}
<dl class="st-metafields">
{%- for entry in field_group -%}
{%- assign field_key = entry | first -%}
{%- assign field_value = entry | last -%}
{%- if field_value != blank -%}
<div class="st-metafields__row">
<dt class="st-metafields__label">{{ field_key | replace: '_', ' ' | capitalize }}</dt>
<dd class="st-metafields__value">{{ field_value }}</dd>
</div>
{%- endif -%}
{%- endfor -%}
</dl>
{%- endif -%}
Outputs the SKU of the selected or first available variant when one is set.
{% comment %}
Show the product SKU.
Paste into a product template or section, near the title or price.
Reads the selected variant so it can be refreshed by the theme's variant JS.
{% endcomment %}
{%- assign shown_variant = product.selected_or_first_available_variant -%}
{%- if shown_variant.sku != blank -%}
<p class="st-sku">
<span class="st-sku__label">SKU:</span>
<span class="st-sku__value" data-variant-sku>{{ shown_variant.sku }}</span>
</p>
{%- endif -%}
Renders a buy form for products that have one variant, with a sold-out fallback.
{% comment %}
Single variant product form.
Paste into a product template or section for items that have only one variant.
Hides the variant picker and disables the button when the item is sold out.
{% endcomment %}
{%- assign only_variant = product.selected_or_first_available_variant -%}
{% form 'product', product, class: 'st-buy-form' %}
<input type="hidden" name="id" value="{{ only_variant.id }}">
<p class="st-buy-form__price">{{ only_variant.price | money }}</p>
{%- if only_variant.available -%}
<button type="submit" name="add" class="st-buy-form__submit">
Add to cart
</button>
{{ form | payment_button }}
{%- else -%}
<button type="submit" name="add" class="st-buy-form__submit" disabled>
Sold out
</button>
{%- endif -%}
{% endform %}
An honest urgency line that appears only when the selected variant is nearly out.
{% comment %}
Low-stock note — product template; shows only when the variant tracks
inventory and five or fewer remain.
{% endcomment %}
{% assign st_variant = product.selected_or_first_available_variant %}
{% if st_variant.inventory_management == 'shopify'
and st_variant.inventory_quantity > 0
and st_variant.inventory_quantity <= 5 %}
<p class="st-low-stock">Only {{ st_variant.inventory_quantity }} left in stock.</p>
{% endif %}
Lists every store vendor as a link to that vendor's filtered collection page.
{% comment %}
Vendor link list.
Paste into a section, page template, or sidebar.
Loops over every unique vendor in the store and links each to its
vendor-filtered collection page.
{% endcomment %}
{%- if shop.vendors.size > 0 -%}
<nav class="st-vendors" aria-label="Shop by brand">
<ul class="st-vendors__list">
{%- for vendor in shop.vendors -%}
<li class="st-vendors__item">
{{ vendor | link_to_vendor }}
</li>
{%- endfor -%}
</ul>
</nav>
{%- endif -%}
Adds a special-instructions textarea to the cart that saves an order note on checkout.
{% comment %}
Cart order note. Place inside the cart form block (form 'cart')
in your cart template or section. The name="note" attribute is required.
{% endcomment %}
<div class="st-cart-note">
<label class="st-cart-note__label" for="st-cart-note">
Order notes
<span class="st-cart-note__hint">Add special instructions for your order</span>
</label>
<textarea
class="st-cart-note__field"
id="st-cart-note"
name="note"
rows="4"
placeholder="e.g. leave at the front desk"
>{{ cart.note }}</textarea>
</div>
A gift-wrapping option stored as a cart attribute, visible on the order.
{% comment %}
Gift-wrap option — place inside your cart form. The choice arrives on
the order as a cart attribute your staff can see.
{% endcomment %}
<label class="st-giftwrap">
<input type="checkbox" name="attributes[Gift wrap]" value="Yes"
{% if cart.attributes['Gift wrap'] == 'Yes' %}checked{% endif %}>
Add gift wrapping
</label>
Shows a sidebar of links for every tag in a blog, with the active tag highlighted.
{% comment %}
Blog tag list. Place in a blog template/section where the blog
object is available (e.g. a sidebar in sections/main-blog.liquid).
{% endcomment %}
{% if blog.all_tags.size > 0 %}
<aside class="st-blog-tags" aria-label="Filter by tag">
<h2 class="st-blog-tags__title">Topics</h2>
<ul class="st-blog-tags__list">
<li class="st-blog-tags__item">
{% if current_tags == empty %}
<span class="st-blog-tags__link st-blog-tags__link--active" aria-current="true">All</span>
{% else %}
<a class="st-blog-tags__link" href="{{ blog.url }}">All</a>
{% endif %}
</li>
{% for tag in blog.all_tags %}
<li class="st-blog-tags__item">
{% if current_tags contains tag %}
<span class="st-blog-tags__link st-blog-tags__link--active" aria-current="true">{{ tag }}</span>
{% else %}
<a class="st-blog-tags__link" href="{{ blog.url }}/tagged/{{ tag | handleize }}">{{ tag }}</a>
{% endif %}
</li>
{% endfor %}
</ul>
</aside>
{% endif %}
Adds a keyboard-only link that jumps past navigation straight to the main content.
{% comment %}
Skip to content link.
Paste as the very first element inside <body> in theme.liquid.
Give your main content wrapper id="st-main-content" so the link can target it.
The link stays hidden until it receives keyboard focus.
{% endcomment %}
<a class="st-skip-link" href="#st-main-content">Skip to content</a>
<style>
.st-skip-link {
position: absolute;
left: -9999px;
top: 0;
z-index: 1000;
padding: 0.75rem 1rem;
background: #ffffff;
color: #111111;
text-decoration: none;
}
.st-skip-link:focus {
left: 0;
}
</style>
A theme-agnostic 404 body with a message, a search form, and a link back to the homepage.
{% comment %}
404 (page not found) content. Paste into templates/404.liquid,
or a section rendered by the 404 JSON template.
{% endcomment %}
<div class="st-404">
<h1 class="st-404__title">Page not found</h1>
<p class="st-404__text">
The page you were looking for doesn't exist. It may have been moved or removed.
</p>
<form action="{{ routes.search_url }}" method="get" role="search" class="st-404__search">
<label for="st-404-search" class="st-404__label">Search the store</label>
<input type="search"
id="st-404-search"
name="q"
value="{{ search.terms | escape }}"
placeholder="Search products..."
class="st-404__input">
<button type="submit" class="st-404__button">Search</button>
</form>
<p class="st-404__links">
<a href="{{ routes.root_url }}" class="st-404__home">Return to the homepage</a>
</p>
</div>
Some snippets re-implement patterns popularised by Shopify's public Liquid examples,
rewritten from scratch for this library; the rest are our own. Test in a duplicate theme
before shipping to a live store.