Skip to content

Instantly share code, notes, and snippets.

View carolineschnapp's full-sized avatar

Caroline carolineschnapp

  • Shopify
  • Montreal
View GitHub Profile
@carolineschnapp
carolineschnapp / gist:9495805
Last active June 21, 2021 20:44
Code to paste at the very top or bottom of your product.liquid template to make clicks on product thumbnails update product option drop-downs.For the Variant Images app.
{% comment %}
Place this in your product.liquid template, either at the top or bottom.
{% endcomment %}
{% if product.variants.size > 1 %}
<script>
(function($) {
var variantImages = {},
thumbnails,
variants = {};
{% for variant in product.variants %}
@carolineschnapp
carolineschnapp / gist:9122054
Last active October 25, 2024 16:31
Order form to use in a page or collection template.
{% comment %}
Source: https://gist.github.com/carolineschnapp/9122054
If you are not on a collection page, do define which collection to use in the order form.
Use the following assign statement, replace 'your-collection-handle-here' with your collection handle.
{% assign collection = collections.your-collection-handle-here %}
Use the assign statement outside of this comment block at the top of your template.
{% endcomment %}
{% paginate collection.products by 100 %}
@carolineschnapp
carolineschnapp / hear-about-us.liquid
Last active June 21, 2021 20:44
Asking a customer “how did you hear about us” on the cart page in Shopify
{% assign choices = "Facebook, Twitter, Google, Best Toys Bulletin, John Doe" %}
{% assign required = true %}
<div class="form-vertical">
<p>
<label for="how-did-you-hear-about-us">How did you hear about us?</label>
<select id="how-did-you-hear-about-us" name="attributes[how-did-you-hear-about-us]">
<option value=""{% if cart.attributes.how-did-you-hear-about-us == "" %} selected{% endif %}>Please make a selection</option>
{% assign optionsArray = choices | split: ',' %}
{% for o in optionsArray %}
@carolineschnapp
carolineschnapp / variant-images-in-cart.html
Last active February 11, 2022 07:16
Script that updates images on the cart page to show the correct thumbnail as chosen in the Variant Images app.
{% if cart.item_count > 0 %}
<script>
// Script that updates images on the cart page to show the correct thumbnail as chosen in the Variant Images app.
// This works with any markup.
// This works when using Line Item Properties where several items in the cart form can share the same variant ID.
// Author: Caroline Schnapp.
// Place at the top of your cart.liquid template.
(function($) {
var variantImages = {},
productHandles = [];
@carolineschnapp
carolineschnapp / gist:7086465
Last active June 21, 2021 20:44
Sidebar in Minimal theme, 5 products per row.
<div id="collection">
{% paginate collection.products by 25 %}
<div class="row">
<div class="span10 products">
<div class="row">
@carolineschnapp
carolineschnapp / gist:6964782
Last active June 21, 2021 20:44
Minimal theme collection.liquid with sidebar on the right - 3 products per row.
<div id="collection">
{% paginate collection.products by 18 %}
<div class="row">
<div class="span9 products">
<div class="row">
@carolineschnapp
carolineschnapp / gist:6675188
Created September 23, 2013 18:56
Alfred prep theme extension
cd ~/Desktop/{query}
rm config.yml
find . -name '*.DS_Store' -type f -delete
rm .gitignore
rm -rf .git
rm -rf less
cd ..
zip -r {query} {query}
@carolineschnapp
carolineschnapp / gist:6675151
Created September 23, 2013 18:54
shopify_theme
Move to some folder where you want to download your theme.
Go to your shop admin.
Go to /admin/api
Copy this:
API Key
Password
<!-- It is important to understand that SwiftType uses Shopify's robots.txt to know which pages to crawl for suggestions.
So it will look at 'page' pages, blog pages, collection pages and product pages.
It will also crawl the home page and /serach page unless those are deleted in the SwiftType account under Pages.
It will look at collection-agnostic product URLs, because that's what robots.txt tells it to do.
So no collection-aware product pages will be crawled. -->
<!-- Other important consideration: as title for the suggestion, SwiftType uses the content of the title tag, or any h1 or h2 tags, on the page.
For most searches, the content title will show up nicely: product title if searching for a product, collection title if searching for a collection, etc.
Since Shopify 2, one can set up a SEO title for each product, and we don't want it to come up, so we can force a few things for product pages:
product title, also add vendor name, product type, product tags, and product image...-->
@carolineschnapp
carolineschnapp / gist:6082654
Last active June 21, 2021 20:45
Script that checks if a product has a Colo(u)r option and is available in more than 1 color.
{% assign has_color = false %}
{% assign option_index = 0 %}
{% for option in product.options %}
{% capture downcased_option %}{{ option | downcase }}{% endcapture %}
{% if downcased_option contains 'color' or downcased_option contains 'colour' %}
{% assign option_index = forloop.index0 %}
{% assign has_color = true %}
{% endif %}
{% endfor %}
{% if has_color %}