Skip to content

Instantly share code, notes, and snippets.

@freakdesign
freakdesign / get-total-stock-value.md
Last active November 19, 2020 10:44
JavaScript function to calculate the total stock value within a Shopify store

Get total stock value of all Shopify products

Refers to the freakdesign blog post.

Most people that need to know the total stock value are already likely to be using a third party Inventory Management System, ERP (or similar). If you want to know what your total stock value is you can grab that info via the API - let's look how.

Usage

Paste the code into the browser debug console.

@freakdesign
freakdesign / collection-ratings.liquid
Created April 11, 2016 15:53
Show a collection based summary using data from the Shopify Product Reviews App.
{% comment %}
Usage:
{% include 'collection-ratings' %}
{% include 'collection-ratings' collectionHandle:'some-handle' useAll:true %}
{% endcomment %}
{% if collectionHandle == blank %}{% assign collectionHandle=collection.handle %}{% endif %}
{% if collections[collectionHandle].products.size > 0 %}
@freakdesign
freakdesign / order-to-cart.liquid
Last active September 15, 2022 20:53
Add a previous Shopify order to the cart
{% if order.line_items.size > 0 %}
<p>
<button class="btn place-same-order">Add order to cart</button>
<script>
(function(){
/* Check for the button */
var buttonOrder = document.getElementsByClassName('place-same-order') || false;
if(!buttonOrder){ return }
@freakdesign
freakdesign / product-grid-item.liquid
Created January 3, 2016 03:31
Modification of the default Timber product grid item snippet so that it can show variants.
<!-- /snippets/product-grid-item.liquid :: mod by Jason at freakdesign.com.au -->
{% comment %}
<!--
This snippet is used to showcase each product during the loop,
'for product in collection.products' in collection.liquid.
If however the product has variants, we'll show the variants instead.
-->
{% endcomment %}
@freakdesign
freakdesign / imgix-theme-settings.json
Last active October 28, 2021 13:34
Snippet and Theme Settings to for converting a Shopify CDN image path into an Imgix path. Snippet allows for the passing of Imgix filters.
{
"name": "Imgix",
"settings": [
{
"type": "paragraph",
"content": "For more info on these theme settings refer to the original [blog post](http:\/\/freakdesign.com.au\/blogs\/news\/91099207)"
},
{
"type": "checkbox",
"id": "enableImgix",
@freakdesign
freakdesign / product-sold-count.md
Last active May 24, 2018 13:40
Quick code to show how to add a sold counter to a product page. Refers to blog post for more info: http://freakdesign.com.au/blogs/news/17335317

Refers to blog post: http://freakdesign.com.au/blogs/news/17335317

First create a new snippet called product-sold-count.liquid. In that file copy and paste the below code:

{% comment %}
  Show current amount sold for a single product (with default variant).
  This assumes that you have created a metafield
{% endcomment %}
@freakdesign
freakdesign / currencies.liquid
Created September 7, 2015 07:30 — forked from carolineschnapp/currencies.liquid
currencies.liquid
{% if settings.show_multiple_currencies %}
{{ "//cdn.shopify.com/s/javascripts/currencies.js" | script_tag }}
{{ "jquery.currencies.min.js" | asset_url | script_tag }}
<script>
Currency.format = '{{ settings.currency_format | default: 'money_with_currency_format' }}';
var shopCurrency = '{{ shop.currency }}';
@freakdesign
freakdesign / new-content-for-header.liquid
Last active October 15, 2021 23:38
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' %}
@freakdesign
freakdesign / shopify-sitelink-search.liquid
Last active February 8, 2018 17:45
Google Sitelinks Search Box for Shopify
@freakdesign
freakdesign / blog-atom.liquid
Last active October 19, 2021 21:48
Shopify RSS atom feed
{% layout none %}{% comment %}
/*
* Simple blog feed
*
* Copyright (c) 2015 Jason Bowman (jason@freakdesign.com.au)
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
*/
{% endcomment %}<?xml version="1.0" encoding="UTF-8"?>