How can I link live chat to my menu in Shopify?

Solved

How can I link live chat to my menu in Shopify?

husainshaikh
Shopify Partner
8 0 0

I have installed the Shopify inbox app on my store.

Now I have a menu option in the footer menu that says "Live Chat"

I want the Shopify chat to pop open/expand when a user clicks on that link.

 

What URL should I add for that to happen?

 

Kindly let me know.

Regards

Accepted Solution (1)

AsenWang
Shopify Partner
27 4 3

This is an accepted solution.

1. Add the LiveChat link as shown below

AsenWang_0-1667558505029.png

 

2.  Add the following code at the bottom of theme.liquid

3. Enjoy this code

 

<script>
if (document.readyState !== 'loading') {
	watchFooterLiveChat();
} else {
	document.addEventListener('DOMContentLoaded', watchFooterLiveChat);
}

function watchFooterLiveChat() {
    var chatlink = document.querySelector('#shopify-section-footer a[href="#toggleChat"]')
    chatlink && chatlink.addEventListener('click', toggleLiveChat, false);
}

function toggleLiveChat(e) 
{
    var liveChat = document.querySelector('#ShopifyChat')
    if (liveChat) {
        var fdoc = liveChat.contentWindow.document
        if (fdoc.querySelector('.chat-app--is-open')) {
            fdoc.querySelector('.chat-app--close-button').click()
        } else {
            fdoc.querySelector('.chat-toggle').click()
        }
    } else {
        var iframe = document.querySelector('#dummy-chat-button-iframe')
        iframe && iframe.contentWindow.document.querySelector('button').click()
    }
    e && e.stopPropagation();
    return false;
}
</script>

 

If helpful then please Like and Accept Solution.
Professional shopify developer, wx: shopify-asen

View solution in original post

Replies 2 (2)

AsenWang
Shopify Partner
27 4 3

This is an accepted solution.

1. Add the LiveChat link as shown below

AsenWang_0-1667558505029.png

 

2.  Add the following code at the bottom of theme.liquid

3. Enjoy this code

 

<script>
if (document.readyState !== 'loading') {
	watchFooterLiveChat();
} else {
	document.addEventListener('DOMContentLoaded', watchFooterLiveChat);
}

function watchFooterLiveChat() {
    var chatlink = document.querySelector('#shopify-section-footer a[href="#toggleChat"]')
    chatlink && chatlink.addEventListener('click', toggleLiveChat, false);
}

function toggleLiveChat(e) 
{
    var liveChat = document.querySelector('#ShopifyChat')
    if (liveChat) {
        var fdoc = liveChat.contentWindow.document
        if (fdoc.querySelector('.chat-app--is-open')) {
            fdoc.querySelector('.chat-app--close-button').click()
        } else {
            fdoc.querySelector('.chat-toggle').click()
        }
    } else {
        var iframe = document.querySelector('#dummy-chat-button-iframe')
        iframe && iframe.contentWindow.document.querySelector('button').click()
    }
    e && e.stopPropagation();
    return false;
}
</script>

 

If helpful then please Like and Accept Solution.
Professional shopify developer, wx: shopify-asen
husainshaikh
Shopify Partner
8 0 0

Worked like a charm. Thank you.