Skip to content

Instantly share code, notes, and snippets.

@JarrydLong
Last active August 24, 2017 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JarrydLong/7041b064300d5f55ff410200277f3c57 to your computer and use it in GitHub Desktop.
Save JarrydLong/7041b064300d5f55ff410200277f3c57 to your computer and use it in GitHub Desktop.
Render a popup on the page. Choose weather to open or close the chat from the popup.
jQuery(document).ready(function(){
var popup_string = "<div class='wplc_custom_popup'>";
popup_string = popup_string + "<p>Can we help you?</p>";
popup_string = popup_string + "<button class='custom_popup_open_chat'>Yes</button>";
popup_string = popup_string + "<button class='custom_popup_close_chat'>No</button>";
popup_string = popup_string + "</div>";
var show_popup = Cookies.get( 'wplc_chat_popup_window' );
if( typeof show_popup === 'undefined' ){
jQuery("body").append(popup_string);
}
jQuery("body").on("click", ".custom_popup_open_chat", function(){
console.log('Opening the chat');
jQuery("#wp-live-chat-header").click();
jQuery(".wplc_custom_popup").css('display','none')
});
jQuery("body").on("click", ".custom_popup_close_chat", function(){
console.log('Closing the chat');
jQuery(".wplc_custom_popup").css('display','none');
Cookies.set('wplc_chat_popup_window', 1, { expires: 1, path: '/' });
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment