Skip to content

Instantly share code, notes, and snippets.

View zakhardage's full-sized avatar

little desert dog zakhardage

View GitHub Profile
@zakhardage
zakhardage / Shopify Line Item Properties -> Cart Attributes
Created January 31, 2014 17:31
This is a workaround solution to the problem of Shopify line item properties getting truncated and stripped of their line breaks on the Orders page. I convert line item properties to unique cart attributes to move the information to the Order Notes section of the Orders page.
{{ p.first }}{% endunless %}: {{ p.last | newline_to_br }}
<textarea class="hidden" id="{{ p.first | handle }}-{{ item.product.handle }}" name="attributes[{{ p.first | handle }}-{{ item.product.handle }}]" cols="10" rows="10">{{ p.last }}</textarea>
@zakhardage
zakhardage / Shopify Cart Permalink
Created March 7, 2014 07:00
How to construct the permalink by looping through cart.items
// Existing Form
<form action="http://bridal-survival.myshopify.com/cart/add" method="post">
<input type="hidden" name="id" value="{{ variant.id }}" />
<input type="hidden" name="return_to" value="back" />
<input class="buy" type="submit" value="{{ variant.id }}" />
</form>
// New Form
{% if customer and customer.tags contains 'wholesale' %}{% assign wholesale-customer = true %}{% endif %}
{% for variant in product.variants %}{% if variant.title contains 'wholesale' %}{% assign wholesale-product = true %}{% endif %}
{% assign price = product.price_max %}
{% if wholesale-customer and wholesale-product %}
{% for variant in product.variants %}
{% if variant.title contains 'wholesale %}
{% assign item-count = item-count | plus:1 %}
{% unless variant.price < price %}
{% assign id = variant.id %}
@zakhardage
zakhardage / Liquid Reviews
Created April 24, 2014 05:03
Using article and comment variables to display product reviews
{% for article in blogs.reviews.articles %}
{% assign article-handle = article.title | handle %}
{% if article-handle == product.handle %}
{% assign review-count = article.comments_count %}
{% paginate article.comments by 50 %}
{% for comment in article.comments %}
{% assign star-count = star-count | plus:comment.name %}
{% endfor %}
{% endpaginate %}
{% endif %}
@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 / 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>
<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 / 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;
}
}
@zakhardage
zakhardage / Wordpress Style-by-Color Widget
Last active December 17, 2015 21:09
Displays blog tags a color links. Used here: http://www.lmaeboutique.com/blog/
a {display:block; float:left; color:#898989; text-decoration:none; padding:0 8px 8px 8px; width:90px; text-transform:capitalize; border-right:thin solid #c2b59b; white-space: nowrap; overflow: hidden; -o-text-overflow: ellipsis; -ms-text-overflow: ellipsis; text-overflow: ellipsis;}
a.one {padding:0 8px 8px 0;}
a.three {border-right:none;}
a span {display:inline-block; height:15px; width:15px; border-radius:7.5px; position:relative; top:3px; margin:0 5px 0 0;}
<?php
$tags = get_tags();
$count = 1;
foreach ( $tags as $tag ) {
$tag_link = get_tag_link( $tag->term_id );