Skip to content

Instantly share code, notes, and snippets.

View JamieS's full-sized avatar

Jamie Sutton JamieS

View GitHub Profile
if (location.protocol !== "https:") {
location.protocol = 'https:';
}
@JamieS
JamieS / gist:3177281
Created July 25, 2012 17:04 — forked from carolineschnapp/size-chart.liquid
size-chart.liquid snippet
{% if template contains 'product' %}
{% assign size_options = 'size,taille' | split: ',' %}
{% assign size_chart_text_link = 'Size chart' %}
{% assign has_size = false %}
{% assign size_index = 0 %}
{% for option in product.options %}
{% assign downcased_option = option | downcase %}
{% if has_size == false and size_options contains downcased_option %}
{% assign has_size = true %}
{% assign size_index = forloop.index0 %}
@JamieS
JamieS / cart-snippet.liquid
Created March 9, 2012 15:52 — forked from bradjmiller/cart-snippet.liquid
Display associated image of product variant in cart.liquid
<a href="{{ item.product.url }}" title="{{ item.product.title | escape }}">
{% assign found = false %}
{% for img in item.product.images %}
{% if found == false and item.variant.title contains img.alt %}
<img src="{{ img | product_img_url: 'thumb' }}" alt="{{ item.alt | escape }}" />
{% assign found = true %}
{% endif %}
{% endfor %}
{% if found == false %}
<img src="{{ item.product.featured_image | product_img_url: 'thumb' }}" alt="{{ item.product.featured_image.alt | escape }}" />
@JamieS
JamieS / Meta Descriptions
Created October 18, 2011 15:04 — forked from resistorsoftware/Google Shopping Snippet
Enhanced Meta-Titler snippet
{% assign maxwords = 30 %}
{% if template == 'product' %}
{% if collection %}
<link rel="canonical" href="{{ shop.url }}{{ product.url }}" />
{% endif %}
{% assign mf = product.metafields.meta_data %}
{% unless mf == empty %}
{% for mf in product.metafields.meta_data' %}
{% capture key %}{{ mf | first }}{% endcapture %}
{% if key == 'title' %}
@JamieS
JamieS / coupons
Created October 3, 2011 11:34 — forked from rapind/coupons
Load Groupon Codes into Shopify Discounts
# http://forums.shopify.com/categories/6/posts/42926
# This is a fairly simple mechanize script to create a few hundred or so shopify discounts from a CSV of groupon codes.
# You'll want to change all of the "changeme" values to your own.
# The script expects there to be a groupon_codes.csv in the same directory.
#
# The groupons_code.csv should look like this:
# 8m7677
# 8m6749
# 8m5398
# 8m7699
@JamieS
JamieS / gist:1083549
Created July 14, 2011 21:49 — forked from carolineschnapp/gist:1083007
Linked options helper methods for Shopify. See this: http://wiki.shopify.com/Linked_Options
<script>
// (c) Copyright 2011 Caroline Schnapp. All Rights Reserved. Contact: mllegeorgesand@gmail.com
// See http://wiki.shopify.com/Linked_Options
Shopify.optionsMap = {};
Shopify.updateOptionsInSelector = function(selectorIndex) {
var key = jQuery('.single-option-selector:eq(0)').val();
if (selectorIndex === 2) {
key += ' / ' + jQuery('.single-option-selector:eq(1)').val();
}
var selector = jQuery('.single-option-selector:eq(' + selectorIndex + ')');
@JamieS
JamieS / altered-superfish.js
Created April 13, 2011 12:24 — forked from kswedberg/altered-superfish.js
Superfish onclick
/*
* Superfish v1.4.8 - jQuery menu widget
* Copyright (c) 2008 Joel Birch
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
*/
// ---------------------------------------------------------
// POST to cart/update.js returns the cart in JSON.
// To clear a particular attribute, set its value to an empty string.
// Receives attributes as a hash or array. Look at comments below.
// ---------------------------------------------------------
Shopify.updateCartAttributes = function(attributes, callback) {
var data = '';
// If attributes is an array of the form:
// [ { key: 'my key', value: 'my value' }, ... ]
if (jQuery.isArray(attributes)) {
{% if template == 'product' %}
{% assign mf = product.metafields.meta_description %}
{% unless mf == empty %}
{% for mf in product.metafields.meta_description %}
<meta name="Fubar2 Ronnie James Dio" content="{{mf.last}}" />
{% endfor %}
{% endunless %}
{% endif %}
/*
* mediaquery function - test whether a CSS media type or query applies
* author: Scott Jehl
* Copyright (c) 2010 Filament Group, Inc
* MIT license
* Developed as a feature of the EnhanceJS Framework (enhancejs.googlecode.com)
* thx to:
- phpied.com/dynamic-script-and-style-elements-in-ie for inner css text trick
- @paul_irish for fakeBody trick
*/