Skip to content

Instantly share code, notes, and snippets.

View carolineschnapp's full-sized avatar

Caroline carolineschnapp

  • Shopify
  • Montreal
View GitHub Profile
@carolineschnapp
carolineschnapp / hide variant images.md
Created February 18, 2016 20:11
Hide variant images on the product page, so that a variant image is shown as main image only when its corresponding variant is selected.

The goal

Hide the thumbnails of variant images on the product page.

How to do that

  1. Add a class of 'variant-image' to the wrapper of each thumbnail that is a variant image. See first product.liquid snippet.
  2. Hide all .variant-image elements with CSS in the theme's stylesheet. See second style.scss.liquid snippet.
<script>
// (c) Copyright 2016 Caroline Schnapp. All Rights Reserved. Contact: mllegeorgesand@gmail.com
// See https://docs.shopify.com/themes/customization/navigation/link-product-options-in-menus
var Shopify = Shopify || {};
Shopify.optionsMap = {};
Shopify.updateOptionsInSelector = function(selectorIndex) {
@carolineschnapp
carolineschnapp / Add compare at price to Supply theme.md
Last active October 9, 2022 10:00
Add compare at price to Supply theme.
  1. Add the compare at price to the product-grid-item.liquid snippet. See gist file product-grid-item.liquid below.

  2. Add the compare at price to the product-list-item.liquid snippet. See gist file product-list-item.liquid below.

  3. Add the compare at price to the search-result-grid.liquid snippet. See gist file search-result-grid.liquid below.

  4. Add the compare at price to the product.liquid template. See gist file product.liquid below.

  5. For a more attractive strike-through, you can add some CSS to your stylesheet. See gist below.

<div>
<label for="sort-by">Sort by</label>
<select id="sort-by">
<option value="manual">Featured</option>
<option value="price-ascending">Price: Low to High</option>
<option value="price-descending">Price: High to Low</option>
<option value="title-ascending">A-Z</option>
<option value="title-descending">Z-A</option>
<option value="created-ascending">Oldest to Newest</option>
<option value="created-descending">Newest to Oldest</option>
@carolineschnapp
carolineschnapp / gist:ba16d0f12ab9ba7baefe
Last active June 15, 2022 06:42
Delivery charge collected on the Cart page
<script>
Shopify.Cart = Shopify.Cart || {};
Shopify.Cart.DeliveryCharge = {};
Shopify.Cart.DeliveryCharge.set = function(data) {
jQuery.ajax({
type: 'POST',
url: '/cart/update.js',
@carolineschnapp
carolineschnapp / 1-remove-gray-frame-in-Brooklyn.md
Last active May 24, 2022 03:53
How to get rid of the gray product image frame, when the collage treatment is disabled. For those who want a more conventional grid when using the #Brooklyn theme. This isn't a customization I support. If you have questions, please post them in this community forum: https://ecommerce.shopify.com/c/ecommerce-design

What you want

You want to go from this:

Alt text

... to that:

Alt text

@carolineschnapp
carolineschnapp / Add Color Swatches using hex values.md
Last active May 11, 2022 18:39
Add Color swatches to #Brooklyn theme. Use hexadecimal values or images.

What we want

We want to go from this:

Alt text

... to that:

Alt text

@carolineschnapp
carolineschnapp / disable-sold-out.liquid
Last active May 5, 2022 06:14
Disable sold-out variants
{% comment %}
Disable sold-out variants.
Only works for products that have one option.
It won't work with products that have two or three options, like Size and Color.
See: https://docs.myshopify.io/themes/customization/products/hide-variants-that-are-sold-out
{% endcomment %}
{% if product.options.size == 1 %}
<script>
var $addToCartForm = $('form[action="/cart/add"]');
@carolineschnapp
carolineschnapp / gist:3452433
Last active March 18, 2022 05:08
product.liquid in New Standard Theme after the swatches "wash"
<div class="clearfix" id="product-content" itemscope itemtype="http://schema.org/Product">
<meta itemprop="url" content="{{ shop.url }}{{ product.url }}" />
<meta itemprop="image" content="{{ product.featured_image.src | product_img_url: 'grande' }}" />
{% if product.available %}
<form action="/cart/add" method="post" enctype="multipart/form-data">
{% endif %}
<ul id="product-details">
@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