Skip to content

Instantly share code, notes, and snippets.

@seedcms
seedcms / % off tag
Created January 19, 2017 21:57
Take a percentage off any products with a specific tag.
@percent = Decimal.new(40) / 100.0
Input.cart.line_items.each do |line_item|
product = line_item.variant.product
next if product.gift_card?
next unless product.tags.include?('hugesale')
line_discount = line_item.line_price * @percent
line_item.change_line_price(line_item.line_price - line_discount, message: "HUGESALE! 40% off this item!")
end
Output.cart = Input.cart
@seedcms
seedcms / cart.liquid
Created January 18, 2017 23:57
Updated cart summary
<tfoot class="summary">
<tr>
<td colspan="2">Subtotal</td>
<td>{{ cart.original_total_price | money }}</td>
</tr>
<tr>
<td colspan="2">Discount Savings</td>
<td>{{ cart.total_discount | money }}</td>
</tr>
<tr>
@seedcms
seedcms / cart.liquid
Created January 18, 2017 23:54
Cart table after the updated line items
<tbody class="line-items">
{% for item in cart.items %}
<tr>
<td>{{ item.product.title }}</td>
<td>{{ item.quantity }}</td>
<td>
{{ item.line_price }}
{% if item.total_discount > 0 %}
<s>{{ item.original_line_price }}</s>
( {{ item.message }} )
@seedcms
seedcms / cart.liquid
Created January 18, 2017 22:26
Cart table before the script editor code.
<table class="cart">
<thead class="heading">
<tr>
<th>Product</th>
<th>Quantity</th>
<th>Total</th>
</tr>
</thead>
<tbody class="line-items">
@seedcms
seedcms / product-swatches-json.liquid
Last active July 9, 2019 08:59
Product Swatches APP JSON example
<div class="swatchslider">
<ul class="slides product-swatches-{{product.id}}"></ul>
</div>
<div style="clear:both;"></div>
<script>
/*$(window).load(function() {
$('.swatchslider').flexslider({
animation: "slide",
animationLoop: false,
@seedcms
seedcms / new-content-for-header.liquid
Created October 31, 2016 20:14 — forked from freakdesign/new-content-for-header.liquid
Detect if an admin is logged into Shopify using liquid.
<!--
Simple method for detecting an Admin in Shopify using liquid.
Quick code by jason at freakdesign.com.au
Related Blog post: http://freakdesign.com.au/blogs/news/34154561
-->
{% capture CFH %}{{ content_for_header }}{% endcapture %}{{ CFH }}
{% if CFH contains 'admin_bar_iframe' %}
@seedcms
seedcms / other-product-swatches.liquid
Last active January 4, 2018 16:40
other-product-swatches-v-001.4
<div class="product-swatches-{{product.id}}"></div>
<div style="clear:both;"></div>
<script>
jQuery(document).ready(function(){
var appDomain = '//productswatches.herokuapp.com';
var url = appDomain + '/product_swatches/get-json/{{product.id}}';
var data = {
return_format: 'html',
product_id:'{{product.id}}',
tooltip: 'yes',
@seedcms
seedcms / snippet-gallery.liquid
Created July 20, 2016 08:54
shopify - javascript random image display
@seedcms
seedcms / lookbook-apps.liquid
Created May 29, 2016 00:25
Lookbook Snippet V4
<link href='//pressify.s3.amazonaws.com/assets/fancybox/source/jquery.fancybox.css' rel='stylesheet' type='text/css'>
<script src="//pressify.s3.amazonaws.com/assets/fancybox/source/jquery.fancybox.js" type="text/javascript"></script>
<script src="//npmcdn.com/[email protected]/dist/masonry.pkgd.min.js"></script>
<script src="//npmcdn.com/[email protected]/imagesloaded.pkgd.min.js"></script>
<link href='//pressify.s3.amazonaws.com/assets/bxslider/jquery.bxslider.css' rel='stylesheet' type='text/css'>
<script src="//pressify.s3.amazonaws.com/assets/bxslider/jquery.bxslider.min.js"></script>
<div class="lookbook_details" style=""></div>
<script>
jQuery(document).ready(function(){
// app domain
@seedcms
seedcms / gist:156cf4220e2c6b382b6d40e7dc2602ca
Created April 18, 2016 19:31 — forked from carolineschnapp/gist:9122054
Order form to use in a page or collection template.
{% comment %}
Source: https://gist.github.com/carolineschnapp/9122054
If you are not on a collection page, do define which collection to use in the order form.
Use the following assign statement, replace 'your-collection-handle-here' with your collection handle.
{% assign collection = collections.your-collection-handle-here %}
Use the assign statement outside of this comment block at the top of your template.
{% endcomment %}
{% paginate collection.products by 100 %}