Skip to content

Instantly share code, notes, and snippets.

View zakhardage's full-sized avatar

little desert dog zakhardage

View GitHub Profile
// change line 108 from
{% for line_item in line_items_in_shipment %}
// to
{% assign line_items_by_sku = line_items_in_shipment | sort:'sku' %}
{% for line_item in line_items_by_sku %}
// change line 21 from
<th>Item</th>
// to
<th>SKU</th>
<th>Item</th>
// change line 30 from
{% for line_item in line_items %}
// to
{% assign line_items_by_sku = line_items | sort:'sku' %}
<form action="/cart/add" method="post">
{% if product.variants.size > 1 %}
{% for variant in product.variants %}
<input type="radio" id="variant-{{ variant.title | handle }}" name="variant" value="{{ variant.id }}" />
<label for="variant-{{ variant.title | handle }}">{{ variant.title }}</label>
<br />
{% endfor %}
{% endif %}
<input type="hidden" name="id" class="product-select" value="{{ product.variants[0].id }}" />
@zakhardage
zakhardage / Vanilla product recommendations
Last active June 15, 2021 05:49
updated to prioritize shows and art medium
<div class="cross-content"></div>
<script>
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];
{% assign member_discount_code = settings.member_discount_code %}
{% assign class_discount_code = settings.class_discount_code %}
{% assign combined_discount_code = settings.combined_discount_code %}
{% if customer %}
{% assign customer_tags = customer.tags | join:',' | downcase %}
{% if customer_tags contains 'member' %}
{% assign member = true %}
{% endif %}
{% endif %}
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Buy button / cart permalink</title>
<style>
img {max-width:200px;}
</style>
</head>
<body>
{%- assign media_padding_top = media.aspect_ratio + 0.08 | divided_by: media.aspect_ratio | times: 100 -%}
or
{%- assign media_padding_top = 8 | divided_by: media.aspect_ratio | plus: 100 -%}
@zakhardage
zakhardage / price change
Created January 16, 2020 05:33
price change
var price = '$'+parseFloat(variant.price/100).toFixed(2);
$('.product-price').text(price);
@zakhardage
zakhardage / remove duplicate strings from variant titles
Created August 29, 2019 22:27
Removes duplicate strings from the beginning of variant titles (Shopify)
{% assign string = product.variants[0].title | downcase | split:' ' %}
{% assign size = string | size %}
{% assign pass = true %}
{% for i in (0..size) %}
{% for variant in product.variants %}
{% assign compare = variant.title | downcase | split:' ' %}
{% unless string[i] == compare[i] %}{% assign pass = false %}{% endunless %}
{% endfor %}
{% if pass %}{% assign remove = remove | append:string[i] | append:' ' %}{% endif %}
{% endfor %}
@zakhardage
zakhardage / Quick Shopify Section API request
Created August 21, 2019 04:43
Quick Shopify Section API request
<div class="content-test"></div>
<script>
var request = new XMLHttpRequest();
request.open('GET', '/?section_id=[static-section-name]', false);
request.send();
$('.content-test').html(request.responseText);
</script>