Skip to main content

Widget integrado ao site

Para integrar em seu site o widget de busca, utilizar o código gerado na tela de configuração do Motor:

alt text

Segue exemplo do código - atualize o código com o id da sua página:

<div id="otabuilder-widget">Carregando...</div>
<script>
function loadJS(url, location) {
var scriptTag = document.createElement('script')
scriptTag.src = url
scriptTag.crossOrigin = 'anonymous'
scriptTag.defer = true
scriptTag.async = true
location.appendChild(scriptTag)
}
function initOtabuilderWidget(storefrontId, elementId) {
var _k = '_OTABUILDER_EMBEDDED_SEARCH_INIT_'
var loaded = false
var _i = function (initSearchForm) {
if (!loaded) {
loaded = true
initSearchForm(document.getElementById(elementId), {
storefrontId: storefrontId,
})
}
}
if (window[_k]) {
_i(window[_k])
} else {
const listener = function (e) {
_i(e.detail.initSearchForm)
}
document.addEventListener('otabuilder-search-ready', listener)
}
}

initOtabuilderWidget(
'<INSERIR AQUI O ID DO CADASTRO DO OTABUIDER>' /** storefrontId */,
'otabuilder-widget' /** widget container */
)
loadJS(
'https://app.otabuilder.com/static/js/widget.js' /** widget Js Url */,
document.body /** script tag parent */
)
</script>