Skip to content

Instantly share code, notes, and snippets.

View zakhardage's full-sized avatar

little desert dog zakhardage

View GitHub Profile
@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 );
@zakhardage
zakhardage / Shopify Blog Archives
Last active December 18, 2015 03:39
Archives widget for shopify blog sidebar
{% capture dates %}2013 2014 2015 2016 2017 2018 2019 2020{% endcapture %}
{% capture tags %}{% for tag in blog.all_tags %}{{ tag }} {% endfor %}{% endcapture %}
<div id="categories" class="widget">
<h2>Categories</h2>
{% for tag in blog.all_tags %}
{% assign check = tag | downcase | split:' ' %}
{% unless dates contains check[0] %}
<a href="{{ blog.url }}/tagged/{{ tag | handle }}">{{ tag }}</a>
{% endunless %}
{% endfor %}
@zakhardage
zakhardage / Shopify Random Product Order
Last active February 23, 2023 07:47
Random Product Order in Shopify
<script type="text/javascript">
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 / Shopify cross sell, randomized
Last active April 13, 2020 02:27
Simple randomized cross sell for Shopify using fisherYates shuffle.
{% assign curProduct = product.handle %}
{% assign count = 0 %}
<div id="related">
<script>
function fisherYates ( myArray ) {
var i = myArray.length,j,temp;
if (i === 0) return false;
while (--i) {
j = Math.floor(Math.random()*(i+1));
@zakhardage
zakhardage / Auto-select first available variant (Shopify)
Created July 27, 2013 22:06
Auto-selecting the first available variant so that your product does not look sold out
<select id="product-select" name="id">
{% assign selected = 'notYet' %}
{% for variant in product.variants %}
{% if variant.available and selected == 'notYet' %}
<option value="{{ variant.id }}" selected="selected">{{ variant.title }}</option>
{% assign selected = 'alreadySelected' %}
{% else %}
<option value="{{ variant.id }}">{{ variant.title }}</option>
{% endif %}
{% endfor %}
@zakhardage
zakhardage / Shopify Wholesale Collection
Last active January 30, 2016 13:56
Shopify collection template with a quick add-to-cart button for each product for wholesale customers.
<table>
{% tablerow product in collection.products cols: 3 %}
{% assign parentCount = tablerowloop.index %}
<a href="{{ product.url | within: collection }}">
<img id="img{{ tablerowloop.index }}" src="{{ product.featured_image | product_img_url: 'large' }}" alt="{{ product.title | escape }}" />
{{ product.title }}
{% assign wholesalePriceCheck = 'unset' %}
{% for variant in product.variants %}
{% assign opt1 = variant.option1 | handle %}
@zakhardage
zakhardage / Using article variables for repetitive content (Shopify)
Last active December 20, 2015 17:39
This particular snippet is used to display the about-the-maker tabbed content on koromiko.com's product pages.
{% for article in blogs.retailers.articles reversed %}
{% assign content = article.content | strip_html | split:',' %}
{% assign state = content[1] %}
{% unless states contains state %}
{% assign count = count | plus:1 %}
{% assign stores = 0 %}
{% capture states %}{{ state }} {{ states }}{% endcapture %}
<h3 class="state">{{ state }}</h3>
<p>
<script>
@zakhardage
zakhardage / Shopify Advanced Search
Created August 27, 2013 02:12
The beginnings of advanced search for Shopify. Using javascript to update the 'type' input field. Using Shopify's search filters (http://wiki.shopify.com/Admin_search#Searching_only_for_certain_types) you can go much further. This could probably be written cleaner/faster, but this is just a quick proof of concept.
@zakhardage
zakhardage / Breadcrumbs for sub-collections [Shopify]
Created September 1, 2013 05:16
This is an example of displaying breadcrumbs for products within a sub-collection in Shopify.
{% for link in linklists.sidebar.links %}
{% assign cur_parent = link.title | handleize %}
{% assign cur_parent_url = link.url %}
{% if linklists.[cur_parent].links.size > 0 %}
{% for link in linklists.[cur_parent].links %}
{% if link.title == collection.title %}
{% assign parent = cur_parent %}
{% assign parent_url = cur_parent_url %}
{% endif %}
{% endfor %}
@zakhardage
zakhardage / Much much simpler option selector for Shopify
Last active July 8, 2022 09:50
Much simpler version of Shopify's option_selection.js for separating product options into their own dropdown menus.
<form action="/cart/add" method="post">
{% if product.variants.size > 1 %}
{% if product.options[0] %}
{% assign used = '' %}
<label for="select-one">{{ product.options[0] }}</label>
<select id='select-one' onchange="letsDoThis()">
{% for variant in product.variants %}
{% unless used contains variant.option1 %}
<option value="{{ variant.option1 }}">{{ variant.option1 }}</option>
{% capture used %}{{ used }} {{ variant.option1 }}{% endcapture %}