top of page
bottom of page
import wixData from 'wix-data'; let allProducts = []; let categories = []; $w.onReady(async function () { console.log("Loading products..."); await loadProducts(); console.log("✓ Products loaded:", allProducts.length); console.log("✓ Categories:", categories); // Wait for custom element to be ready $w('#quoteCalculator').onReady(() => { console.log("Custom element ready, building calculator..."); buildCalculator(); }); }); async function loadProducts() { try { const results = await wixData.query("Prices") .limit(1000) .find(); allProducts = results.items.map(item => ({ _id: item._id, category: item.Category, title: item.Product, price: item.Price, vat: item.VAT, factor: item.Factor })); categories = [...new Set(allProducts.map(p => p.category))]; } catch (error) { console.error("✗ Error:", error); } } function buildCalculator() { const customElement = $w('#quoteCalculator'); // Set HTML content customElement.setAttribute('innerHTML', `
Subtotal (Net): 0.00 €
VAT 7%: 0.00 €
VAT 19%: 0.00 €
Total VAT: 0.00 €
TOTAL (Gross): 0.00 €
`); }