Skip to content

Instantly share code, notes, and snippets.

@jb510
Last active June 8, 2019 02:31
Show Gist options
  • Save jb510/3bdc0203fa6f2561f332051a1de0e610 to your computer and use it in GitHub Desktop.
Save jb510/3bdc0203fa6f2561f332051a1de0e610 to your computer and use it in GitHub Desktop.
Jilt Early email capture, front end only
<?php
/**
* Adds listener to Email popup form and send email to Jilt for Cart Recovery
*
* @return void
*/
if ( !is_admin() ) {
add_action(
'init', function() {
// set your input name to watch here
$input = 'EMAIL';
if ( function_exists( 'wc_enqueue_js' ) ) {
$js = 'jQuery(\'input[name="' . $input . '"]\').typeWatch({ callback: function (value) { if ( JiltStorefront.Helpers.isValidEmail( value ) ) { jilt.setCustomer({email: value }); } }, wait: 1250, highlight: false, allowSubmit: false, captureLength: 6 });';
wc_enqueue_js( $js );
}
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment