Skip to content

Instantly share code, notes, and snippets.

@msmithstubbs
Created November 25, 2013 17:29
Show Gist options
  • Select an option

  • Save msmithstubbs/7645100 to your computer and use it in GitHub Desktop.

Select an option

Save msmithstubbs/7645100 to your computer and use it in GitHub Desktop.
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;
}
alert(msg);
},
variantId = $('[name=id]').val();
if (BISPopover) {
BISPopover.create(BIS.$('#bis-email', attr.form).value, variantId)
.then(showResponse);
}
},
variantId = function() { $('[name=id]').val(); };
$(function() {
$('.variants').on('change', 'select', function(e) {
var variantId = $('[name=id]').val();
if (typeof BISPopover != 'undefined' && BISPopover._variantsById[variantId]) {
$('.bis-form').toggle(BISPopover._variantsById[variantId].inventory_quantity < 1);
}
});
});
</script>
<style>
.bis-form {
clear: both;
margin: 1em 0;
{% if product.available %}
display: none;
{% endif %}
}
</style>
<form class="bis-form" onsubmit="BISSubmit({ form: this }); return false;">
<p>Enter your email address to receive a notification when this is available to order.</p>
<input type="email" id="bis-email" name="email" class="search-input" value="" placeholder="Email address">
<input class="btn" type="submit" name="bis-notify" value="Notify Me">
</form>
@msmithstubbs
Copy link
Author

  1. Before anything else, make a backup of your theme.
  2. Create a new snippet in your Radiance theme called bis-form.liquid
  3. Copy the contents of the above file into the snippet and hit save.
  4. In your product.liquid theme find the closing div for #product-header (around line 50), and add the following line
{% include 'bis-form' %}

It should look like this:

  1. Hit save on the product.liquid template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment