Skip to content

Instantly share code, notes, and snippets.

View msmithstubbs's full-sized avatar

Matt Stubbs msmithstubbs

View GitHub Profile
@msmithstubbs
msmithstubbs / back-in-stock.liquid
Created June 5, 2014 12:55
Back In Stock form for Shopify React theme
<style>
#BIS_form { margin-top: 20px; }
#BIS_form .btn { height: 34px; line-height: 34px; }
.BIS_response { min-height: 1em; }
</style>
<form id="BIS_form" class="clearfix" data-first-variant="{{product.variants.first.id}}" id="BIS_form" onsubmit="return BISCreateNotification{{product.id}}(this); return false;" {% if product.available %}style="display:none"{% endif %}>
<p><strong>Notify me when this product is available</strong></p>
<p>
<input type="email" class="text" name="email">
@msmithstubbs
msmithstubbs / gist:eef0f991e095021a3316
Created June 2, 2014 09:25
Add a Notify Me button to the product page when at least one variant is sold out.
{% assign show_button = false %}
{% for variant in product.variants %}
{% if variant.available == false %}
{% assign show_button = true %}
{% endif %}
{% endfor %}
{% if show_button %}
<img src="{{ 'notify_me.png' | asset_url }}" id="BIS_trigger">
{% endif %}
@msmithstubbs
msmithstubbs / gist:11247189
Created April 24, 2014 08:56
BIS conversion tracking
if (window.location.toString().match(/bis_id/)) {
function getJsonFromUrl() {
var query = location.search.substr(1);
var data = query.split("&");
var result = {};
for(var i=0; i<data.length; i++) {
var item = data[i].split("=");
result[item[0]] = item[1];
}
return result;
@msmithstubbs
msmithstubbs / button.html
Created April 16, 2014 13:47
Add Back In Stock button to the product page for the Shopify Timber theme
<input type="submit" name="add" class="btn" id="addToCart" value="Add to Cart">
<input type="button" name="bis" class="btn-secondary" id="BIS_trigger" value="Email when available">
@msmithstubbs
msmithstubbs / keys.txt
Created April 14, 2014 16:12
Environemnt bootstrap
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2WCRvFexNsG1TDZvf4jOFxSC1ZFQuZCr3Suu3dYBZ5Ao7G6cKNHvz2l+FwbOWLlnEspywLpk2bbTRHUOM2AKLJ5JmSlrLZXf49TAs64JooLPl9X5gMsetXpasv7DJpl516UbtAbfY7AlQGzYkj+tCuelF5s8H25XUMfz/2/IFUk8OdND5FHLUJ0FUPk1A2iy3CiQ3irmO3Jw48cm6qKVUaDOhmVavGHuzg7C4psTI2X9Mi2kmwyu7CiK2E8RbNhK7razj4yaHsqyrMflWbonhU0WT+jjSJk/taWUkDM+5Yv7m8emcAA1J+daWiIkTNpPPVDDrkReoIzW0lqgDY+KLw== matt@shiraz.lan
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDNb6mkpmDRDffOecoswXbFYA4Gq/iyCgd9eDsVznzgh3f/Hd5f3MIoh88NbLqI75vUuqr7gNmkRRmnon0clxTmKAZUrtnGeyTbvnrRkvNfp5F0xbZb7RiJkKz1D/mtT6QpUEFWHpKrbYwPW4EM+psJ31RleUHwi64Q2rzucelIBaNTYv2PPtA2yHIv4+J7uwGX0ZCLgcBCalDXwmVnjxZcFGgqkadTYVTfygNOvG9SN89BijVmnX0hifyfDBJBCb1wmjuC+/b48wL2hLXsC5W+Wcafv7llzlmhHjoy61Lt4//Z6yJTMelGZ9l4sroCgBV9b6CkOjOaeIOeEyfDawv1 matt@macbook-pro.lan
@msmithstubbs
msmithstubbs / gist:10281884
Created April 9, 2014 15:15
Hide the Back In Stock Notify Me button on mobile devices.
@media only screen and (max-width: 320px) {
body > div#BIS_trigger { display: none !important; }
}
@msmithstubbs
msmithstubbs / bis-notify-me-js.liquid
Last active August 29, 2015 13:57
Back In Stock Inline for for Symmetry theme
<script>
/* Back In Stock app */
$(function() {
function createNotification(e) {
var $productContainer = $(e.target).closest('div[data-product-id], #main-product-detail'),
productId = $(e.target).data('product-id'),
email = $productContainer.find('[name=BIS_email]').val(),
variantId;
@msmithstubbs
msmithstubbs / gist:9617039
Last active August 29, 2015 13:57
Update form label with variant title
$(function() {
$(document).on('change', '.single-option-selector', function() {
var label = $('.notify_form label[for^=contact]');
if (label.is(':visible')) {
var title = $('.single-option-selector').map(function() { return $(this).val() }).get().join(' ');
label.text("Notify me when the " + title + " are in stock");
}
});
@msmithstubbs
msmithstubbs / gist:9546263
Last active August 29, 2015 13:57
Show button for a single collection
{% for collection in product.collections %} {% if collection.handle == 'spring-summer-14' %} <script> _BISConfig = { button: { visible: true } }; </script> {% endif %} {% endfor %}
@msmithstubbs
msmithstubbs / form
Created March 14, 2014 09:03
Example of Back In Stock form with MailChimp checkbox
<label>Email me when available</label>
<input type="email" id="notify_email" />
<input type="checkbox" id="notify_opt_in" value="Yes" /> Opt-in in for
email newsletter
<button id="notify_button">Email when available</button>
<script>
var notificationCallback = function(data) {
var msg = '';
if (data.status == 'OK') {