Skip to content

Instantly share code, notes, and snippets.

View zakhardage's full-sized avatar

little desert dog zakhardage

View GitHub Profile
@zakhardage
zakhardage / Fisher Yates
Last active August 29, 2015 14:22
Fisher Yates
function fisherYates ( myArray ) {
var i = myArray.length,j,temp;
if (i === 0) return false;
while (--i) {
j = Math.floor(Math.random()*(i+1));
temp = myArray[i];
myArray[i] = myArray[j];
myArray[j] = temp;
}
}
<div class="framing" id="framing">
<div>
<a href="#frame-gallery-gold" onclick="canvasFraming('gallery-gold','Gallery Gold')"></a>
<p id="gallery-gold" onclick="canvasFraming('gallery-gold','Gallery Gold')">Gallery Gold</p>
</div>
<div>
<a href="#frame-gallery-walnut" onclick="canvasFraming('gallery-walnut','Gallery Walnut')"></a>
<p id="gallery-walnut" onclick="canvasFraming('gallery-walnut','Gallery Walnut')">Gallery Walnut</p>
</div>
<div>
<form name="add-to-cart" id="add-to-cart" action="/cart/add" method="post" onsubmit="return formCheck()">
{% if product.variants.size > 1 %}
{% if product.options[0] %}
{% assign used = '' %}
<div class="select" id="parent-1">
<div class="title" id="title-1" onclick="productOptions('child-1','parent-1')">
{% unless template contains 'canvas' %}Select {% endunless %}{% if product.options.size > 1 %}{{ product.options[0] }}{% endif %}
</div> <!-- end .title -->
<div class="options-child" id="child-1">
@zakhardage
zakhardage / Wishlist Item Count
Created September 17, 2014 15:50
Wishlist Item Count
{% if customer %}
{% for tag in customer.tags %}
{% assign t = tag | remove:'x' %}
{% unless tags contains t %}
{% capture tags %}{{ tags }} {{ t }}{% endcapture %}
{% endunless %}
{% endfor %}
{% for collection in collections %}
{% paginate collection.products by collection.all_products_count %}
@zakhardage
zakhardage / Simple "Captcha" for Shopify
Created July 31, 2014 18:16
Simple "Captcha" for Shopify
// Goes in theme.liquid
{% if template contains 'contact' %}
{{ 'https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js' | script_tag }}
<script type="text/javascript">
$(document).ready(function() {
var n1 = Math.round(Math.random() * 10 + 1);
var n2 = Math.round(Math.random() * 10 + 1);
$("#question").val(n1 + " + " + n2);
$(".contact-form").submit(function (e) {
if (eval($("#question").val()) != $("#answer").val()) {
@zakhardage
zakhardage / Inventory for Wholesale [Shopify]
Last active August 29, 2015 14:04
Inventory for Wholesale [Shopify]
{% for variant in product.variants %}
{% assign qty = qty | plus:variant.inventory_quantity %}
{% endfor %}
{% if qty > 0 %}
<label>Quantity ({{ qty}} available):</label>
<input type="text" name="quantity" id="quantity" value="1" onclick="this.select()" onkeyup="qtyCheck(this.value)" />
<button type="submit">add to cart</button>
{% else %}
<p>Sorry, this is temporarily unavailable.</p>
@zakhardage
zakhardage / gist:d24bcf888011b173d89b
Last active August 29, 2015 14:04
opengraph wholesale price
// Replace this
<meta property="og:price:amount" content="15.00" />
<meta property="og:price:currency" content="USD" />
// With this
{% assign price = product.price_max %}
{% for v in product.variants %}
{% unless v.title contains 'wholesale' or v.title contains 'Wholesale' or v.price > price %}
{% assign price = v.price %}
{% endunless %}
@zakhardage
zakhardage / Shopify Cart Permalink
Last active December 11, 2018 20:05
Shopify Cart Permalink
@zakhardage
zakhardage / Advanced Search
Created April 26, 2014 00:20
Advanced Search Concept for Shopify