Skip to content

Instantly share code, notes, and snippets.

View msmithstubbs's full-sized avatar

Matt Stubbs msmithstubbs

View GitHub Profile
@msmithstubbs
msmithstubbs / gist:5508127
Last active December 16, 2015 22:39
Custom trigger for testing365
// add a custom trigger to the product.liquid template, right afer the add to cart button. It is hidden by default.
<input type="submit" name="BIS" value="Email me when available" id="BIS_trigger" class="action_button" style="display:none;">
// then in app.js, update the selectCallback to show and hide the Add to car and trigger buttons
if (variant && variant.available == true) {
if(variant.price < variant.compare_at_price){
$('.was_price', $product).html(Shopify.formatMoney(variant.compare_at_price, $('form.product_form', $product).data('money-format')))
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, "${{amount}}") + " <span>was " + Shopify.formatMoney(variant.compare_at_price, "${{amount}}") + "</span>");
} else {
jQuery('#price-preview').html(Shopify.formatMoney(variant.price, "${{amount}}"));
}
jQuery('#BIS_trigger').hide(); // Added for Back In Stock app
#BIS_frame {
width: 100% !important;
position: fixed !important;
left: 0 !important;
top: 0;
}
/*
* Example code only. This code has not been tested on a live site.
* IMPORTANT: Backup your theme before making any modifications.
*
*/
var selectCallback = function(variant, selector) {
if (variant && variant.available == true) {
jQuery('#add-to-cart').removeAttr('disabled'); // remove unavailable class from add-to-cart button, and re-enable button
if(variant.price < variant.compare_at_price){
/*
* Example code only. This code has not been tested on a live site.
* IMPORTANT: Backup your theme before making any modifications.
*
*/
if (variant && variant.available == true) {
if(variant.price < variant.compare_at_price){
$('.was_price', $product).html(Shopify.formatMoney(variant.compare_at_price, $('form', $product).data('money-format')))
// Example code only
// This hasn't been tested on a real site. Please backup your theme before making any changes.
var selectCallback = function(variant, selector) {
if (variant && variant.available) {
jQuery('#add-to-cart').removeAttr('disabled').removeClass('disabled'); // 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, "${{amount}}") + " <del>" + Shopify.formatMoney(variant.compare_at_price, "${{amount}}") + "</del>");
} else {
jQuery('#price-preview').html(Shopify.formatMoney(variant.price, "${{amount}}"));
{% if product.available %}
<style>
#BIS_trigger { display: none; }
</style>
{% endif %}
<script type="text/javascript">
var selectCallback = function(variant, selector) {
if (variant && variant.available == true) {
// selected a valid variant
var selectCallback = function(variant, selector) {
if (variant && variant.available) {
jQuery('#add-to-cart').removeAttr('disabled').removeClass('disabled'); // 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, "{{amount_no_decimals}} &#1088;&#1091;&#1073;.") + " <del>" + Shopify.formatMoney(variant.compare_at_price, "{{amount_no_decimals}} &#1088;&#1091;&#1073;.") + "</del>");
} else {
jQuery('#price-preview').html(Shopify.formatMoney(variant.price, "{{amount_no_decimals}} &#1088;&#1091;&#1073;."));
}
$('#BIS_trigger').hide(); // added for Back In Stock app
} else {
{% if product.available == false %}
<style>
#BIS_trigger { display: block; }
</style>
{% endif %}
jQuery(function() {
// This first bit is just handling the user selecting a variant.
$('.product-information').on('click', '.variant_title', function(e) {
e.preventDefault();
$(this).addClass('selected').siblings().removeClass("selected");
$(this).closest('.product-information').find('#bis_button').toggle($(this).is('.unavailable'));
});
// Then, when the button is clicked...
$('#bis_button').on('click', function(e) {