Skip to content

Instantly share code, notes, and snippets.

@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>
@odessy
odessy / product-metaobject-swatches.liquid
Created October 23, 2025 18:21
Shopify metaobject swatches on product page
let ColorMatch = class ColorMatch {
init() {
...
const newColors = document.querySelector('[data-swatches-json]');
if (newColors && newColors.innerHTML !== '') {
const colors = JSON.parse(newColors.innerHTML);
return Promise.resolve(this.matchColors(colors, this.settings.color));
}
@odessy
odessy / gist:565925e2e4b613cbf3e074028d063638
Created October 6, 2025 15:25
Apple touch icon liquid code
<link rel="apple-touch-icon" sizes="180x180" href="{{ settings.favicon | img_url: '180x180' }}" />
@odessy
odessy / gist:86de239e881e3499a50f8ecedfaab040
Created September 18, 2025 15:17
Cart taxes included
{%- if cart.taxes_included -%}
<p class="taxes-included-message" style="padding-bottom: 10px;">
{{ 'cart.general.shipping_at_checkout' | t }}
</p>
{%- endif -%}
@odessy
odessy / gist:a44b9b9de4984c61f2b3cec9a94eed9a
Last active September 11, 2025 15:39
Shopify metaobject swatches on product page
<fieldset class="radio__fieldset" style="margin-bottom: 12px;">
<legend class="radio__legend" aria-label="{{ 'home_page.onboarding.color' | t }}">
<span class="radio__legend__label">{{ 'home_page.onboarding.color' | t }}</span>
</legend>
{% for color_item in product.metafields.shopify.color-pattern.value %}
{% if color_item %}
<radio-swatch class="swatch__button{% if settings.swatches_squares %} swatch__button--square{% endif %}">
<label {% if color_item.color != null %} data-swatch style="--swatch: {{ color_item.color }}"{% endif %}>
{% if color_item.image %}
{% render 'image', img_object: color_item.image.value, width: 34, wh_ratio: 1 %}
@odessy
odessy / gitbook_csv_export.py
Created August 8, 2025 18:23
Export document from gitbook web pages
import requests
from bs4 import BeautifulSoup, Tag
import csv
import re
from urllib.parse import urljoin
from typing import List, Dict, Optional
# Configuration
BASE_URL = "https://pipeline.groupthought.com/"
HEADERS = {
/* CSS - change Add to Cart button color */
.product__form--buybutton .product__submit__add {
background-color: var(--primary);
border: 1px solid var(--primary);
color: var(--primary-opposite);
}
.product__form--buybutton .product__submit__add:hover,
.product__form--buybutton .product__submit__add:focus {
background-color: var(--primary-hover);
border: 1px solid var(--primary-hover);
@odessy
odessy / gist:1478dd7bc95532d2ec5072dc44214d1e
Created July 22, 2025 16:58
Hide section if image settings is blank
data-section-id="{{ section.id }}"