Skip to content

Instantly share code, notes, and snippets.

@maxrice
Last active November 8, 2018 22:33
Show Gist options
  • Save maxrice/41cc44d1361ffaa58737cbb90df9b24a to your computer and use it in GitHub Desktop.
Save maxrice/41cc44d1361ffaa58737cbb90df9b24a to your computer and use it in GitHub Desktop.
Jilt for WooCommerce - watch an email input and automatically set the customer when populated
<?php
add_action( 'init', 'jilt_for_wc_add_custom_email_capture' );
function jilt_for_wc_add_custom_email_capture() {
if ( function_exists( 'wc_enqueue_js' ) ) {
ob_start();
?>
$(window).load(function() {
var opts = {
callback: function (value) {
if ( JiltStorefront.Helpers.isValidEmail( value ) )
{ jilt.setCustomer({email: value }); }
},
wait: 750, highlight: false, allowSubmit: false, captureLength: 6 };
$('input[name="wof-email"]').typeWatch( opts );
});
<?php
wc_enqueue_js( ob_get_clean() );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment