Em destaque

Busque por tema

My Cart
Lista de Desejos
Categorias
document.addEventListener("DOMContentLoaded", async () => { const priceEl = document.querySelector('.woocommerce-Price-amount bdi') || document.querySelector('.price bdi'); if (!priceEl) return; const usdText = priceEl.textContent.replace(/[^\d.,]/g, '').replace(',', '.'); const usd = parseFloat(usdText); if (!usd) return; const res = await fetch(`/wp-json/brazilpays/v1/product-info?amount=${usd}`); const data = await res.json(); if (!data || data.error) return; const exchange = data.exchange?.toFixed(2); const totalBrl = data.totalAmount?.toFixed(2); const pix = data.pix; const installments = data.installments || []; let html = `
💵 R$ ${totalBrl} via BrazilPays
(1 USD = R$ ${exchange})
`; if (pix && pix.grossValue) { html += `
PIX: R$ ${pix.grossValue.toFixed(2)} ${pix.discount ? `(${pix.discount}% off)` : ''}
`; } if (installments.length) { html += `
💳 Parcelamento:
`; } html += `
`; priceEl.insertAdjacentHTML('afterend', html); });