From 88e65290e12a1145cc20135f3e89eefcd83b58e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Tue, 29 Sep 2026 10:40:55 -0300 Subject: [PATCH] fix: quote freight on its own, and drop the Calcular button Going back to home delivery with a CEP already typed, or restoring a saved cart, now quotes the freight again by itself; before, only pressing Calcular did. With every case covered, the button is gone. Co-Authored-By: Claude Opus 5.5 --- web/cart.js | 3 ++- web/index.html | 3 +-- web/site-flow.js | 14 ++------------ 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/web/cart.js b/web/cart.js index 0409a7c..f335ca9 100644 --- a/web/cart.js +++ b/web/cart.js @@ -32,13 +32,14 @@ if(saved && !pedido.length && !itemAtual){ pedido=saved.items;cliente=saved.customer;entrega=saved.delivery; // Freight must be quoted again; restored browser values are never final. - if(entrega.tipo==='frete'){entrega.cotado=false;entrega.valor=0;} + if(entrega.tipo==='frete'){entrega.cotado=false;entrega.valor=0;entrega.dias=null;} for(const [id,key] of [['fCnpj','cnpj'],['fZap','zap'],['fMail','mail']])$(id).value=cliente[key]; $('cepIn').value=fmtCep(entrega.cep); entrega.end=entrega.end||{}; for(const [id,key] of [['eNome','nome'],['eRua','rua'],['eNum','num'],['eComp','comp'], ['eBairro','bairro'],['eCidade','cidade'],['eUf','uf']])$(id).value=entrega.end[key]||''; $('atual').style.display='none';pintaEntrega(); + if(entrega.tipo==='frete' && entrega.cep.length===8 && window.dtfFreight) window.dtfFreight(); notice.textContent='Carrinho recuperado. Remova e adicione novamente um item se precisar alterar sua montagem.'; }else{ const account=await window.dtfApi('/account/me'); diff --git a/web/index.html b/web/index.html index 683c054..1d20403 100644 --- a/web/index.html +++ b/web/index.html @@ -1170,8 +1170,7 @@ footer a:hover{color:var(--laranja2)}
- - +

diff --git a/web/site-flow.js b/web/site-flow.js index 911e2e3..6140cb1 100644 --- a/web/site-flow.js +++ b/web/site-flow.js @@ -157,6 +157,8 @@ document.querySelectorAll('.opE').forEach(b=>b.addEventListener('click',()=>{ entrega.valor=0; if(entrega.tipo==='frete') $('cepMsg').innerHTML=''; pintaEntrega(); + // A CEP already typed is quoted again as soon as delivery is chosen. + if(entrega.tipo==='frete' && entrega.cep.length===8 && window.dtfFreight) window.dtfFreight(); })); function fmtCep(v){ v=String(v||'').replace(/\D/g,'').slice(0,8); return v.length>5 ? v.slice(0,5)+'-'+v.slice(5) : v; } // The address of a complete CEP fills the form; only the number is left to type. @@ -192,18 +194,6 @@ for(const [id,chave] of [['eNome','nome'],['eRua','rua'],['eNum','num'],['eComp' pintaEntrega(); }); } -$('bCep').addEventListener('click',async()=>{ - if(entrega.cep.length!==8){ $('cepMsg').innerHTML='CEP incompleto.'; return; } - buscaEndereco(entrega.cep); - if(window.dtfFreight){ await window.dtfFreight(); return; } - // A cotação vem da transportadora. Enquanto a integração não existir, o pedido não - // fecha por frete: o valor precisa estar fechado antes do Mercado Pago. - $('cepMsg').innerHTML='Cotação de frete ainda não integrada.
'+ - 'O valor precisa vir da transportadora antes do pagamento — senão você pagaria um '+ - 'total que não é o final. Por enquanto, retire em Franca ou fale conosco no WhatsApp.'; - pintaEntrega(); -}); - $('bMais').addEventListener('click',()=>{ if(guardaItem()) vaiPara('/#envio'); }); $('bPagar').addEventListener('click',()=>{