Skip to content

Instantly share code, notes, and snippets.

@odessy
odessy / gist:4e843f6c0af1e2f06ac826dea10c6110
Created August 25, 2026 13:54
Confirm notification with line item properties
{% assign delivery_method_types = delivery_agreements | map: 'delivery_method_type' | uniq %}
{% assign has_split_cart = false %}
{% assign non_none_count = 0 %}
{% for type in delivery_method_types %}
{% unless type == 'none' %}
{% assign non_none_count = non_none_count | plus: 1 %}
{% endunless %}
{% endfor %}
{% if non_none_count > 1 %}
{% assign has_split_cart = true %}
@odessy
odessy / gist:a5784f75e02c82a14e7f417934a8f42e
Last active August 20, 2026 22:27
Story button and quantity selector inline
.shopify-product-form {
display: grid;
grid-template-columns: 120px 1fr;
grid-template-areas:
"variant variant"
"terms terms"
"meta meta"
"quantity submit"
"empty empty";
@odessy
odessy / gist:f56cb28bc065e85ef7a40b44a56b3a22
Created May 6, 2026 01:50
Custom quick view product link
{%- assign button_text = 'products.product.add_to_cart' | t -%}
{%- if card_product.metafields.theme.preorder.value == true -%}
{% comment %} Add a line item property with 'Sale type: Pre-order' and make the button say 'Pre-order'{% endcomment %}
{%- assign button_text = 'products.product.pre_order' | t -%}
{%- endif -%}
{%- unless card_product.selected_or_first_available_variant.available -%}
{%- assign button_text = 'products.product.sold_out' | t -%}
{%- endunless -%}
<a href="{{ card_product.url }}" class="product-clip__btn btn--soft btn--small btn--primary">
@odessy
odessy / gist:37aee170c82aab08d1362798dead43ca
Created March 7, 2026 18:35
Product grid layout change the sizes attribute calculation to prevent blurry image
function getCSSLayoutWidth() {
const value = getComputedStyle(document.documentElement)
.getPropertyValue('--LAYOUT-WIDTH')
.trim();
return value || '100vw';
}
function updateImageSizes(largeValue, smallValue) {
const largeDivisor = largeValue || 1;
const smallDivisor = smallValue || 1;
@odessy
odessy / gist:c2f3dc3233629cb4fba3e4e4f4051b16
Created February 19, 2026 17:47
Pipeline CSS var set product page thumbnail width and height
/* Set product page thumbnail width and height */
.product-single{
--thumb-width: 100px;
--thumb-height: 125px;
}
.media__thumb {
width: var(--thumb-width);
height: var(--thumb-height);
}
.media__thumb img.loading-shimmer {
@odessy
odessy / gist:afc003c3576f2598edf27657da36793d
Created February 19, 2026 15:05
Product structured data without price
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Product",
"@id": "{{ product.url | prepend: shop.url }}#product",
"name": {{ product.title | json }},
"description": {{ product.description | strip_html | json }},
"image": [
{% for image in product.images %}
{{ image | image_url | prepend: "https:" | json }}{% unless forloop.last %},{% endunless %}
@odessy
odessy / gist:3e0eb52b29b65e64a5db3fa160ee3206
Last active April 29, 2026 15:42
Product page show custom badge
{% if settings.badge_custom %}
{% if product.metafields.theme.badge != blank and product.metafields.theme.badge.type == 'single_line_text_field' %}
<div class="badge--custom"><span>{{ product.metafields.theme.badge.value }}</span>
<style>
.badge--custom {
font-family: var(--FONT-STACK-ACCENT);
font-weight: var(--FONT-WEIGHT-ACCENT-BOLD);
text-transform: var(--FONT-ACCENT-TRANSFORM);
letter-spacing: var(--FONT-ACCENT-LETTER-SPACING);
font-size: calc(var(--font-2) * var(--FONT-ADJUST-ACCENT));
@odessy
odessy / gist:e49b2e54460b87c9d6fc1c0dcfdc0e7e
Last active November 13, 2025 16:41
Redirect when product added to cart
/* Javascript - Redirect to cart when product added to cart */
document.addEventListener('theme:cart:popdown', (e) => {
const listener = (e) => {
const location = window.location.href;
if(theme && theme.routes && !location.includes(theme.routes.cart)){
window.location.href = theme.routes.cart;
}
};
document.addEventListener('theme:cart:change', listener);
});
@odessy
odessy / gist:0ed3ee48b5d8b26d9b8f1d7255eaa7c4
Created November 12, 2025 16:38
product page json ld structured data
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Product",
"name": {{ product.title | json }},
"url": {{ request.origin | append: product.url | json }},
{% if seo_media -%}
"image": [
{{ seo_media | image_url: width: 1920 | prepend: "https:" | json }}
],
@odessy
odessy / gist:927c6bc229d9e13c865fc6fe9d868ff8
Created October 23, 2025 20:44
Sticky add to cart with wrapper
{%- if product.available -%}
<div x-data="{visible: false, sectionId: '{{ section.id }}', productId: '{{ product.handle }}', ...handleClick, ...showButton}">
<template x-teleport="body">
<div
@theme:scroll.document="showButton"
x-show.opacity="visible"
class="buy-it-now-wrapper block left-0 bottom-0 fixed z-20 w-full p-r5">
<button
@click="handleClick"
class= "btn btn--primary btn--full uppercase btn--add-to-cart buy-it-now block">{{'products.product.add_to_cart' | t}}</button>