Skip to content

Instantly share code, notes, and snippets.

View zakhardage's full-sized avatar

little desert dog zakhardage

View GitHub Profile
@zakhardage
zakhardage / Tiered Pricing for Shopify
Last active April 19, 2022 10:53
Shopify tiered pricing using javascript (non-app). This example has the quantity breaks controlled by theme settings.
// config -> settings.html
// Make sure you have the same number of quantity breaks as product variants
<fieldset>
<legend>Quantity Breaks</legend>
<table class="standard-table">
<tr><td>Enter quantity breaks in ascending order separated by a comma (e.g. 5, 10, 20, 50)</td><td><input type="text" name="breaks" size="50" /></td></tr>
</table>
</fieldset>
@zakhardage
zakhardage / Style by Color (Wordpress)
Created November 1, 2013 07:20
Colored links from post tags. Example: http://www.lmaeboutique.com/blog/
<div class="widget">
<h3>Style by Color</h3>
<?php
$tags = get_tags();
foreach ($tags as $tag) {
$tag_link = get_tag_link( $tag->term_id );
$background = ' ' . $tag->slug;
$html .= "<a href='{$tag_link}'><span style='background:{$tag->slug};'></span>";
$html .= "{$tag->name}</a>";
}
@zakhardage
zakhardage / Monogram case with javascript
Created November 20, 2013 04:50
I needed to convert the customers 3-character input into lowercase-uppercase-lowercase (e.g. "eMc").
<div class="custom monogram">
<label>ADD A MONOGRAM:</label>
<input type="text" onkeyup="caseChange()" id="monogram" maxlength="3" />
<p class="notes">Please enter your monogram here in the correct order: first, last, middle. Monogram may not be changed to another style or full name.</p>
</div> <!-- end .custom .monogram -->
<script>
function caseChange() {
var str = document.getElementById('monogram').value;
var one = str.substring(0,1);
@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 / Custom Social Sharing
Last active March 10, 2016 21:51
Social Sharing
{% comment %} using icons from Font Awesome http://fortawesome.github.io/Font-Awesome {% endcomment %}
{% assign twitter-handle = settings.twitter | split:'twitter.com/' %}
{% assign twitter-handle = twitter-handle[1] | remove:'/' | prepend:'@' %}
<a href="http://twitter.com/home?status={{ product.title | url_escape }}%20by%20{{ shop.name | url_escape }}%20{{ shop.url }}{{ product.url }}{% if twitter-handle != blank %}%20{{ twitter-handle }}{% endif %}" target="_blank"><i class="fa fa-twitter"></i></a>
<a href="https://www.facebook.com/sharer/sharer.php?u={{ shop.url }}{{ product.url }}" target="_blank"><i class="fa fa-facebook"></i></a>
<a href="https://pinterest.com/pin/create/button/?url={{ shop.url }}{{ product.url }}&amp;media=https:{{ product.featured_image | product_img_url:'large' }}&amp;description={{ product.title | url_escape }}%20by%20{{ shop.name | url_escape }}" target="_blank"><i class="fa fa-pinterest"></i></a>
<a href="mailto:?Subject={{ product.title | url_escape }}%20from%20{{ shop.name |
@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 / Advanced Search
Created April 26, 2014 00:20
Advanced Search Concept for Shopify