Last active
November 8, 2018 22:33
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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