Chat app shopify

I’ve posted relevant solution earlier, but the code was lost due to forum migration.

So, reposting:

Here is what you can do without any theme code edits.

Add a new link to your menu, call it Chat and make it point to #chat (address is important).

Then add a “Custom liquid” section into your Footer section group and paste this code:

<script>
document.addEventListener('click', e=> {
  let target = e.target.closest('[href$="#chat"]');
  if (target) {
    e.stopImmediatePropagation();
    e.preventDefault();
    let chat = document.querySelector('inbox-online-store-chat');
    if (!chat) return;
    let buttonSelector = chat.getAttribute('is-open') == 'true' ? ".chat-app--close-button" : ".chat-toggle";
    chat.shadowRoot.querySelector(buttonSelector)?.dispatchEvent(new Event('click'));
    return false;
  }
});
</script>
<style>
  inbox-online-store-chat#ShopifyChat[is-open="false"] {
    transform: translateX(-100vw);
  }
</style>

The code will listen to click on any link not only menu, so you can output your own button somewhere…


And here is the preview link: BBK Market