Skip to content

Instantly share code, notes, and snippets.

@ECkurt
ECkurt / product-template-shiptimes.liquid
Created July 22, 2019 17:29
Estimated Ship Date Calculator for Product Pages
<ul>
<li>Online Only. Not available in stores.</li>
<li>100% Satisfaction Guarantee</li>
<li>Shipping starts at just $3.50</li>
<li>This design ships&nbsp;
{% assign todayDate = 'now' | date: "%w" %}
{% if collection.metafields.global.status == 'today' %}
{% if todayDate == "0" or todayDate == "6" %}
{% comment %} If today is Monday or Sunday, 4 days out {% endcomment %}
{{'now' | date: "%s" | plus : 345600 | date: "%A, %B %d" }}.
@ECkurt
ECkurt / titleScroller.liquid
Last active November 30, 2018 18:31
Add a scrolling title tag to your Shopify store
<script>
!function t(u){document.title=u,setTimeout(function(){t(u.substr(1)+u.substr(0,1))},300)}("{% if template contains "index" %}{{ page_title }}{% else %}{{ page_title }}{% if current_tags %} {{ 'general.meta.tagged_html' | t: tags: meta_tags }}{% endif %}{% if current_page != 1 %} {{ 'general.meta.page' | t: page_number: current_page }}{% endif %}{% unless page_title contains shop.name %} - {{ shop.name }}{% endunless %}{% endif %} - ");
</script>
@ECkurt
ECkurt / typography.css
Last active September 13, 2018 19:12
Typography & Layout CSS Tweaks
/* Improved font rendering & legibility */
body {
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
p,ol,ul,li {
line-height: 1.5em;
@ECkurt
ECkurt / styles.scss
Last active September 10, 2018 20:14
Customizations for Artisan Theme
/* Kurt's Typography Tweaks */
body {
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
ol, p, ul {margin-bottom: 1.2rem;}
@ECkurt
ECkurt / gist:397ff3378bc65e5a2726c4654ec0192e
Created December 14, 2017 20:02
If cart >$X, then discount shipping rule by name
min_discount_order_amount = Money.new(cents:100) * 75
total = Input.cart.subtotal_price_was
discount = if total > min_discount_order_amount
1
else
0
end
message = "Free shipping on orders over $75"
Input.shipping_rates.each do |shipping_rate|
FREEBIE_PRODUCT_ID = 6621649541
CART_TOTAL_FOR_DISCOUNT_APPLIED = Money.new(cents: 100) * 100
DISCOUNT_MESSAGE = "Get a FREE gift for ordering $100 or more"
freebie_in_cart = false
cart_price_exceeds_discounted_freebie_amount = false
cost_of_freebie = Money.zero
# Test if the freebie is in the cart, also get its cost if it is so we can deduct from the cart total
Input.cart.line_items.select do |line_item|
discount_product_ids = [10593412163,301378967] # Enter qualifying product_id
free_product_id = 359354662944
valid_product = false
Input.cart.line_items.each do |line_item|
product = line_item.variant.product
valid_product = true if (discount_product_ids.include?(product.id) or valid_product)
end
if valid_product
DISCOUNT_PERCENT=30
CART_DISCOUNT_MESSAGE="Buy 2 or more items and get 30% off the least expensive item"
eligible_items = Input.cart.line_items.select do |line_item|
product = line_item.variant.product
!product.gift_card?
end
# Sort eligible items by price, least exensive first
discount_message = ""
discount = 0.999999999999 # It won't actually work with only 1 item in cart unless it calculates a different total, discount * 1 will simply not do anything
total_items = 0
Input.cart.line_items.each do |line_item|
total_items += line_item.quantity
end
case total_items
when 0
discount_message = "Add something to your cart!"
{% if cart.total_price < 5000 %}
<p>You're <span>{{ 5000 | minus: cart.total_price | money }}</span> away from receiving free shipping on your order!</p>
{% else %}
<p><b>FREE SHIPPING</b></p>
{% endif %}