How to add web chat only for shopping and checkout

We are extending the header.view for it will not affect the indexing issue of the website.

 _.extend(HeaderView.prototype, {
                getContext: _.wrap(HeaderView.prototype.getContext, function(fn) {
                    var originalRet = fn.apply(this, _.toArray(arguments).slice(1));
                    if(SC.CONFIGURATION.Webchat){
                        if (JSON.stringify(new XMLSerializer().serializeToString(document)).indexOf('https://contact.goto.com/web-chat/widget.min.js') === -1) {
                            jQuery('body').append(jQuery(`<script type="text/javascript"> (function(e){var t="https://contact.goto.com/web-chat/widget.min.js";window["CC_WEB_CHAT_APP_KEY"]=e;var n=function e(){var n;var a=document.createElement("script");a.type="text/javascript";a.async=true;a.src=t;var r=document.getElementsByTagName("script")[0];(n=r.parentNode)===null||n===void 0?void 0:n.insertBefore(a,r)};if(document.readyState==="complete"){n()}else{window.addEventListener("load",n,false)}})("e6390505-8fa4-4591-82d7-43eb93fe4998"); </script>`));
                        }
                    }
                    return originalRet;
                })
            });

To add a checkbox for enabling and disabling the checkbox.

{
    "type": "object",
    "subtab": {
        "id": "webchat",
        "group": "extensions",
        "title": "Web Chat",
        "description": "Webchat Enable checkbox"
    },
    "properties": {
        "Webchat": {
            "group": "extensions",
            "subtab": "webchat",
            "type": "boolean",
            "title": "Web Chat",
            "description": "Webchat Enable checkbox",
            "default": true
        }
    }
}

Leave a comment

Your email address will not be published. Required fields are marked *