';
});
itens.innerHTML = html;
document.getElementById('hivahSubtotalVal').textContent = self.fmt(total);
var btn = document.getElementById('hivahBtnFinalizar');
btn.href = 'https://www.hivahoficial.com.br/checkout?session_id=' + cart.session() + '&store_id=' + cart.idStore();
self.updateFrete(total);
self.loadCompreJunto(ids, urls);
},
updateFrete: function(total) {
var falta = Math.max(0, this.META - total);
var pct = Math.min(100, (total / this.META) * 100);
document.getElementById('hivahFreteFill').style.width = pct + '%';
document.getElementById('hivahFreteLabel').innerHTML = falta === 0
? '\uD83C\uDF89 Voc\u00EA ganhou FRETE GR\u00C1TIS!'
: 'Faltam ' + this.fmt(falta) + ' para FRETE GR\u00C1TIS';
},
_extrairDadosProduto: function($el, ids) {
var id = $el.find('form.list-variants').data('id');
if (!id || ids.indexOf(parseInt(id)) !== -1) return null;
var $priceOff = $el.find('.price-off').first();
var $priceBox = $el.find('.box-price, .price').first();
var precoPromo = $priceOff.length ? $priceOff.text().trim().match(/R\$\s*[\d.,]+/) : null;
var precoCheio = $priceBox.text().trim().match(/R\$\s*[\d.,]+/);
var temDesconto = precoPromo && precoCheio && precoPromo[0] !== precoCheio[0];
var imgEl = $el.find('img.swiper-lazy, img').first();
return {
id: id,
nome: $el.find('a.hivah-wpp-vitrine').data('wppNome'),
url: $el.find('a.hivah-wpp-vitrine').data('wppLink'),
img: imgEl.attr('data-src') || imgEl.attr('src') || '',
preco: precoPromo ? precoPromo[0] : (precoCheio ? precoCheio[0] : ''),
precoOriginal: temDesconto ? precoCheio[0] : null
};
},
_extrairRelacionados: function(html, ids) {
var self = this;
var doc = jQuery('
').html(html);
var prods = [], vistos = {};
doc.find('.showcase.list-slide .product').each(function() {
var id = jQuery(this).find('form.list-variants').data('id');
if (!id || vistos[id]) return;
vistos[id] = true;
var dado = self._extrairDadosProduto(jQuery(this), ids);
if (dado) prods.push(dado);
});
return prods;
},
_renderCJ: function(prods) {
if (!prods.length) {
var cj = document.getElementById('hivahCompreJunto');
cj.style.display = 'none';
cj.classList.remove('visivel');
return;
}
var html = '';
prods.slice(0, 4).forEach(function(pr) {
html += '
' +
'
' + (pr.img ? '' : '') + '
' +
'
' +
'
' + pr.nome + '
' +
'
' +
(pr.precoOriginal ? '
' + pr.precoOriginal + '
' : '') +
'
' + pr.preco + '
' +
'
' +
'' +
'
';
});
var cj = document.getElementById('hivahCompreJunto');
document.getElementById('hivahCjScroll').innerHTML = html;
cj.style.display = 'block';
setTimeout(function() { cj.classList.add('visivel'); }, 30);
},
loadCompreJunto: function(ids, urls) {
if (!ids.length) {
var cj = document.getElementById('hivahCompreJunto');
cj.style.display = 'none';
cj.classList.remove('visivel');
return;
}
var self = this;
var listaPagos = (self._lastList || []).filter(function(i) {
return parseFloat(i.Cart.price) > 0;
});
var refItem = listaPagos.length ? listaPagos[listaPagos.length - 1] : self._lastList[self._lastList.length - 1];
var refId = parseInt(refItem.Cart.product_id);
var refUrl = urls[refId];
if (jQuery('html').hasClass('page-product')) {
var domProds = [], vistos = {};
jQuery('.showcase.list-slide .product').each(function() {
var id = jQuery(this).find('form.list-variants').data('id');
if (!id || vistos[id]) return;
vistos[id] = true;
var dado = self._extrairDadosProduto(jQuery(this), ids);
if (dado) domProds.push(dado);
});
if (domProds.length) { self._renderCJ(domProds); return; }
}
if (self._cjCache && (self._cjCache.id === refId || (refUrl && self._cjCache.url === refUrl))) {
var cached = self._cjCache.prods.filter(function(p) {
return ids.indexOf(parseInt(p.id)) === -1;
});
if (cached.length) { self._renderCJ(cached); return; }
}
if (refUrl) {
jQuery.get(refUrl, function(html) {
var prods = self._extrairRelacionados(html, ids);
self._cjCache = { id: refId, url: refUrl, prods: prods };
if (prods.length) { self._renderCJ(prods); return; }
self._fallbackCategoria(ids);
}).fail(function() { self._fallbackCategoria(ids); });
return;
}
self._fallbackCategoria(ids);
},
_fallbackCategoria: function(ids) {
var self = this;
var listaPagos = (self._lastList || []).filter(function(i) {
return parseFloat(i.Cart.price) > 0;
});
var refItem = listaPagos.length ? listaPagos[listaPagos.length - 1] : self._lastList[self._lastList.length - 1];
var refId = parseInt(refItem.Cart.product_id);
jQuery.ajax({
method: 'GET', url: '/web_api/products/' + refId,
success: function(r) {
var prod = r && r.Product ? r.Product : null;
if (!prod) {
var cj = document.getElementById('hivahCompreJunto');
cj.style.display = 'none'; cj.classList.remove('visivel'); return;
}
jQuery.ajax({
method: 'GET', url: '/web_api/products?category_id=' + prod.category_id + '&limit=8&available=1',
success: function(r2) {
var prods = r2 && r2.Products ? r2.Products : [];
var sugs = prods.filter(function(p) { return ids.indexOf(parseInt(p.Product.id)) === -1; }).slice(0, 4);
if (!sugs.length) {
var cj = document.getElementById('hivahCompreJunto');
cj.style.display = 'none'; cj.classList.remove('visivel'); return;
}
var domProds = sugs.map(function(p) {
var pr = p.Product;
var thumbs = pr.ProductImage && pr.ProductImage[0] && pr.ProductImage[0].thumbs ? pr.ProductImage[0].thumbs : null;
var precoPromo = pr.promotional_price && parseFloat(pr.promotional_price) > 0 ? parseFloat(pr.promotional_price) : null;
var precoCheio = parseFloat(pr.price);
return {
id: pr.id,
nome: pr.name,
url: pr.url ? pr.url.https : '',
img: thumbs ? (thumbs['180'] ? thumbs['180'].https : (thumbs['90'] ? thumbs['90'].https : '')) : '',
preco: self.fmt(precoPromo || precoCheio),
precoOriginal: (precoPromo && precoPromo !== precoCheio) ? self.fmt(precoCheio) : null
};
});
self._renderCJ(domProds);
},
error: function() {
var cj = document.getElementById('hivahCompreJunto');
cj.style.display = 'none'; cj.classList.remove('visivel');
}
});
},
error: function() {
var cj = document.getElementById('hivahCompreJunto');
cj.style.display = 'none'; cj.classList.remove('visivel');
}
});
},
addCJ: function(productId, variantId, href, btn) {
btn.textContent = 'Adicionando...';
btn.disabled = true;
cart.addToCart(productId, 1, variantId, href, 1);
var self = this;
setTimeout(function() { self.reload(); }, 800);
},
changeQty: function(idx, delta, productId, variantId, addInfo, boughtTogetherId) {
var self = this;
var qtdEl = document.querySelectorAll('.hivah-qty-num')[idx];
if (!qtdEl) { self.reload(); return; }
var novaQtd = (parseInt(qtdEl.textContent) || 1) + delta;
if (novaQtd <= 0) {
self.removeItem(productId, variantId, addInfo, boughtTogetherId); // <-- passa boughtTogetherId
return;
}
var variant = parseInt(variantId) === 0 ? '' : '/' + variantId;
var addText = addInfo ? '/?additional_information=' + addInfo.replace(/br>/g, 'br/>') : '';
jQuery.ajax({
method: 'DELETE', url: '/web_api/carts/' + cart.session() + '/' + productId + variant + addText,
success: function() {
cart.loadCustomerId();
jQuery.ajax({
method: 'POST', url: '/web_api/cart/', dataType: 'json',
data: { Cart: { session_id: cart.session(), product_id: productId, variant_id: variantId || 0, quantity: novaQtd }},
success: function() { self.reload(); }, error: function() { self.reload(); }
});
},
error: function() { self.reload(); }
});
},
removeItem: function(productId, variantId, addInfo, boughtTogetherId) {
var self = this;
var vid = parseInt(variantId) === 0 ? 0 : variantId;
var addText = addInfo ? 'additional_information=' + addInfo.replace(/br>/g, 'br/>') : '';
var btid = boughtTogetherId && parseInt(boughtTogetherId) !== 0;
var url;
if (btid) {
url = '/web_api/carts/' + cart.session() + '/' + productId + '/' + (vid || 0) + '/' + boughtTogetherId;
if (addText) url += '?' + addText;
} else {
url = '/web_api/carts/' + cart.session() + '/' + productId;
if (vid) url += '/' + vid;
if (addText) url += '/?' + addText;
}
jQuery.ajax({
method: 'DELETE', url: url,
success: function() { self.reload(); }, error: function() { self.reload(); }
});
}
};
function hivahWppCarrinho() {
var session = jQuery('html').attr('data-session');
var storeId = jQuery('html').attr('data-store');
var itens = '', total = 0;
document.querySelectorAll('.hivah-cart-item').forEach(function(el) {
var nome = el.querySelector('.hivah-cart-item-name');
var preco = el.querySelector('.hivah-cart-item-price');
var qty = el.querySelector('.hivah-qty-num');
if (!nome || !preco || !qty) return;
var qtyNum = parseInt(qty.textContent) || 1;
var precoUnit = preco.textContent.replace('R$ ', '').replace(',', '.');
itens += '* ' + nome.textContent + ' (x' + qtyNum + ') - R$ ' + (parseFloat(precoUnit) * qtyNum).toFixed(2).replace('.', ',') + '\n';
total += parseFloat(precoUnit) * qtyNum;
});
if (!itens) return;
var checkoutUrl = 'https://www.hivahoficial.com.br/checkout?session_id=' + session + '&store_id=' + storeId;
var msg = 'Ola! Gostaria de finalizar minha compra pelo WhatsApp\n\n' + itens + '\nTotal: R$ ' + total.toFixed(2).replace('.', ',') + '\n\nLink para finalizar: ' + checkoutUrl;
location.href = 'https://wa.me/5521981978217?text=' + encodeURIComponent(msg);
}
function hivahInitListeners() {
if (typeof jQuery === 'undefined') { setTimeout(hivahInitListeners, 50); return; }
jQuery('.cart-header').off('click').on('click', function(e) { e.preventDefault(); e.stopPropagation(); hivahDrawer.open(); });
jQuery('.shadow-cart').off('click').on('click', function(e) { e.stopPropagation(); hivahDrawer.close(); });
jQuery('#hivahOverlay').off('click').on('click', function(e) { e.stopPropagation(); hivahDrawer.close(); });
}
hivahInitListeners();
Ao acessar ou realizar um cadastro em nosso site, você concorda com os termos abaixo. Prezamos por transparência, segurança e respeito em cada etapa da sua experiência com a Hivah.
Utilizamos protocolos de segurança para proteger seus dados e garantir um ambiente confiável.
Como medida antifraude, poderemos:
Confirmar dados do pedido
Validar titularidade do pagamento
Solicitar documentação complementar
Reservamo-nos o direito de cancelar pedidos com indícios de fraude ou inconsistência.
⚠️ Importante: Nunca solicitamos senha ou código de segurança (CVV) do cartão.
✧ 4. LGPD – Proteção de Dados
Tratamos seus dados pessoais conforme a Lei Geral de Proteção de Dados (Lei nº 13.709/2018).
Coletamos apenas informações necessárias para:
Processar pedidos
Realizar entregas
Emitir notas fiscais
Prestar atendimento
Enviar comunicações autorizadas
Seus dados não são vendidos ou compartilhados indevidamente.
Você pode, a qualquer momento:
Solicitar acesso aos seus dados
Corrigir informações
Solicitar exclusão do cadastro
Basta entrar em contato pelo nosso canal oficial de atendimento.
✧ 5. Comunicação
Ao se cadastrar, você concorda em receber comunicações sobre pedidos, novidades e lançamentos.
O cancelamento pode ser feito a qualquer momento pelo link disponível nos e-mails ou na área "Minha Conta".
✧ 6. Propriedade Intelectual
Todo o conteúdo do site é de propriedade da Hivah.
É proibida a reprodução, uso indevido da marca ou qualquer ação que comprometa a integridade da operação online.
✧ 7. Descrição dos Produtos
As descrições e imagens são elaboradas com precisão.
Podem ocorrer variações de cor conforme configuração de tela.
Caso o produto não esteja conforme descrito, você poderá solicitar devolução em até 7 dias corridos após o recebimento, conforme nossa Política de Troca e Devolução.
✧ 8. Preços e Estoque
Trabalhamos com estoque limitado.
A inclusão no carrinho não garante reserva
A reserva ocorre apenas após aprovação do pagamento
Preços podem ser alterados sem aviso prévio
⚠️ Cupons e cashbacks não são cumulativos e não se aplicam à categoria OFF. Produtos em promoção não são trocados, exceto por defeito de fabricação.
Nosso compromisso é proteger seus dados e oferecer uma experiência segura, transparente e alinhada aos valores da Hivah 🤎