Skip to content

Instantly share code, notes, and snippets.

View gterrill's full-sized avatar

Gavin Terrill gterrill

View GitHub Profile
# put this in 'serve_file'
if File.exists?("#{template_path}/#{filename}.liquid")
filepath = "#{template_path}/#{filename}.liquid"
else
filepath = "#{template_path}/#{filename}"
end
def zip(theme, location)
begin
FileUtils.mkdir_p(File.dirname(location))
FileUtils.rm(location) if File.exists?(location)
if RUBY_PLATFORM =~ /darwin/
Dir.chdir(THEMES) do
system("zip -r \"#{location}\" #{theme}/ -x \"*.svn*\" -x \"*.git*\"")
<script type="text/javascript">
// <![CDATA[
Forexd.init("{{ shop.currency }}");
jQuery(document).ready(function($) {
$('#site-currency').val(Forexd.currency()).show();
$('#site-currency').change(function() {
Forexd.currency($(this).val()); // save new currency
document.location.href = document.location.href; // reload the page
});
{% comment %}
You can use this snippet to display categories on the front page. Turn on this snippet using theme settings.
{% endcomment %}
{% if linklists.categories.links.size > 0 %}
<div id="products">
{% for link in linklists.categories.links %}
<div class="product {% cycle 'first_col', '', '', 'last_col' %}">
{% assign collection = link.object %}
{% if collection.products.size > 0 %}
@gterrill
gterrill / shopify-money-format.js
Created July 22, 2011 21:59
How to initialize money format with the store currency
<script type="text/javascript">
Shopify.money_format = "{{shop.money_format}}";
</script>
@gterrill
gterrill / subfix.js
Last active October 12, 2015 04:18
Fix for submenus on iOS 6
if (navigator.userAgent.match(/(iPad|iPhone|iPod)/g)) {
$('a.sf-with-ul').each(function() {
$(this).attr('data-clicked', 'false');
$(this).click(function(e) {
if ($(this).attr('data-clicked') === 'false') {
e.preventDefault();
$(this).attr('data-clicked', 'true');
return false;
}
return true;
@gterrill
gterrill / booking-form.liquid
Last active December 11, 2015 16:48
Show upcoming scheduled events in a table.
{% comment %}
BookThatApp auto installed snippet. Changes made to this file will be lost if installed again.
{% endcomment %}
{% if product.metafields.bookthatapp.product_id %}
<table id="events" style="width:100%">
<tr>
<th colspan="4">Upcoming Classes</th>
</tr>
@gterrill
gterrill / bta-onselect.js
Created February 17, 2013 00:39
Do something when a date is selected, preserving BookThatApp's handling for availability purposes
<script type="text/javascript">
bta_callbacks = {};
// invoked after availability data from BookThatApp is loaded via Ajax.
bta_callbacks["loaded"] = function(data) {
var onStartSelect = $('#booking-start').datepicker('option', 'onSelect'),
onFinishSelect = $('#booking-finish').datepicker('option', 'onSelect');
$('#booking-start').datepicker('option', 'onSelect', function(date) {
onStartSelect.call(this, date);
@gterrill
gterrill / gist:5156454
Created March 13, 2013 21:27
Displaying pickup date and time. Time is 12 hour clock.
{% for attribute in attributes %}{{ attribute | first | replace: 'booking-time', 'Time' | replace: 'booking', 'Pickup' }}: {% if attribute.first == 'booking-time' %}{% assign t = attribute.last | split: ':' %}{% assign hour = t[0] | minus:0 %}{% if hour > 12 %}{{ t[0] | minus:12 }}:{{ t[1] }} pm{% else %}{{ t[0] }}:{{ t[1] }} am{% endif %}{% else %}{{ attribute | last }}{% endif %}{% endfor %}
@gterrill
gterrill / gist:5265571
Created March 28, 2013 18:18
Standard Order Notification Template
{{ shop_name }},
{{ billing_address.name }} placed a new order with you today ({{ date | date: "%b %d %I:%M%p" }}).
Payment method:
{{ gateway }}
Delivery method:
{% for shipping_method in shipping_methods %}{{ shipping_method.title }}
{% endfor %}