Skip to content

Instantly share code, notes, and snippets.

@carolineschnapp
carolineschnapp / available-colors.liquid
Created October 4, 2016 15:15
Snippet that says 'also available in colors x and y' on the collection page when a product is available in more than 1 color. To include in product-loop.liquid, or product-grid-item.liquid.
{% comment %}
Do we have a Color option?
If so, is it the first, second or third option of that product?
We will need to access values so we need that color index.
{% endcomment %}
{% assign has_color = false %}
{% assign color_option_index = 0 %}
{% for option in product.options %}
{% assign downcased_option = option | downcase %}
@alexeygrigorev
alexeygrigorev / vimeo-download.py
Created September 17, 2016 09:09
Downloading segmented video from vimeo
import requests
import base64
from tqdm import tqdm
master_json_url = 'https://178skyfiregce-a.akamaihd.net/exp=1474107106~acl=%2F142089577%2F%2A~hmac=0d9becc441fc5385462d53bf59cf019c0184690862f49b414e9a2f1c5bafbe0d/142089577/video/426274424,426274425,426274423,426274422/master.json?base64_init=1'
base_url = master_json_url[:master_json_url.rfind('/', 0, -26) + 1]
resp = requests.get(master_json_url)
content = resp.json()
@romanzaycev
romanzaycev / pagination.jade
Last active May 14, 2020 07:38
Jade (Pug) Bootstrap pagination mixin (Digg-like pagination)
mixin pagination(adjacents, numPages, display, currentPage, base)
- adjacents = (adjacents || 1) * 1;
- numPages = (numPages || 10) * 1;
- currentPage = (currentPage || 1) * 1;
- base = base || '#';
- display = (display || 7) * 1;
ul.pagination
if numPages < display + adjacents * 2
- var p = 1;
@zakhardage
zakhardage / automatically apply price-based discount in Shopify
Created June 17, 2016 21:00
automatically apply price-based discount in Shopify
{% if cart.total_price > settings.cart-discount-threshold %}{% assign threshold = true %}{% endif %}
<form action="/cart{% if threshold %}/?discount=[discountcode]{% endif %}" method="post">
@carolineschnapp
carolineschnapp / Have search box open by default.md
Created May 9, 2016 23:34
Have search box open by default in #Venture

What you have

Alt text

What you want

Alt text

How to get it

@carolineschnapp
carolineschnapp / multiple images for a variant.md
Created March 31, 2016 01:23
"Grouped variant images". Solution good for all themes, no change to markup required.

What to do

  1. Use the alt text to associate the additional images - besides the variant image - to the option value. Example: say you have 3 images that show the Blue variants, then a) associate the first image as variant image to all Blue variants, and b) set the alt text of the 2 additional images to 'Blue'.
  2. Copy+paste the code found in the product.liquid snippet below at the bottom of your product.liquid template.

How that works, essentially

Only the images associated to the currently selected variant are shown. Other images are hidden.

What to expect, the specifics

@carolineschnapp
carolineschnapp / bottom-align slide text and button.md
Created March 26, 2016 15:40
Bottom-align slides' text and button in #Brooklyn theme

What you have

Alt text

What you want

Alt text

How to get it

@zakhardage
zakhardage / Shopify add-ons (e.g. engraving)
Created March 10, 2016 22:23
Shopify add-ons (e.g. engraving)
{% comment %}
Create product for engraving and add to collection with handle "utility"
Add "add-to-cart" class to product form
Add "quantity" class to quantity field
Create a test for engraving product -- I like adding a product tag
{% for tag in product.tags %}
{% assign t = tag | downcase %}
{% if t contains 'engrave' %}{% assign engrave = true %}{% endif %}
{% endfor %}
@martinbean
martinbean / pre-commit
Last active December 19, 2023 22:14
Pre-commit hook to detect if any .php files contain dd()
#!/usr/bin/php
<?php
$files = shell_exec('git diff-index --name-only --cached --diff-filter=ACMR HEAD | grep "\.php$"');
$files = explode("\n", trim($files));
$exitCode = 0;
foreach ($files as $file) {
if (empty($file)) {
@stephenway
stephenway / README.md
Last active June 22, 2024 16:04
BEMIT Cheatsheet