Skip to content

Instantly share code, notes, and snippets.

Avatar

Gavin Terrill gterrill

View GitHub Profile
View bundle-sync.liquid
{% comment %}
Products Assistant code used to figure out if components are sold out:
https://gist.github.com/gterrill/6e6bac607961139d52f9f5276e34b450
{% endcomment %}
{% if template contains 'product' %}
<script>
window.bundleSync = {
bundleMatrix: JSON.parse('{{ product.metafields.sva.bundle_matrix }}' || '[]'),
View cart-booking-form.liquid
{% assign delivery_product = all_products['delivery'] %}
<div class="cart-booking-form">
<div>
<label for="booking">Please enter the date for your order:</label>
<input id="booking" type="text" name="attributes[Date]"
value="{{ cart.attributes["Date"] }}"
data-bta-product-config="{{ delivery_product.metafields.bookthatapp.config }}"
data-duration="30"
class="datepicker bta bta-dp-start required bta-load-enable" size="12" autocomplete="off"
@gterrill
gterrill / static-cart-extra.liquid
Created Feb 13, 2018
Make quantity read only for the Empire theme
View static-cart-extra.liquid
{% if has_items %}
<script>
document.addEventListener("DOMContentLoaded", function(event) {
{% for item in cart.items %}
$('.cart-item--quantity:nth-child({{ forloop.index }})')
.empty()
.append({{ item.quantity }})
.append('<input type="hidden" value="{{ item.quantity }}" name="updates[]" id="updates_{{ item.key }}">');
{% endfor %}
});
@gterrill
gterrill / order-notification.liquid
Last active Jul 28, 2017
Order Notification email with conditional content based on product
View order-notification.liquid
{% if line.variant.title != 'Default Title' %}
<span class="order-list__item-variant">{{ line.variant.title }}</span>
{% endif %}
{% for p in line.properties %}
<br/><span class="order-list__item-variant">{{ p.first }}: {{ p.last }}</span>
{% endfor %}
{% if line.product.tags contains 'foo' %}
{% comment %} Special content for any product tagged 'Foo' goes here (e.g. location) {% comment %}
@gterrill
gterrill / bundled.v5.liquid
Last active Dec 6, 2018
Script to show products as out of stock if a bundled component is out of stock
View bundled.v5.liquid
{% comment %}
This is used to figure out if components are sold out.
Please see https://gist.github.com/gterrill/b77f0352982991bd1c748d0ab2b42b45 for more info
{% endcomment %}
<script>
var bundleInfo = '{{ product.metafields.sva.bundle }}', bundle,
bundles = [];
@gterrill
gterrill / booking-form.liquid
Last active Jun 22, 2017
Hide duration variant option
View booking-form.liquid
// ============ Booking Form Snippet =============
{% if product.metafields.bookthatapp.config %}
<div class="booking-form">
<div>
{% capture attribute %}booking-start{% endcapture %}
<label for="{{ attribute }}-{{ product.handle }}">From:</label>
<input id="{{ attribute }}-{{ product.handle }}" type="text" name="properties[From]" size="12" class="datepicker bta required bta-load-enable bta-dp-start" disabled="disabled"
data-handle="{{ product.handle }}" data-variant="{{ product.selected_or_first_available_variant.id }}"
data-bta-product-config="{{ product.metafields.bookthatapp.config }}"
@gterrill
gterrill / gist:50ba52076f1ef3b2d3a85f7c9146c503
Last active May 30, 2018
Notes on setting up a Rails App on Opsworks Stacks using Chef 12
View gist:50ba52076f1ef3b2d3a85f7c9146c503
@gterrill
gterrill / collection.classes.liquid
Created Apr 26, 2017
Display events using list view
View collection.classes.liquid
{%- paginate collection.products by settings.pagination_limit -%}
{%- assign product_ids = "" -%}
{%- for product in collection.products -%}
{%- capture product_ids -%}{{ product_ids }}{%- unless forloop.first -%},{%- endunless -%}{{ product.id }}{%- endcapture -%}
{%- endfor -%}
<div id="content">
<div class="container">
{% include 'breadcrumb' %}
@gterrill
gterrill / request_store_access.rb
Last active Feb 25, 2017
Request Store Access via Shopify Partner Dashboard using Mechanize
View request_store_access.rb
require 'rubygems'
require 'mechanize'
STORE = 'foo.myshopify.com'
a = Mechanize.new
# login
a.get('https://app.shopify.com/services/partners/auth/login') do |page|
page.form_with(action: '/services/partners/auth/login') do |form|
@gterrill
gterrill / theme.js.liquid
Created Jan 13, 2017
Initialize the booking form when add to cart form is dynamically loaded by fancybox
View theme.js.liquid
// Call Fancybox for product modal + stop scroll to top
$('.product-modal').fancybox({
ajax: {
complete: function(jqXHR, textStatus) {
new bta.BookingForm(jQ("form[action^='/cart/add']").not('.bta-active'));
}
},
helpers: {
overlay: {
locked: false
You can’t perform that action at this time.