Skip to content

Instantly share code, notes, and snippets.

View jdlich's full-sized avatar

Jacob Lichner jdlich

View GitHub Profile

Creates an array of metafield keys for a given namespace (replace "namespace" below with actual metafield namespace).

{% assign product_metafields = product.metafields["namespace"] %}

{% assign product_metafield_keys = "" | split: "" %}

{% assign keys = product_metafields | json | split: "," %}

{% for k in keys %}
// Put this at the top of the <head>
// 3rd party globals will be listed in the console
<script>
(function (window) {
var globals = (function (o) {
for ( var i in window ) {
o.push(i);
}
@jdlich
jdlich / SassMeister-input.scss
Created February 15, 2016 01:07
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
$colors: (inverted, #ffffff) (primary, blue) (accent, red);
@mixin borders($modifier: "") {
@each $color in $colors {
$color-keyword: nth($color, 1);
$color-hex: nth($color, 2);
@jdlich
jdlich / SassMeister-input.scss
Created February 1, 2016 19:10
Generated by SassMeister.com.
// ----
// libsass (v3.3.2)
// ----
@mixin column-helpers($breakpoint:"") {
$columns: (1,one) (2,two) (3,three) (4,four) (5,five) (6,six) (7,seven) (8,eight) (9,nine) (10,ten) (11,eleven) (12,twelve) (13,thirteen) (14,fourteen) (15,fifteen) (16,sixteen);
.one {
width: 100%;
}
@jdlich
jdlich / SassMeister-input.scss
Created December 27, 2015 18:19
Generated by SassMeister.com.
// ----
// libsass (v3.3.2)
// ----
@mixin width-helpers($breakpoint:"") {
$columns: (1,one) (2,two) (3,three) (4,four) (5,five) (6,six) (7,seven) (8,eight) (9,nine) (10,ten) (11,eleven) (12,twelve) (13,thirteen) (14,fourteen) (15,fifteen) (16,sixteen);
@each $column in $columns {
$column-count: nth($column, 1);
$column-class: nth($column, 2);
@jdlich
jdlich / enforce-http.liquid.js
Last active July 16, 2018 22:27 — forked from chrisjhoughton/enforce-http.liquid.js
How to build an ajax form on Shopify. See http://inside.sauce.ly/how-to-build-an-ajax-login-form-on-shopify/ for the full blog post.
/*
* Ensure the http protocol is always used on the myshopify.com domains.
* Uses liquid to input the correct URL.
*/
if (window.location.href.match(/https:\/\/.*.myshopify.com/) && top === self) {
window.location.href = window.location.href.replace(/https:\/\/.*.myshopify.com/, 'http://{{ shop.domain }}');
}
// ---------------------------------------------------------
// 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)) {
@jdlich
jdlich / SassMeister-input.scss
Last active August 29, 2015 14:22
Generated by SassMeister.com.
// ----
// Sass (v3.4.14)
// Compass (v1.0.3)
// ----
$font-weights: (lightest,100) (light,200) (regular,300) (medium,500) (bold,700) (boldest,900);
@each $font in $font-weights {
$font-name: nth($font, 1);
$font-weight: nth($font, 2);
@jdlich
jdlich / SassMeister-input.scss
Created June 5, 2015 02:29
Generated by SassMeister.com.
// ----
// Sass (v3.4.13)
// Compass (v1.0.3)
// ----
@mixin position-helpers($breakpoint:"") {
@each $side in "top", "right", "bottom", "left" {
.#{$breakpoint}position-#{$side} {
position: absolute;
#{$side}: 0;
@jdlich
jdlich / SassMeister-input.scss
Last active August 29, 2015 14:22
Generated by SassMeister.com.
// ----
// Sass (v3.4.13)
// Compass (v1.0.3)
// ----
$colors: (primary,#f05d9a) (secondary,#a9e686);
@each $color in $colors {
$color-keyword: nth($color,1);
$color-hex: nth($color,2);