// Replace the mockOrders array with this fetch logic async function fetchEtsyData() { const workerUrl = "https://small-lab-7f20.lumberandboards.workers.dev/"; // Your Worker URL try { const response = await fetch(workerUrl); const data = await response.json(); const receipts = data.results; // Clear the table and total tableBody.innerHTML = ""; totalNet = 0; receipts.forEach(receipt => { // Find which of your 2 items was sold based on the title const title = receipt.transactions[0].title; let productKey = ""; if (title.includes("Assortment")) productKey = "Hardwood Lumber Assortment"; else if (title.includes("Variety Pack")) productKey = "Hardwood Lumber Variety Pack"; if (productKey) { const price = parseFloat(receipt.grandtotal.amount) / 1000000; const config = productConfigs[productKey]; const fees = (price * 0.095) + 0.25; const net = price - fees - config.shipEst - config.matCost; totalNet += net; // Add row to table... (use same row logic from previous step) } }); document.getElementById('total-profit').innerText = `$${totalNet.toFixed(2)}`; } catch (e) { console.error("Failed to fetch Etsy data:", e); } } fetchEtsyData();