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:1748732
Created February 6, 2012 01:02
Image Update in Couture
<script>
jQuery('#product-select').change(function() {
var variantTitle = jQuery(this).find(':selected').text();
jQuery('.thumbs img[alt=' + variantTitle + ']').trigger('click');
})
</script>
@carolineschnapp
carolineschnapp / gist:1795220
Created February 11, 2012 01:54
The Big Loop
<ul>
{% for collection in collections %}
{% unless collection.products_count == 0 %}
<li>
{{ collection.title | link_to: collection.url }}
{% if collection.all_tags.size > 0 %}
<ul>
{% for tag in collection.all_tags %}
{% capture url %}{{ collection.url }}/{{ tag | handle }}{% endcapture %}
<li>{{ tag | link_to: url }}</li>
@carolineschnapp
carolineschnapp / relevant-articles.liquid
Created February 21, 2012 18:20
Pulling relevant articles from one blog in product.liquid
{% comment %}
Put the code below in a new snippet called relevant-articles.liquid. Include that snippet in product.liquid using {% include 'relevant-articles' %}.
Edit how many articles maximum you want to show by editing the how_many_articles_to_show variable assignment near the top.
Requirement: whenever you are blogging and you happen to say something that is relevant to product A or product B, add the title of those products as tags to your blog post.
For example, if you are writing about how you have been working on improving a product called 'Gizmo', then add 'Gizmo' as tag to your blog post.
{% endcomment %}
@carolineschnapp
carolineschnapp / gist:1878238
Created February 21, 2012 19:13
When filtering a collection by size, say, 'Small', that is the code to use to hide products which 'Small' variants are out of stock.
{% for product in collection.products %}
{% assign hide_product = false %}
{% assign size_index = 0 %}
{% for option in product.options %}
{% if option == 'Size' %}
{% assign size_index = forloop.index0 %}
{% endif %}
{% endfor %}
@carolineschnapp
carolineschnapp / settings.html
Created February 22, 2012 00:20
Build your own product: Pick X products and we'll put that in a box.
<fieldset>
<legend>Your pack product</legend>
<table style="clear:both">
<tr>
<td><label for="pack_quantity">How many items in the pack?</label></td>
<td>
<select id="pack_quantity" name="pack_quantity">
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
@carolineschnapp
carolineschnapp / build-your-own-pack.liquid
Created February 22, 2012 00:41
Extra fields for the Customizr
{% assign number_of_picks = settings.pack_quantity %}
{% assign flavors = settings.pack_flavors | strip_newlines | replace: ' ,', ',' | replace: ' , ', ',' | replace: ', ', ',' %}
{% assign flavor_array = flavors | split: ',' %}
<table>
<tr>
<th>Flavors</th>
{% for i in (1..number_of_picks) %}
<th>{{ i }}</th>
{% endfor %}
</tr>
@carolineschnapp
carolineschnapp / gist:1904659
Created February 24, 2012 23:46
Client-side sorting for collections
<div id="reorder-drop-down" style="margin-top:10px; background-color:#e8e8e8; padding:10px; overflow:hidden">
<label style="display:inline; color: #777; font-size: 12px; font-weight: normal">Reorder this collection</label>
<select id="reorder-options" name="reorder-options">
<option value="alpha-asc"{% if collection.handle contains 'alpha-asc' %} selected="selected"{% endif %}>Alphabetically: A-Z</option>
<option value="alpha-desc"{% if collection.handle contains 'alpha-desc' %} selected="selected"{% endif %}>Alphabetically: Z-A</option>
<option value="best-selling"{% if collection.handle contains 'best-selling' %} selected="selected"{% endif %}>By Best Selling</option>
<option value="created-desc"{% if collection.handle contains 'created-desc' %} selected="selected"{% endif %}>By Created Date: Newest to Oldest</option>
<option value="created-asc"{% if collection.handle contains 'created-asc' %} selected="selected"{% endif %}>By Created Date: Oldest to Newest</option>
<optio
@carolineschnapp
carolineschnapp / gist:1960279
Created March 2, 2012 18:37
Latest Blog Articles
{% comment %}
Edit the 2 values right below: what's your blog handle and how many articles do you want to show?
{% endcomment %}
{% assign your_blog_handle_here = 'news' %}
{% assign how_many_articles_to_show = 5 %}
<!-- START OF LATEST BLOG POSTS -->
{{ '//code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css' | stylesheet_tag }}
{{ '//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js' | script_tag }}
<div style="width:300px; clear:both;">
<p>
<label for="date">Pick a delivery date:</label>
<input id="date" type="text" name="attributes[date]" value="{{ cart.attributes.date }}" />
<span style="display:block" class="instructions"> We do not deliver during the week-end.</span>
</p>
</div>
@carolineschnapp
carolineschnapp / gist:1961517
Created March 2, 2012 21:25
Add this at the bottom of cart.liquid to auto-save your cart attributes
<script type="text/javascript" charset="utf-8">
//<![CDATA[
jQuery(function() {
jQuery(window).unload(function() {
var params = {
type: 'POST',
url: '/cart/update.js',
data: jQuery('form[action="/cart"]').serialize(),
dataType: 'json',
async: false