Skip to content

Instantly share code, notes, and snippets.

@msmithstubbs
Created August 2, 2014 10:02
Show Gist options
  • Select an option

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

Select an option

Save msmithstubbs/091478c914ef16a5e734 to your computer and use it in GitHub Desktop.
Accepts marketing checkbox with inline form
$('#bis-submit').on('click', function(e) {
e.preventDefault();
var email = $('#bis_email').val(),
variant = $('.size-handle.options li.hovered').data('variant'),
productId = BISPopover.product.id,
options = {
accepts_marketing: $('#notify_opt_in').is(':checked')
};
BISPopover.create(email, variant, productId, options).then(function(response) {
if (response.status == 'OK') {
$('.BIS_error').hide();
$('.BIS_response').show();
$('#nbody').hide();
} else {
// show error message...
$('.BIS_response').hide();
$('.BIS_error').html(response.errors.email[0]).show();
}
});
});
@msmithstubbs
Copy link
Author

This assumes you have a checkbox with the correct id:


<input type="checkbox" id="notify_opt_in" value="1">
<label for="notify_opt_in">Add me to the newsletter</label

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