Skip to content

Instantly share code, notes, and snippets.

View msmithstubbs's full-sized avatar

Matt Stubbs msmithstubbs

View GitHub Profile
@msmithstubbs
msmithstubbs / variant-images.liquid
Created February 12, 2014 14:29
Match image in the email template to the variant.
{% comment %}
This looks for an image with the same alt text as the variant title.
You can use this if your are matching variants to images using the image ALT text.
{% endcomment %}
{% assign main_image = product.featured_image %}
{% for image in product.images %}
{% if image.alt == variant.title %}
@msmithstubbs
msmithstubbs / product-notify-me.liquid
Last active January 3, 2016 13:39
Catch blank phone field
{% if settings.notify_me_form %}
<div class="notify_form" id="notify-form-{{ product.id }}" {% if product.available %}style="display:none"{% endif %}>
<form action="/contact" method="post" data-first-variant="{{product.variants.first.id}}" id="BIS_form" onsubmit="return createNotification{{product.id}}(this); return false;">
<p>
<label for="contact[email]"><strong>Contact me with stock price and availability:</strong></label>
</p>
<p>
<input required type="phone" name="contact[email]" id="contact[email]" placeholder="EMAIL" value="{{ contact.fields.email }}" style="display:inline;margin-bottom:0px" />
</p>
<p>
@msmithstubbs
msmithstubbs / gist:7895197
Created December 10, 2013 18:09
Ttile from variant dropdowns
var title = $('#productVariants .single-option-selector').map(function() { return $(this).val() }).get().join(' / ');
@msmithstubbs
msmithstubbs / bis-form.liquid
Created November 25, 2013 17:29
Product page form for Radiance theme
<script>
var BISSubmit = function(attr) {
var showResponse = function(data) {
var msg = '';
if (data.status == 'Error') {
for (var k in data.errors) {
msg += data.errors[k].join();
}
} else {
msg = data.message;
@msmithstubbs
msmithstubbs / bis-form.liquid
Last active December 29, 2015 08:09
Adding a Back In Stock form to Symmetry
{% comment %}
/*
* Example code only. This code has not been tested on a live site.
* IMPORTANT: Backup your theme before making any modifications.
*
*/
{% endcomment %}
{% unless product.available %}
<script>
jQuery(document).on('load', function() {
console.log('Message 1');
});
jQuery(document).ready(function() {
console.log('Message 2');
});
@msmithstubbs
msmithstubbs / gist:7525547
Created November 18, 2013 10:11
QuestionTime default styles
@import url(//fonts.googleapis.com/css?family=Open+Sans:700,300);
.QT-container {
overflow: hidden;
padding: 12px;
max-width: 980px;
margin: auto;
line-height: 1.667;
}
.QT-button {
@msmithstubbs
msmithstubbs / gist:7230136
Created October 30, 2013 10:12
Set visibility of the Notify Me button from the template
You can set the button visibility off by including the following config in the template:
<script>
var _BISConfig = { button: { visible: false } };
</script>
This could combined with some Liquid variables to control it for certain situations. For example, if the product is in the Clearance collection then don't show the Notify Me button:
{% for collection in product.collections %}
{
"product": {
"body_html": "\u003Cp\u003EWoddy action figure\u003C/p\u003E",
"created_at": "2013-09-26T07:55:20-04:00",
"handle": "woddy",
"id": 160381129,
"product_type": "Toys",
"published_at": null,
"published_scope": "global",
"template_suffix": null,
var create_callback = function(data) {
var msg = "Hm, there was an error. Sorry!";
if (data.status == 'OK') {
msg = 'Great! Stay tuned!';
} else {
var errors = [];
for(var i in data.errors) {
errors.push(data.errors[i]);
}
msg = errors.join("\n");