Skip to content

Instantly share code, notes, and snippets.

@JamieS
JamieS / Shopify Blog Display a Collection in a Blog
Created August 25, 2010 11:51
Shopify Blog Display a collection in a blog
<div class="article">
<h2 class="article-title">{{ article.title }}</h2>
<p class="article-details">posted <span class="article-time">{{ article.published_at | date: "%Y %h" }}</span> by <span class="article-author">{{ article.author }}</span></p>
<div class="article-body textile">
{{ article.content }}
{% if article.title == 'Our New merchandise' %}
<ul>
{% for product in collections.new-merchandise.products limit:3 %}
<li>
<div class="feature-product">
@carolineschnapp
carolineschnapp / gist:1003334
Created June 1, 2011 21:10
Related Products using metafields - to add to product.liquid
<!-- Solution brought to you by Caroline Schnapp -->
<!-- See this: http://wiki.shopify.com/Related_Products -->
{% assign image_size = 'compact' %}
{% assign heading = 'Other fine products' %}
{% if product.metafields.recommendations.productHandles %}
<h3>{{ heading }}</h3>
<ul class="related-products"></ul>
@bdunlap
bdunlap / resend-webhook.php
Created September 7, 2011 15:26
Given a Shopify order ID, pulls the order JSON from Shopify API and resends the order to an arbitrary webhook URL.
<?php
$settings = array(
'store-domain' => 'YOUR SHOPIFY DOMAIN HERE',
'api-key' => 'YOUR API KEY HERE',
'api-secret' => 'YOUR API SECRET HERE',
'webhook-url' => 'YOUR WEBHOOK URL HERE, INCLUDING "KEY" PARAMETER IF APPLICABLE',
);
ini_set('display_errors', 'On');
error_reporting(-1);
@jmc734
jmc734 / MassDiscount.php
Created August 12, 2012 01:19
Shopify Batch Discount Automation (Create, Enable/Disable, Delete)
<?php
/**
* Discount
*
* Create, modify, and delete Shopify discounts
*
* PHP version 5
*
* @author Jacob McDonald <jmc734@gmail.com>
*/
@paulhhowells
paulhhowells / Theme Bean Block & Display Suite Combo.php
Last active April 6, 2017 20:36
Enable bean blocks to be themed (using a .tpl file) according to bean-type: i.e. block__bean__BEAN-TYPE.tpl
Enable bean blocks to be themed (using a .tpl file) according to bean-type:
i.e. block__bean__BEAN-TYPE.tpl
Why? Combine a Bean Block with Display Suite and the innards of the block will match the DS layout
used, however the outer wrapping of the block must be themed separately. However if you write a
.tpl that matches the block it will take precedence and the DS layout will be lost. This prevents
using a DS layout for each type of Bean while simultaneously having full control over the Bean
Block’s mark-up.
This solution adds a theme hook suggestion so that .tpl files may be written for each type of Bean.
@r10r
r10r / enable_dnsmasq_on_osx.sh
Last active October 11, 2019 04:27
Installs and configures dnsmasq on osx (for local resolution of development machines e.g virtualbox). Cudos to Alan Ivey http://www.echoditto.com/blog/never-touch-your-local-etchosts-file-os-x-again
# ----------------------
# installing dnsmasq and enable daemon
# ----------------------
brew install dnsmasq
sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
# ----------------------
# adding resolver for vbox domain
# ----------------------
[ -d /etc/resolver ] || sudo mkdir -v /etc/resolver
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/vbox'
@gterrill
gterrill / delivery.liquid.html
Created May 20, 2013 20:16
Add a variant to the cart dynamically depending on what is in the cart.
{{ 'api.jquery.js' | shopify_asset_url | script_tag }}
<script type="text/javascript">
var variant = 231075270, // delivery item
count = 0, existing = 0, cart = {{ cart | json }};
var returnToCart = function(line_item) {
window.location.href = '/cart';
};
@behrendtio
behrendtio / gist:5779239
Last active December 18, 2015 11:59
Shopify explanation

VAT: 20%

Price including VAT: 35 €

Price excluding VAT: 29.17 €

Calculating incl. VAT using {{ price | times: 1.2 | money }}

  • for 1 item: 35 € ==> correct
  • for 2 items: 70.01 € ==> incorrect
@zakhardage
zakhardage / Much much simpler option selector for Shopify
Last active July 8, 2022 09:50
Much simpler version of Shopify's option_selection.js for separating product options into their own dropdown menus.
<form action="/cart/add" method="post">
{% if product.variants.size > 1 %}
{% if product.options[0] %}
{% assign used = '' %}
<label for="select-one">{{ product.options[0] }}</label>
<select id='select-one' onchange="letsDoThis()">
{% for variant in product.variants %}
{% unless used contains variant.option1 %}
<option value="{{ variant.option1 }}">{{ variant.option1 }}</option>
{% capture used %}{{ used }} {{ variant.option1 }}{% endcapture %}
@stephsharp
stephsharp / README.md
Last active August 19, 2021 14:50
Sample code for Stack Overflow question about using radio buttons for Shopify variants (http://stackoverflow.com/questions/19085276/shopify-variants)