Skip to content

Instantly share code, notes, and snippets.

View gterrill's full-sized avatar

Gavin Terrill gterrill

View GitHub Profile
@gterrill
gterrill / ticket.html.liquid
Created September 25, 2015 23:07
Ticket template using location
<h1>Ticket</h1>
<p>
Name: {{ booking.name }}</br>
Date: {{ booking.start | date: "%m/%d/%Y" }}
</p>
<h3>Booking Details:</h3>
<ul>
{% for item in booking.items %}
@gterrill
gterrill / reminder.html.liquid
Last active June 25, 2019 10:56
Reminder template using location
<p>Hi {{ booking.name }},</p>
<p>This is a reminder from {{ shop.name }} about your upcoming booking on {{ booking.start | date: "%m/%d/%Y" }}.</p>
<h3>Your booking:</h3>
<ul>
{% for item in booking.items %}
<li>
{{ item.quantity }} x {{ item.product.title }} on {{ booking.start | date: "%m/%d/%Y %-I:%M %p" }}
</li>
{% endfor %}
</ul>
@gterrill
gterrill / bundled.v3.js.liquid
Last active August 29, 2015 14:25
bundled.v3.js.liquid
<script>
bundles = [];
{% for variant in product.variants %}{% if variant.metafields.sva.bundled %}
bundles['{{ variant.id }}'] = jQuery.parseJSON('{{ variant.metafields.sva.bundled }}');
{% endif %}{% endfor %}
var process = function (target, results) {
var deferred = $.Deferred();
$.ajax({
@gterrill
gterrill / booking-guard.liquid
Last active October 18, 2017 03:47
Display a message if the product is already in the cart
{% comment %}
Checks if the product is already in the cart and if
so hides the booking form and displays a message.
Install Instructions:
1. Create a new snippet called 'booking-guard' and paste this code.
2. Include this new snippet in the existing booking-form snippet, and set the initial style of the booking form
@gterrill
gterrill / jquery-ui-datepicker-table.css
Created July 2, 2015 05:06
Fix up table styles for jQuery UI Datepicker
/* BookThatApp Customization */
.ui-datepicker table {font-size: .9em; margin-bottom: inherit;}
.ui-datepicker table tr th {font-weight:bold; background: initial; text-align:center; padding: .7em .3em !important; border: 0;}
.ui-datepicker table tr td {font-weight:bold; background: initial; text-align:center; border: 0;}
@media only screen and (max-width: 767px) {
.ui-datepicker tr {
display: table-row;
}
@gterrill
gterrill / booking-form.liquid
Created June 4, 2015 02:55
Disable add to cart on product page if product already in the cart
{% comment %}
BookThatApp auto installed snippet. Changes made to this file will be lost if installed again.
{% endcomment %}
{% if product.metafields.bookthatapp.config %}
{% unless bta_configured %}
<div class="booking-form">
<p id="bta-loading" class="loading">Loading availability...</p>
<div id="variant-in-cart" style="display:none">
@gterrill
gterrill / ajax-cart.js.liquid
Last active October 14, 2015 05:14
Timber theme ajax JS updated to work with BTA
/*============================================================================
Ajax the add to cart experience by revealing it in a side drawer
Plugin Documentation - http://shopify.github.io/Timber/#ajax-cart
(c) Copyright 2015 Shopify Inc. Author: Carson Shold (@cshold). All Rights Reserved.
This file includes:
- Basic Shopify Ajax API calls
- Ajax cart plugin
This requires:
@gterrill
gterrill / ajax-cart-template-bta.liquid
Last active August 29, 2015 14:20
Timber theme modified cart template to work with BTA
<!-- /snippets/ajax-cart-template.liquid -->
{% comment %}
This snippet provides the default handlebars.js templates for
the ajax cart plugin. Use the raw liquid tags to keep the
handlebar.js template tags as available hooks.
{% endcomment %}
<script id="CartTemplate" type="text/template">
{% raw %}
@gterrill
gterrill / shopify_api_ext.rb
Last active August 29, 2015 14:20
Example of monkey patching the ShopifyAPI gem
module ShopifyAPI
class Product
def prices
variants.collect(&:price).collect(&:to_f)
end
def price_min
prices.min
end
@gterrill
gterrill / gist:06ddc5839cfa5c10107f
Last active August 29, 2015 14:20
Upcoming events list embedded in a regular page
{% capture bta_url %}{{ shop.permanent_domain | split: '.' | first }}.bookthatapp.com{% endcapture %}
{% assign product_ids = "" %}{% for product in collections.events.products %}{% capture product_ids %}{{ product_ids }}{% unless forloop.first %},{% endunless %}{{ product.id }}{% endcapture %}{% endfor %}
<script src="//{{ bta_url }}/fullcalendar2/lib/moment.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
var today = moment(),
btacal = {
load: function() {
if ($('#events').length == 0) return;