A Pen by Isaac Strack on CodePen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="/cart/add" method="post" style="text-align:center;"> | |
<select name="id"> | |
{% for variant in product.variants %} | |
{% if variant.available %} | |
<option value="{{ variant.id }}">{{ variant.title }} - {{ variant.price | money }}</option> | |
{% else %} | |
<option disabled="disabled">{{ variant.title }} - Sold Out</option> | |
{% endif %} | |
{% endfor %} | |
</select> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% comment %} | |
Add a tag to a product that's on sale. Add this in your template for displaying a product in a grid, for me it's called product-grid-item.liquid | |
{% endcomment %} | |
{% assign on_sale = false %} | |
{% if product.compare_at_price > product.price %} | |
{% assign on_sale = true %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="{{ product.url | within: collection }}"> | |
{% assign imgSize = 'medium' %} | |
{% assign canSwap = false %} | |
{% if product.images.size > 1 %} | |
{% assign canSwap = true %} | |
{% assign swapImg = product.images[1] %} | |
{% assign swapImgSrc = swapImg.src | product_img_url: imgSize %} | |
{% assign swapImgAlt = swapImg.alt | escape %} | |
{% endif %} | |
<img{% if canSwap %} class="has-swap"{% endif %} src="{{ product.featured_image.src | product_img_url: imgSize }}" alt="{{ product.featured_image.alt | escape }}"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
##Device = Desktops | |
##Screen = 1281px to higher resolution desktops | |
*/ | |
@media (min-width: 1281px) { | |
/* CSS */ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Ajax API --> | |
{{ '//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js' | script_tag }} | |
{{ 'api.jquery.js' | shopify_asset_url | script_tag }} | |
<style type="text/css"> | |
#rv__recent_products.rv__grid{width: 100%; margin-top: 20px;} | |
.rv__grid .row{ display: block; clear: both;} | |
.rv__grid .rv__row .rv__column{ float: left; } | |
.rv__grid .rv__row .rv__column.rv__one{ width: 8.3%; } | |
.rv__grid .rv__row .rv__column.rv__two{ width: 16.66%; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- This is an example of automatic currency switching based on IP as well as language selection using Langify and redirects. | |
All domains should be set up in Langify with their appropriate languages. I'd recommend placing this code in its own snippet | |
and including it near the </body> tag in your theme.liquid | |
Dependencies: | |
- currencies.js (https://github.com/carolineschnapp/currencies) | |
- Langify (https://apps.shopify.com/langify) | |
- A Shopify Store (well, should work anywhere, but only tested on Shopify) | |
--> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% capture index %}{{ 'now' | date: '%S' | times: collections.frontpage.products.size | divided_by: 60 }}{% endcapture %} | |
{% for article in blogs.blog-name.articles offset:index limit:1 %} | |
<a href="{{article.url}}">{{ article.title }}</a> | |
{% endfor %} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var CSSCriticalPath = function(w, d, opts) { | |
var opt = opts || {}; | |
var css = {}; | |
var pushCSS = function(r) { | |
if(!!css[r.selectorText] === false) css[r.selectorText] = {}; | |
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/); | |
for(var i = 0; i < styles.length; i++) { | |
if(!!styles[i] === false) continue; | |
var pair = styles[i].split(": "); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% assign total_saving = 0 %} | |
{% for item in cart.items %} | |
{% if item.variant.compare_at_price > item.variant.price %} | |
{% capture saving %}{{ item.variant.compare_at_price | minus: item.variant.price }}{% endcapture %} | |
{% assign total_saving = saving | plus: total_saving %} | |
{% endif %} | |
...rest of cart code within for loop | |
{% endfor %} | |
Display saving: |
NewerOlder