import wixData from 'wix-data'; let skip = 0; const limit = 9; let isLoading = false; $w.onReady(() => { loadMoreProducts(); // OPTIONAL: If using button for load more // $w("#loadMore").onClick(() => { // loadMoreProducts(); // }); // Auto scroll trigger $w("#repeater1").onViewportEnter(() => { loadMoreProducts(); }); }); function loadMoreProducts() { if (isLoading) return; isLoading = true; wixData.query("Products") .skip(skip) .limit(limit) .find() .then((results) => { if (results.items.length > 0) { const newItems = results.items; const currentItems = $w("#repeater1").data || []; $w("#repeater1").data = [...currentItems, ...newItems]; skip += limit; } else { // No more products $w("#loadMore").hide(); // if using button } isLoading = false; }); }
Auto-loaded via Endless Scroll
`; container.appendChild(card); if (productIndex % 10 === 0) { const adBlock = document.createElement("div"); adBlock.className = "adsense-slot my-4"; adBlock.innerHTML = ``; container.appendChild(adBlock); if (window.adsbygoogle) window.adsbygoogle.push({}); } } } window.addEventListener("scroll", () => { if (window.innerHeight + window.scrollY >= document.body.offsetHeight - 500) { loadProducts(); } }); document.addEventListener("DOMContentLoaded", () => { loadProducts(); }); /*************************************************** * MASTER UNIFIED VELO SNIPPET * Sites: MetroNeeds.in | ModuLyfe.in | PalmSpringsLakeResort.in * Features: Analytics, Affiliate, UPI, AI, PWA, Lexilexi, StoreHippo ***************************************************/ // ---------------- CONFIG ---------------- const CONFIG = { googleAnalyticsId: "G-XXXXXXXXXX", // GA4 ID metaPixelId: "META-PIXEL-ID", // Meta Pixel ID amazonAffiliateId: "metroneeds-21", // Affiliate ID upiId: "yourupi@upi", // UPI ID lexilexiSiteId: "YOUR_LEXILEXI_SITE_ID", // Lexilexi widget/site key perplexityApiKey: "PERPLEXITY_API_KEY", // Perplexity API key metroSheet: "https://docs.google.com/spreadsheets/d/e/YOUR_METRONEEDS_SHEET/pub?output=csv", moduSheet: "https://docs.google.com/spreadsheets/d/e/YOUR_MODULYFE_SHEET/pub?output=csv", storeHippoEnterpriseUrl: "https://www.storehippo.com/en/page/enterprise-platinum" }; // ---------------- UTILITY ---------------- function buildAffiliateLink(url) { return url.includes("tag=") ? url : `${url}${url.includes("?") ? "&" : "?"}tag=${CONFIG.amazonAffiliateId}`; } // ---------------- ANALYTICS ---------------- (function(){ // GA4 const ga = document.createElement("script"); ga.async = true; ga.src = `https://www.googletagmanager.com/gtag/js?id=${CONFIG.googleAnalyticsId}`; document.head.appendChild(ga); window.dataLayer = window.dataLayer || []; function gtag(){ dataLayer.push(arguments); } window.gtag = gtag; gtag("js", new Date()); gtag("config", CONFIG.googleAnalyticsId); // Meta Pixel !(function(f,b,e,v,n,t,s){ if (f.fbq) return; n = f.fbq = function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)}; if (!f._fbq) f._fbq = n; n.push = n; n.loaded = !0; n.version = "2.0"; n.queue = []; t = b.createElement(e); t.async = !0; t.src = v; s = b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t, s); })(window, document, "script", "https://connect.facebook.net/en_US/fbevents.js"); fbq("init", CONFIG.metaPixelId); fbq("track", "PageView"); })(); // ---------------- ON READY ---------------- $w.onReady(() => { cleanupLegacy(); initSiteFunctions(); injectEnterprisePlatinum(); registerPWA(); injectLexilexi(); }); // ---------------- CLEANUP ---------------- function cleanupLegacy() { document.querySelectorAll("script[data-legacy-snippet]").forEach(el => el.remove()); } // ---------------- SITE LOGIC ---------------- function initSiteFunctions() { const base = wixLocation.baseUrl; if (base.includes("metroneeds.in")) { loadProducts(CONFIG.metroSheet, "#productRepeater"); } else if (base.includes("modulyfe.in")) { loadProducts(CONFIG.moduSheet, "#moduRepeater"); } else if (base.includes("palmspringslakeresort.in")) { initResortBooking(); initHotelSearchAI(); } } // ---------------- PRODUCT LOADING ---------------- async function loadProducts(sheetUrl, repeaterId) { try { const resp = await fetch(sheetUrl); const txt = await resp.text(); const rows = txt.split("\n").slice(1); const items = rows.map(r => { const [title, price, img, url] = r.split(","); return { title, price, img, url }; }); if ($w(repeaterId)) { $w(repeaterId).data = items; $w(repeaterId).onItemReady(($item, itemData) => { $item("#title").text = itemData.title; $item("#price").text = `₹${itemData.price}`; $item("#image").src = itemData.img; $item("#buyNow").link = buildAffiliateLink(itemData.url); }); } } catch (e) { console.error("Product load error:", e); } } // ---------------- PALMSPRINGS BOOKING ---------------- function initResortBooking() { if ($w("#bookNowBtn")) { $w("#bookNowBtn").onClick(() => { wixLocation.to(`https://wa.me/919834193149?text=Booking%20Inquiry`); }); } } // ---------------- PALMSPRINGS AI ---------------- function initHotelSearchAI() { if ($w("#hotelSearchBox") && $w("#hotelResults")) { $w("#hotelSearchBtn").onClick(async () => { const query = $w("#hotelSearchBox").value; try { const res = await fetch("https://api.perplexity.ai/search", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${CONFIG.perplexityApiKey}` }, body: JSON.stringify({ query }) }); const data = await res.json(); $w("#hotelResults").text = data?.answer || "No results found."; } catch (err) { console.error("AI search error:", err); $w("#hotelResults").text = "Error retrieving hotel info."; } }); } } // ---------------- STOREHIPPO CALLOUT ---------------- function injectEnterprisePlatinum() { const container = $w("#enterprisePlatinumSection"); if (!container) return; container.html = `Scale your eCommerce with StoreHippo’s Enterprise Platinum infrastructure.
Learn more at StoreHippo →