Skip to content

Instantly share code, notes, and snippets.

View justincron's full-sized avatar

Justin Cron justincron

View GitHub Profile
@davecap
davecap / collections.liquid.html
Last active February 11, 2025 15:00
"Infinite" scrolling in Shopify collections
{% paginate collection.products by 20 %}
<!-- the top of your collections.liquid -->
<!-- START PRODUCTS -->
{% for product in collection.products %}
<!-- START PRODUCT {{ forloop.index | plus:paginate.current_offset }} -->
<div class="product" id="product-{{ forloop.index | plus:paginate.current_offset }}">
{% include 'product' with product %}
</div>
<!-- END PRODUCT {{ forloop.index | plus:paginate.current_offset }} -->
@resistorsoftware
resistorsoftware / Google Shopping Snippet
Last active March 22, 2021 17:01
Enhanced Meta Tagger snippet
{% comment %}
- add this snippet to any product.liquid template, at the top of the file, and you can access the extra data provided by
the new version of Meta Tagger that supports Google Shopping.
{% endcomment %}
{% if template contains 'product' %}
{% if product.metafields.global %}
{% for mf in product.metafields.global %}
@bohman
bohman / viewport.js
Last active March 15, 2025 07:05
jQuery get viewport size
// -----------
// Debugger that shows view port size. Helps when making responsive designs.
// -----------
function showViewPortSize(display) {
if(display) {
var height = jQuery(window).height();
var width = jQuery(window).width();
jQuery('body').prepend('<div id="viewportsize" style="z-index:9999;position:fixed;top:40px;left:5px;color:#fff;background:#000;padding:10px">Height: '+height+'<br>Width: '+width+'</div>');
jQuery(window).resize(function() {
@kyleaparker
kyleaparker / gist:5949872
Created July 8, 2013 15:32
Shopify - Show total savings on cart page
{% 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:
@PaulKinlan
PaulKinlan / criticalcss-bookmarklet-devtool-snippet.js
Last active March 12, 2025 01:22
CriticalCSS Bookmarklet and Devtool Snippet.js
(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(": ");
@strack
strack / A-Pen-by-Isaac-Strack.markdown
Last active December 21, 2015 14:58
A Pen by Isaac Strack.
@lukeburford
lukeburford / Shopify random blog post (Liquid server-side method)
Last active February 16, 2021 10:36
Display random post from a Shopify blog, for example on the store homepage. Shopify caches it's pages so a homepage refresh will not show a new post, but adding an item to the cart and returning to the homepage will. Based on: http://wiki.shopify.com/Featuring_one_randomly_picked_product
{% 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 %}
@donohfx
donohfx / multi-lang.liquid
Last active December 17, 2017 00:41
Multiple Languages + Currencies
<!-- 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)
-->
<!-- 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%; }
@gokulkrishh
gokulkrishh / media-query.css
Last active April 22, 2025 04:29
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
/* CSS */