Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
I have a contact us button on my website that needs to open the Shopify inbox chat box when the user clicks the button. Is it possible to do this ?
By Clicking Open Shopify Inbox Chat
<a class="site-nav__link site-nav__link--icon" href="{{ request.path | append: "/?chat" }}" > Open Chat Box</a>
Did you figure out how to do this? Thanks!
<a class="site-nav__link site-nav__link--icon" href="{{ request.path | append: "/?show_chat" }}" > Open Chat Box</a>
Try this it will work because Shopify inbox updates its handle form /?chat to /?show_chat.
Unfortunately, it did not work for us.
<a class="site-nav__link site-nav__link--icon" href="{{ request.path | append: "/?chat" }}" > Open Chat Box</a>
Try this it will work because Shopify inbox updates its handle form /?show_chat to /?chat.
Hi Noman01, what this link does is refresh the page and then open the chat box. Is there a way to prevent the refresh and simply just open the chat box?
Thank you for taking the time to respond and help.
Hi, @samthk
yes you can use the following code : <a href="/?chat"> Contact US </a>
or you can add /?chat this to your link in the navigation.
Hi Muhammed, this is a great solution! It works, but instead of simply opening up the chat window, this link bounces the user to the homepage and then opens the chat window. Do you know how to open the chat window without redirecting or refreshing the page?
@greenvalleycode <a class="site-nav__link site-nav__link--icon" href="#" onclick="openChatBox(event)">Open Chat Box</a>
<script>
function openChatBox(event) {
event.preventDefault(); // Prevent the default link behavior
// Logic to open your chat box goes here, for example:
// document.querySelector('.chat-box').style.display = 'block';
// Update the URL without refreshing the page
const currentPath = window.location.pathname;
history.pushState(null, null, `${currentPath}/?chat`);
}
</script> try this