Skip to content

Instantly share code, notes, and snippets.

View zakhardage's full-sized avatar

little desert dog zakhardage

View GitHub Profile
{% if product.compare_at_price > product.price %}
<del>${{ product.compare_at_price | money_without_currency | ceil }}</del>
<span class="sale-price"><span itemprop="price">${{ product.price | money_without_currency | ceil }}</span> ({{ product.compare_at_price | minus:product.price | times:100 | divided_by:product.compare_at_price }}% off)</span>
{% else %}
<span itemprop="price">${{ product.price | money_without_currency | ceil }}</span>
{% endif %}
@zakhardage
zakhardage / gist:9a9713ec7b05e4fbc2ea761ffc0996a6
Created January 23, 2018 03:07
"Is there a way I could disable several products to not appear in the search result using the search panel"
{% for item in search.results %}
{% assign tags = item.tags | join:', ' | downcase %}
{% unless tags contains 'search hide' %}
// search result
{% endunless %}
{% endfor %}
@zakhardage
zakhardage / product price table
Created March 26, 2017 03:40
product price table - hard coded value categories
{% for variant in product.variants %}
{% assign option = variant.option1 | downcase %}
{% assign p = variant.price | money %}
{% unless option contains '+' or option contains 'swatch' %}
{% if option contains '1-4' %}
{% assign one = p %}
{% else %}
{% unless option contains '-' %}{% assign one = p %}{% endunless %}
{% endif %}
{% endunless %}
@zakhardage
zakhardage / cart using wholesale discount
Created March 18, 2017 05:07
cart using wholesale discount
{% if customer %}{% assign tags = customer.tags | join:' ' | downcase %}{% if tags contains 'wholesale' %}{% assign wholesale = true %}{% endif %}{% endif %}
{% if wholesale %}
{% if tags contains 'reorder' or customer.orders_count > 0 %}{% assign reorder = true %}{% endif %}
{% assign min = settings.cart-min | times:100 | minus:1 %}
{% if reorder %}{% assign min = setting.cart-min-reorder | times:100 | minus:1 %}{% endif %}
{% endif %}
<div class="meta grid">
{% if wholesale %}{% assign total = cart.total_price | divided_by:2 %}{% else %}{% assign total = cart.total_price %}{% endif %}
<p>{{ total | money | remove:' ' }}</p>
@zakhardage
zakhardage / Shopify redirect for off-platform blogs
Created December 30, 2016 00:55
Shopify redirect for off-platform blogs
{% if template contains 'blog' or template contains 'article' %}
<script type="text/javascript">
window.location = "http://blog.sitename.com";
</script>
{% endif %}
@zakhardage
zakhardage / Pop up and cookies
Created December 16, 2016 18:06
Pop up and cookies
// Newsletter popup
$(document).ready(function() {
$('.response').addClass('rte');
var coOkie = getCookie("bellePopup");
if (coOkie != "") {console.log('coOkie set');} else {newsletterPopup();}
});
function newsletterPopup() {
setTimeout(function() {
$('.overlay').fadeIn();
$('.pop').fadeIn();
@zakhardage
zakhardage / automatically apply price-based discount in Shopify
Created June 17, 2016 21:00
automatically apply price-based discount in Shopify
{% if cart.total_price > settings.cart-discount-threshold %}{% assign threshold = true %}{% endif %}
<form action="/cart{% if threshold %}/?discount=[discountcode]{% endif %}" method="post">
{% capture options1 %}{% for variant in product.variants %}{{ variant.option1 }},{% endfor %}{% encdapture %}
{% assign options1 = options1 | split:',' | uniq %}
<select>
{% for option in options1 %}
<option value="option">{{ option }}</option>
{% enfor %}
</select>
@zakhardage
zakhardage / Shopify add-ons (e.g. engraving)
Created March 10, 2016 22:23
Shopify add-ons (e.g. engraving)
{% comment %}
Create product for engraving and add to collection with handle "utility"
Add "add-to-cart" class to product form
Add "quantity" class to quantity field
Create a test for engraving product -- I like adding a product tag
{% for tag in product.tags %}
{% assign t = tag | downcase %}
{% if t contains 'engrave' %}{% assign engrave = true %}{% endif %}
{% endfor %}
@zakhardage
zakhardage / Line Item Properties from Product Tags
Last active April 11, 2017 14:20
Line Item Properties from Product Tags
{% for tag in product.tags %}
{% if tag contains 'color-' %}{% assign color = true %}{% endif %}
{% endfor %}
{% if color %}
<div class="select">
<label>Color:</label>
<select id="color" name="properties[Color]">
{% for tag in product.tags %}
{% if tag contains 'color-' %}