⏰
EXPIRA EM:
30:00
🔥 Última chance para finalizar seu pedido com desconto!
/* Oculta elementos indesejados */
.mp-pix-approved-container, .mp-pix-approved-card, .mp-pix-approved-header,
.wfty-order-details-heading, .wfty_title, .wfty_pro_list_cont, .wfty_box.wfty_order_details table,
.mp-col-md-4, .mp-details-pix-img, .mp-details-pix-title, .mp-steps-congrats,
p.mp-details-title, p.mp-details-pix-qr-title, p.mp-details-pix-qr-subtitle,
.mp-pix-image-container, .mp-pix-confirmation-container {
display: none !important;
}
/* Layout Flexível */
.mp-row-checkout-pix, .mp-details-pix-container { display: flex !important; flex-direction: column !important; width: 100% !important; }
/* Reordenamento Mobile */
.mp-details-pix-container { order: 1 !important; margin-top: 0 !important; margin-bottom: 5px !important; }
.mp-details-pix-amount {
order: 2 !important;
font-size: 16px !important;
font-weight: 700 !important;
margin-top: 5px !important;
margin-bottom: 2px !important; /* Colado no QR Code */
color: #333 !important;
text-align: center !important;
line-height: 1.2 !important;
}
.mp-details-pix-qr-img {
order: 3 !important;
max-width: 150px !important;
margin: 2px auto 5px auto !important; /* Margens mínimas */
opacity: 0.9;
}
/* Estilos Compactos */
.mp-qr-input { order: 2 !important; width: 100% !important; background: #f8f9fa !important; border: 1px solid #e0e0e0 !important; border-radius: 8px !important; padding: 8px !important; text-align: center !important; font-family: monospace !important; font-size: 11px !important; color: #777 !important; margin-top: 3px !important; height: auto !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-details-pix-button { order: 1 !important; width: 100% !important; background-color: #28a745 !important; color: white !important; font-weight: 800 !important; text-transform: uppercase !important; padding: 12px !important; border-radius: 8px !important; border: none !important; cursor: pointer !important; font-size: 15px !important; margin-bottom: 0 !important; }
.mp-details-pix-button::before { content: "📄 "; margin-right: 5px; }
p.mp-details-pix-qr-description { order: 0 !important; font-size: 0 !important; margin-bottom: 3px !important; text-align: center !important; }
p.mp-details-pix-qr-description::after { content: "👇 Toque no botão abaixo para copiar o código e pague no app do seu banco:"; font-size: 13px !important; display: block !important; line-height: 1.3 !important; color: #555 !important; font-weight: 500 !important; padding: 0 5px; }
/* Zera margens dos pais para colar o cronômetro */
.wfty_box.wfty_order_details { padding: 0 !important; margin: 0 !important; border: none !important; }
#titulo-status, #titulo-status .elementor-widget-container { margin-bottom: 0px !important; padding-bottom: 0 !important; }
.wfty_order_download, .wffn_order_details_table { margin-top: 0px !important; padding-top: 0px !important; }
.joinchat { display: none !important; }
.woocommerce-order-received a.button.download-file { background-color: #28a745 !important; color: white !important; border-radius: 6px !important; padding: 15px !important; font-weight: 800 !important; display: block; margin: 15px auto; text-align: center; text-decoration: none !important; }
document.addEventListener("DOMContentLoaded", function() {
// VARIÁVEIS GLOBAIS
var wrapperTitulo = document.getElementById('titulo-status');
var tituloReal = wrapperTitulo ? wrapperTitulo.querySelector('h1, h2, h3, h4, .elementor-heading-title') : null;
if(!tituloReal) tituloReal = wrapperTitulo;
var cronometro = document.getElementById('cronometro-container');
// --- A. FUNÇÃO DE ALTERAÇÃO VISUAL (Igual a que funcionou pra você) ---
function aplicarSucessoVisual() {
var timerContainer = document.querySelector('#cronometro-container');
if(timerContainer) timerContainer.style.display = 'none';
// Esconde PIX na força bruta
var pixDiv = document.querySelector('.mp-details-pix');
if(pixDiv) pixDiv.style.display = 'none';
localStorage.removeItem('pix_timer_endtime');
if (tituloReal && tituloReal.innerText.indexOf('✅') === -1) {
var textoOriginal = tituloReal.innerText;
var nomeLimpo = "CLIENTE";
if(textoOriginal.includes("Bruno") || textoOriginal.includes("BRUNO")) {
nomeLimpo = "BRUNO";
} else if (textoOriginal.includes(",")) {
var partes = textoOriginal.split(",");
if(partes.length > 1) nomeLimpo = partes[1].replace(/\./g, "").trim().toUpperCase();
}
tituloReal.innerHTML = '✅ PAGAMENTO CONFIRMADO, ' + nomeLimpo + '!';
tituloReal.style.color = "#28a745";
// Cria mensagem se não existir
if(!document.getElementById('msg-sucesso-custom')) {
var containerSucesso = document.createElement("div");
containerSucesso.id = 'msg-sucesso-custom';
containerSucesso.style.display = "block";
containerSucesso.style.width = "100%";
containerSucesso.style.textAlign = "center";
containerSucesso.style.marginTop = "5px";
containerSucesso.style.paddingBottom = "5px";
containerSucesso.style.marginBottom = "5px";
containerSucesso.style.borderBottom = "1px solid #e1e1e1";
containerSucesso.style.clear = "both";
var paragrafoTexto = document.createElement("p");
paragrafoTexto.innerHTML = "A partir de agora nossa equipe iniciará a preparação de seu pedido.
Enviaremos o rastreio de seu pedido por e-mail.";
paragrafoTexto.style.fontSize = "15px";
paragrafoTexto.style.color = "#666";
paragrafoTexto.style.lineHeight = "1.6";
paragrafoTexto.style.margin = "0 0 15px 0";
containerSucesso.appendChild(paragrafoTexto);
var linkDestino = "https://tropicalespeciarias.com.br/";
var textoBotao = "NAVEGAR PELO SITE";
if(linkDestino && textoBotao){
var btnExtra = document.createElement("a");
btnExtra.href = linkDestino;
btnExtra.innerText = textoBotao;
btnExtra.style.display = "inline-block";
btnExtra.style.padding = "14px 25px";
btnExtra.style.border = "2px solid #28a745";
btnExtra.style.borderRadius = "50px";
btnExtra.style.color = "#28a745";
btnExtra.style.textDecoration = "none";
btnExtra.style.fontWeight = "700";
btnExtra.style.fontSize = "13px";
btnExtra.style.letterSpacing = "0.5px";
btnExtra.style.textTransform = "uppercase";
btnExtra.style.transition = "all 0.3s ease";
btnExtra.onmouseover = function() { this.style.backgroundColor = "#28a745"; this.style.color = "#fff"; };
btnExtra.onmouseout = function() { this.style.backgroundColor = "transparent"; this.style.color = "#28a745"; };
containerSucesso.appendChild(btnExtra);
}
wrapperTitulo.parentNode.insertBefore(containerSucesso, wrapperTitulo.nextSibling);
}
}
}
// --- B. LÓGICA DE VERIFICAÇÃO DUPLA (A Melhoria) ---
function checarStatusGeral() {
var orderId = 0;
// 1. Tenta pegar ID do JS do Mercado Pago
if(typeof wc_mercadopago_pix_pooling_params !== 'undefined') {
orderId = wc_mercadopago_pix_pooling_params.order_id;
}
// 2. Se não achou, tenta pegar da URL (Para quando dá F5)
if(!orderId) {
var match = window.location.href.match(/order-received\/(\d+)/);
if(match) orderId = match[1];
}
// Se tiver ID, pergunta ao PHP (Resolve atualização manual)
if(orderId) {
var data = new FormData();
data.append('action', 'checar_status_real_tuca');
data.append('order_id', orderId);
fetch('/wp-admin/admin-ajax.php', { method: 'POST', body: data })
.then(res => res.json())
.then(response => {
if(response.success && response.data.status === 'pago') {
aplicarSucessoVisual(); // SUCESSO DO PHP
}
}).catch(e => {});
}
// Também pergunta ao Mercado Pago (Para atualização automática rápida)
if (typeof wc_mercadopago_pix_pooling_params !== 'undefined') {
var params = wc_mercadopago_pix_pooling_params;
var url = params.ajax_url + '?action=mp_pix_payment_status&order_id=' + params.order_id + '&nonce=' + params.nonce + '&t=' + Date.now();
fetch(url)
.then(response => response.json())
.then(data => {
if (data && (data.status === 'approved' || data.status === 'authorized')) {
aplicarSucessoVisual(); // SUCESSO DO MP
}
}).catch(e => {});
}
}
// --- C. INICIALIZAÇÃO ---
// 1. Ajuste Título Inicial
if (tituloReal && tituloReal.innerText.indexOf('✅') === -1) {
var textoOriginal = tituloReal.innerText;
var nomeFormatado = "";
if (textoOriginal.includes(",")) {
var partes = textoOriginal.split(",");
if (partes.length > 1) {
var nomeSujo = partes[1].replace(/\./g, "").trim();
var nomeLimpo = nomeSujo.charAt(0).toUpperCase() + nomeSujo.slice(1).toLowerCase();
nomeFormatado = ", " + nomeLimpo;
}
}
tituloReal.innerHTML = '📄 Finalize seu pagamento via Pix' + nomeFormatado;
}
// 2. Teleporte Cronômetro
if (cronometro && wrapperTitulo) {
wrapperTitulo.parentNode.insertBefore(cronometro, wrapperTitulo.nextSibling);
}
// 3. Verifica se tem PIX na tela
var pixPendente = document.querySelector('.mp-details-pix') || document.querySelector('.mp-qr-input');
// Se tiver PIX pendente visualmente, inicia lógica
if (pixPendente) {
if(cronometro) cronometro.style.display = 'block';
iniciarCronometro();
setInterval(checarStatusGeral, 5000); // Roda a cada 5s
// Roda uma vez imediatamente para corrigir F5
checarStatusGeral();
} else {
// Se carregou sem PIX, aplica visual de sucesso direto
aplicarSucessoVisual();
}
// 4. Timer Logic
function iniciarCronometro() {
var duration = 30 * 60;
var display = document.querySelector('#time-display');
var timerBox = document.querySelector('#timer-box');
var expiredMsg = document.querySelector('#timer-expired-msg');
var savedEndTime = localStorage.getItem('pix_timer_endtime');
var now = Math.floor(Date.now() / 1000);
var endTime;
if (savedEndTime && savedEndTime > now) {
endTime = parseInt(savedEndTime);
} else {
endTime = now + duration;
localStorage.setItem('pix_timer_endtime', endTime);
}
var interval = setInterval(function () {
if(document.getElementById('msg-sucesso-custom')) { clearInterval(interval); return; }
var currentTime = Math.floor(Date.now() / 1000);
var remaining = endTime - currentTime;
if (remaining <= 0) {
clearInterval(interval);
if(timerBox) timerBox.style.display = 'none';
if(expiredMsg) expiredMsg.style.display = 'inline-block';
return;
}
var minutes = Math.floor(remaining / 60);
var seconds = remaining % 60;
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds {
if (el.innerHTML.indexOf('Entrega em') !== -1 && el.innerHTML.indexOf('Receba em') === -1) {
el.innerHTML = el.innerHTML.replace(/Entrega em/gi, 'Receba em até');
}
});
}, 500);
// ─── A. FEEDBACK VISUAL PÓS-CÓPIA ───────────────────────────────
var btnPix = document.querySelector('.mp-details-pix-button');
if (btnPix) {
// Injeta estilo para suprimir ::before durante o feedback
var styleTag = document.createElement('style');
styleTag.id = 'tuca-btn-feedback-style';
styleTag.textContent = '.mp-details-pix-button.copiado::before { content: "" !important; margin: 0 !important; }';
document.head.appendChild(styleTag);
btnPix.addEventListener('click', function () {
var original = btnPix.innerHTML;
btnPix.classList.add('copiado');
btnPix.style.backgroundColor = '#1a7a32';
btnPix.innerHTML = '✅ CÓDIGO COPIADO! Abra seu app do banco e cole o código PIX';
btnPix.style.fontSize = '13px';
setTimeout(function () {
btnPix.classList.remove('copiado');
btnPix.style.backgroundColor = '#28a745';
btnPix.innerHTML = original;
btnPix.style.fontSize = '';
}, 4000);
});
}
// ─── B. PASSOS COMPACTOS ACIMA DO BOTÃO ─────────────────────────
var containerPix = document.querySelector('.mp-col-md-8.mp-pix-right');
if (containerPix && !document.getElementById('tuca-pix-steps')) {
var steps = document.createElement('div');
steps.id = 'tuca-pix-steps';
steps.style.cssText = 'display:flex;justify-content:center;gap:6px;margin:8px 0 6px;flex-wrap:wrap;';
steps.innerHTML =
'
1️⃣ Abra o app do banco' +
'
2️⃣ Escolha pagar por PIX' +
'
3️⃣ Cole o código copiado';
var pixContainer = containerPix.querySelector('.mp-details-pix-container');
if (pixContainer) {
containerPix.insertBefore(steps, pixContainer);
} else {
containerPix.insertBefore(steps, containerPix.firstChild);
}
}
});