Skip to content

Instantly share code, notes, and snippets.

View gterrill's full-sized avatar

Gavin Terrill gterrill

View GitHub Profile
@gterrill
gterrill / booking-form.snippet.html
Last active May 25, 2018 01:52
Show a return date based on duration.
To show a return date based on duration make the following changes in the booking-form snippet.
1. Add data-bta-update-finish-date="true" to the datepicker:
<div>
{% capture attribute %}booking-start{% endcapture %}
<label for="{{ attribute }}-{{ product.handle }}">Rental Date</label>
<input id="{{ attribute }}-{{ product.handle }}" type="text" name="properties[Date]" size="12"
class="datepicker bta required bta-load-enable bta-dp-start bta-highlight-duration" disabled="disabled"
data-handle="{{ product.handle }}" data-variant="{{ product.selected_or_first_available_variant.id }}"
@gterrill
gterrill / booking-form.snippet.html
Created April 30, 2014 21:18
Group size using booking party (and variant price breaks)
{% comment %}
BookThatApp auto installed snippet. Changes made to this file will be lost if installed again.
{% endcomment %}
{% if product.tags contains 'Booking Party' %}
<label for="booking-party">Number of Participants</label>
<div class="selector-wrapper">
<select id="booking-party" name="properties[booking-party]">
{% for n in (1..30) %}
<option>{{ n }}</option>
@gterrill
gterrill / booking-form.snippet.html
Created May 4, 2014 01:16
Reset button for date range
{% 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 clearfix">
<div class="selector-wrapper">
{% capture attribute %}booking-start{% endcapture %}
<label for="{{ attribute }}">From:</label>
@gterrill
gterrill / file.js
Last active August 29, 2015 14:01
How to validate the booking form
$('form[action*="/cart/add"]').submit(function(e) {
var btaForm = $(this).data('bta.bookingForm');
if ((typeof(btaForm) != "undefined") && !btaForm.isValid()) {
e.stopImmediatePropagation(); // prevents BTA's default form submit handler which also checks for validity
return false;
}
// regular Ajax submit from here...
}
@gterrill
gterrill / calendar.template.html
Created June 3, 2014 20:42
Calendar with images for classes
<div class="span9">
<h1>Art Class Calendar</h1>
<hr />
<em>Sign up for adult classes by clicking the painting on the calendar you would like to come paint.</em>
<div id="bta-calendar"></div>
</div>
<script src="{{ shop.bookthatapp }}/fullcalendar/fullcalendar.js" type="text/javascript"></script>
<script src="{{ shop.bookthatapp }}/javascripts/xdate.js" type="text/javascript"></script>
@gterrill
gterrill / shipping-calculator.liquid
Last active August 29, 2015 14:13
Updated Shipping Calculator
{% unless settings.shipping_calculator == 'Disabled' %}
<div id="shipping-calculator-container" class="clearfix">
<div id="shipping-calculator" class="fl">
<h3>{{ settings.shipping_calculator_heading }}</h3>
<div>
<p>
<label for="address_country">Country</label>
<select id="address_country" name="address[country]" data-default="{% if shop.customer_accounts_enabled and customer %}{{ customer.default_address.country }}{% elsif settings.shipping_calculator_default_country != '' %}{{ settings.shipping_calculator_default_country }}{% endif %}">{{ country_option_tags }}</select>
</p>
<p id="address_province_container" style="display:none;">
@gterrill
gterrill / booking-deposit.liquid
Created January 29, 2015 04:32
Booking Deposit
{% comment %}
Create a linklist called Deposit and link it to your deposit product
{% endcomment %}
{% assign deposit_linklist = linklists.deposit.links %}
{% if deposit_linklist.size > 0 and deposit_linklist.first.type == 'product_link' %}
{% assign deposit_id = deposit_linklist.first.object.variants.first.id %}
{% assign deposit_count = 0 %}
@gterrill
gterrill / calendar.liquid.html
Created February 8, 2015 22:28
Calendar template (including location)
<h3>Events Calendar</h3>
{% if products.size > 1 %}
<p>
<label for="bta-product-select">Product</label>
<select id="bta-product-select">
<option value="">All products</option>
{% for product in products %}
<option value="{{ product.handle }}">{{ product.title }}</option>
{% endfor %}
@gterrill
gterrill / start-only.html
Created February 19, 2015 05:12
Datepicker with option data-startonly='true' attribute
<input id="{{ attribute }}-{{ product.handle }}" type="text" name="properties[{{ attribute }}]" size="12" class="datepicker bta required bta-load-enable" data-handle="{{ product.handle }}" data-variant="{{ product.variants.first.id}}" data-bta-product-config="{{ product.metafields.bookthatapp.config }}" data-bta-variant-config="{% for variant in product.variants %}{{ variant.id }}:{{ variant.metafields.bookthatapp.config }}{% unless forloop.last %},{% endunless %}{% endfor %}" disabled="disabled" data-startonly="true" />
@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;