Skip to content

Instantly share code, notes, and snippets.

View gterrill's full-sized avatar

Gavin Terrill gterrill

View GitHub Profile
@gterrill
gterrill / bundle-sync.liquid
Last active August 28, 2019 05:45
Bundle Sync
{% 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 }}' || '[]'),
{% 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 February 13, 2018 00:24
Make quantity read only for the Empire theme
{% 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 December 17, 2020 20:55
Order Notification email with conditional content based on product
{% 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 December 6, 2018 09:56
Script to show products as out of stock if a bundled component is out of stock
{% 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 June 22, 2017 00:01
Hide duration variant option
// ============ 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 15:10
Notes on setting up a Rails App on Opsworks Stacks using Chef 12
@gterrill
gterrill / collection.classes.liquid
Created April 26, 2017 05:23
Display events using list view
{%- 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 February 25, 2017 01:20
Request Store Access via Shopify Partner Dashboard using Mechanize
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 January 13, 2017 18:16
Initialize the booking form when add to cart form is dynamically loaded by fancybox
// 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