Skip to content

Instantly share code, notes, and snippets.

@keyurshah
keyurshah / multiple-blocks-in-jade-mixins.pug
Created October 15, 2017 14:46 — forked from dek4nice/multiple-blocks-in-jade-mixins.pug
Multiple blocks in Jade/Pug mixins
//- Multiple blocks in jade mixins? #1693
//- https://github.com/pugjs/pug/issues/1693
//- [Issue on github]
//- https://github.com/pugjs/pug/issues/1693
h2 Issue
p
a(href='https://github.com/pugjs/pug/issues/1693' , target="_blank") Multiple blocks in jade mixins?
hr
@keyurshah
keyurshah / progressive-ace.htm
Created October 14, 2017 17:11 — forked from duncansmart/progressive-ace.htm
Integrating ACE Editor in a progressive way
<textarea name="my-xml-editor" data-editor="xml" rows="15"></textarea>
...
<textarea name="my-markdown-editor" data-editor="markdown" rows="15"></textarea>
...
<script src="//d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js"></script>
<script>
// Hook up ACE editor to all textareas with data-editor attribute
$(function () {
@keyurshah
keyurshah / us-state-names-abbrevs.php
Created October 9, 2017 21:33 — forked from maxrice/us-state-names-abbrevs.php
US State Names & Abbreviations as PHP Arrays
<?php
/* From https://www.usps.com/send/official-abbreviations.htm */
$us_state_abbrevs_names = array(
'AL'=>'ALABAMA',
'AK'=>'ALASKA',
'AS'=>'AMERICAN SAMOA',
'AZ'=>'ARIZONA',
'AR'=>'ARKANSAS',
@keyurshah
keyurshah / imgURL.js
Created October 4, 2017 15:50 — forked from DanWebb/imgURL.js
Specify a size for a Shopify image asset url. Equivalent to the liquid image size filter: `{{ image | img_url: "medium" }}`
String.prototype.imgURL = function(size) {
// remove any current image size then add the new image size
return this
.replace(/_(pico|icon|thumb|small|compact|medium|large|grande|original|1024x1024|2048x2048|master)+\./g, '.')
.replace(/\.jpg|\.png|\.gif|\.jpeg/g, function(match) {
return '_'+size+match;
})
;
};
@keyurshah
keyurshah / documents.rb
Created September 6, 2017 16:14 — forked from dhh/documents.rb
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
@keyurshah
keyurshah / multiple images for a variant.md
Created August 10, 2017 01:25 — forked from carolineschnapp/multiple images for a variant.md
"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

@keyurshah
keyurshah / Have search box open by default.md
Created August 10, 2017 01:25 — forked from carolineschnapp/Have search box open by default.md
Have search box open by default in #Venture

What you have

Alt text

What you want

Alt text

How to get it

@keyurshah
keyurshah / available-colors.liquid
Created August 10, 2017 01:24 — forked from carolineschnapp/available-colors.liquid
Snippet that says 'also available in colors x and y' on the collection page when a product is available in more than 1 color. To include in product-loop.liquid, or product-grid-item.liquid.
{% comment %}
Do we have a Color option?
If so, is it the first, second or third option of that product?
We will need to access values so we need that color index.
{% endcomment %}
{% assign has_color = false %}
{% assign color_option_index = 0 %}
{% for option in product.options %}
{% assign downcased_option = option | downcase %}
@keyurshah
keyurshah / gist:22e6329b0ac26c9b9f4be4ccb225fd78
Created August 10, 2017 01:23 — forked from carolineschnapp/gist:1003334
Related Products using metafields - to add to product.liquid
<!-- Solution brought to you by Caroline Schnapp -->
<!-- See this: http://wiki.shopify.com/Related_Products -->
{% assign image_size = 'compact' %}
{% assign heading = 'Other fine products' %}
{% if product.metafields.recommendations.productHandles %}
<h3>{{ heading }}</h3>
<ul class="related-products"></ul>
@keyurshah
keyurshah / select-from-hash
Created April 15, 2017 22:14 — forked from freakdesign/select-from-hash
Javascript snippet to help auto select a Shopify variant from a hash.
<script type="text/javascript">
/*
re: http://ecommerce.shopify.com/c/ecommerce-design/t/land-on-specific-variant-when-loading-product-page-147793
Assumes:
--------
* that you are calling the javascript once the select element is available
* you have a select element on the page like: