Jump to content

Adding Live Chat to Menu


webaura

Recommended Posts

Some help with this one would be greatly appreciated.

 

I am trying to figure out how to use the onclick option for my Live Chat link.

 

I have the following code in my hook:

<?php
#adding Live Chat Menu Item to secondaryNavbar
use WHMCS\View\Menu\Item as MenuItem;
add_hook('ClientAreaSecondaryNavbar', 1, function (MenuItem $secondaryNavbar)
{
   $secondaryNavbar->addChild('Live Chat')
       ->setUri('#chat onclick="toggleChat()"')
       ->setOrder(10);
});

 

I have tried other ways, but can't seem to get the onclick to set. My goal is to have the live chat pop up on click.

Link to comment
Share on other sites

I have this code in header.tpl of my theme:

 

<script type="text/javascript">

function toggleChat() {

Tawk_API.toggle(); return false;

}

</script>

 

 

And this code before secondary-nav is called:

 

<script type="text/javascript">Tawk_API.onStatusChange = function (status){if(status === 'online'){document.getElementById('status').innerHTML = '<a href="#" onclick="toggleChat()">Online - Click to chat</a>';}else if(status === 'away'){document.getElementById('status').innerHTML = 'We are currently away';}else if(status === 'offline'){document.getElementById('status').innerHTML = 'Live chat is Offline';}};
</script>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated