Skip to content

Instantly share code, notes, and snippets.

View msmithstubbs's full-sized avatar

Matt Stubbs msmithstubbs

View GitHub Profile
@msmithstubbs
msmithstubbs / gist:4469055
Created January 6, 2013 18:03
Back In Stock integration for http://www.babeetalk.com/
<script>
var create_callback = function(data) {
if (data.status == 'OK')
{ alert(data.message) }
else {
var msg = [];
for (var i in data.errors) {
msg.push(data.errors[i]);
}
alert(msg.join("\n"));
@msmithstubbs
msmithstubbs / gist:4509078
Last active December 10, 2015 23:28
Back In Stock example for Eric Smith
/*
* Example code only
* This code has not been tested on a live site
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE * WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
@msmithstubbs
msmithstubbs / gist:4560461
Last active December 11, 2015 06:38
Custom integration
/*
* Example code only
* This code has not been tested on a live site
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE * WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
@msmithstubbs
msmithstubbs / gist:4660146
Last active June 6, 2017 06:09
Show a 'Notify me' button, and hide the 'Add' button.
<!-- Updating the product.liquid HTML to have a hidden Notify Me button -->
<!-- START BUY -->
<div id="buy" class="clear">
<h2 id="price"><span>$135.00</span></h2>
<input class="button" type="submit" id="add" value="Buy Now" />
<a href="#" id="notifyme">Notify when available</a>
</div>
<!-- END BUY -->
<a href="#" id="BIS_trigger">Notify me when available!</a>
{% if product.available %}
<style>#BIS_trigger { display: none; }</style>
{% endif %}
var selectCallback = function(variant, selector) {
if (variant && variant.available == true) {
// selected a valid variant
jQuery('#add-to-cart').removeClass('disabled').removeAttr('disabled').val('Add to Cart'); // remove unavailable class from add-to-cart button, and re-enable button
if(variant.price < variant.compare_at_price){
jQuery('#price-preview').html(Shopify.formatMoney(variant.price) + " <span>was " + Shopify.formatMoney(variant.compare_at_price) + "</span>");
} else {
jQuery('#price-preview').html(Shopify.formatMoney(variant.price));
}
jQuery('#BIS_trigger').hide(); // This line added for Back In Stock app
@msmithstubbs
msmithstubbs / gist:5295706
Last active December 15, 2015 17:19
Finding the variant id from the hidden dropdown
$(document).ready(function() {
$('#notify_button').click(function(event) {
event.preventDefault();
BISPopover.create($('#notify_email').val(), $('#product-select :selected').val());
});
});
var selectCallback = function(variant, selector) {
if (variant && variant.available == true) {
// selected a valid variant
$('#productinfo #detail #purchase').removeClass('disabled').removeAttr('disabled'); // remove unavailable class from add-to-cart button, and re-enable button
var newHtml = Shopify.formatMoney(variant.price, "");
if(variant.compare_at_price > variant.price) {
newHtml += '<div class="was-price">was ' + Shopify.formatMoney(variant.compare_at_price, "") + '</div>';
}
$('#price-field').html(newHtml); // update price field
<script>
$(function() {
$('.notify_form [type=submit]').click(function(e) {
e.preventDefault();
var variantId = $('select[name=id]').val() || {{ product.variants.first.id }};
var email = $(this).closest('form').find('[name="contact[email]"]').val();
var showResponse = function(text) {
var create_callback = function(data) {
if (data.status == 'OK') {
$("#inline_message").html('<h3>Thanks</h3> <p>You will receive an email once the item is available.</p>');
} else {
$("#inline_message").html('<h3>Oops! Looks like an error occurred.</h3> <p>Please check the email address you entered and try again.</p>');
}
$.fancybox({
'href': '#inline_message'
});