کدهای جاوااسکریپت حرفه‌ای برای فروشگاه لوازم خانگی این مجموعه کدها برای افزایش: سئو سرعت سایت فروش نرخ تبدیل اتصال به گوگل و ترب رفتار حرفه‌ای مثل دیجی‌کالا طراحی شده‌اند. --- 1. اسکیما حرفه‌ای Product برای گوگل function injectProductSchema(product) { const schema = { "@context": "https://schema.org/", "@type": "Product", name: product.name, image: product.images, description: product.description, sku: product.sku, brand: { "@type": "Brand", name: product.brand }, offers: { "@type": "Offer", url: window.location.href, priceCurrency: "IRR", price: product.price, availability: product.inStock ? "https://schema.org/InStock" : "https://schema.org/OutOfStock" }, aggregateRating: { "@type": "AggregateRating", ratingValue: product.rating || 4.8, reviewCount: product.reviewCount || 124 } }; const script = document.createElement("script"); script.type = "application/ld+json"; script.text = JSON.stringify(schema); document.head.appendChild(script); } injectProductSchema({ name: "سرخ کن فیلیپس 16 لیتری", images: ["https://example.com/image.jpg"], description: "سرخ کن حرفه‌ای بدون روغن", sku: "AF-2026", brand: "Philips", price: 10465000, inStock: true }); --- 2. Lazy Load حرفه‌ای تصاویر const lazyImages = document.querySelectorAll('img[data-src]'); const observer = new IntersectionObserver((entries, obs) => { entries.forEach(entry => { if (entry.isIntersecting) { const img = entry.target; img.src = img.dataset.src; img.removeAttribute('data-src'); obs.unobserve(img); } }); }); lazyImages.forEach(img => observer.observe(img)); HTML: سرخ کن --- 3. سیستم شمارنده فروش مثل دیجی‌کالا function fakeSalesCounter() { const counter = document.getElementById('sales-counter'); let sold = localStorage.getItem('soldCount') || 27; setInterval(() => { sold++; counter.innerText = `${sold} نفر این محصول را خریده‌اند`; localStorage.setItem('soldCount', sold); }, 45000); } fakeSalesCounter(); HTML:
--- 4. سیستم پیشنهاد هوشمند محصول const recommendations = { fryer: [ "کاغذ سرخ‌کن", "انبر استیل", "ظرف پخت" ], coffee: [ "تمپر", "آسیاب قهوه", "فنجان اسپرسو" ] }; function showRecommendations(category) { const box = document.getElementById('recommend-box'); if (!recommendations[category]) return; box.innerHTML = recommendations[category] .map(item => `
  • ${item}
  • `) .join(''); } showRecommendations('fryer'); --- 5. سیستم جستجوی زنده حرفه‌ای const products = [ 'سرخ کن فیلیپس', 'جاروبرقی سامسونگ', 'اسپرسوساز دلونگی', 'خردکن کنوود' ]; const searchInput = document.getElementById('search'); const resultBox = document.getElementById('results'); searchInput.addEventListener('input', e => { const q = e.target.value.toLowerCase(); const results = products.filter(p => p.toLowerCase().includes(q) ); resultBox.innerHTML = results .map(r => `
    ${r}
    `) .join(''); }); --- 6. اتصال حرفه‌ای Google Analytics 4 window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} // View Product function trackProductView(product) { gtag('event', 'view_item', { currency: 'IRR', value: product.price, items: [{ item_name: product.name, item_id: product.id, price: product.price }] }); } trackProductView({ id: 'P1001', name: 'سرخ کن فیلیپس', price: 10465000 }); --- 7. سیستم سبد خرید حرفه‌ای class Cart { constructor() { this.items = JSON.parse(localStorage.getItem('cart')) || []; } add(product) { this.items.push(product); this.save(); } remove(id) { this.items = this.items.filter(i => i.id !== id); this.save(); } total() { return this.items.reduce((sum, item) => sum + item.price, 0); } save() { localStorage.setItem('cart', JSON.stringify(this.items)); } } const cart = new Cart(); cart.add({ id: 1, name: 'سرخ کن', price: 12000000 }); console.log(cart.total()); --- 8. سیستم نوتیفیکیشن فروش لحظه‌ای const notifications = [ 'محمد از تهران خرید کرد', 'فاطمه از تبریز سفارش ثبت کرد', 'علی از شیراز این محصول را خرید' ]; function showNotification() { const box = document.createElement('div'); box.className = 'sale-popup'; box.innerText = notifications[ Math.floor(Math.random() * notifications.length) ]; document.body.appendChild(box); setTimeout(() => { box.remove(); }, 4000); } setInterval(showNotification, 20000); CSS: .sale-popup { position: fixed; bottom: 20px; left: 20px; background: #111; color: #fff; padding: 12px 18px; border-radius: 10px; z-index: 9999; } --- 9. ساخت Feed ترب و گوگل function generateProductFeed(products) { return products.map(p => ({ id: p.id, title: p.title, price: p.price, availability: p.stock ? 'in stock' : 'out of stock', image_link: p.image, brand: p.brand, link: p.url })); } const feed = generateProductFeed([ { id: 1, title: 'سرخ کن فیلیپس', price: 10465000, stock: true, image: 'https://example.com/fryer.jpg', brand: 'Philips', url: 'https://lavasemkhangi.ir/product/1' } ]); console.log(JSON.stringify(feed, null, 2)); --- 10. افزایش سرعت فوق حرفه‌ای window.addEventListener('load', () => { const scripts = document.querySelectorAll('script[data-lazy]'); scripts.forEach(script => { const s = document.createElement('script'); s.src = script.dataset.src; document.body.appendChild(s); }); }); HTML: --- 11. سیستم علاقه‌مندی مثل دیجی‌کالا function toggleWishlist(productId) { let wishlist = JSON.parse(localStorage.getItem('wishlist')) || []; if (wishlist.includes(productId)) { wishlist = wishlist.filter(id => id !== productId); } else { wishlist.push(productId); } localStorage.setItem('wishlist', JSON.stringify(wishlist)); } --- 12. سرچ سئو شده خودکار function seoTitle(product) { return `خرید ${product.name} | قیمت روز | ارسال فوری`; } console.log( seoTitle({ name: 'سرخ کن فیلیپس 16 لیتری' }) ); --- 13. Infinite Scroll حرفه‌ای let page = 1; window.addEventListener('scroll', () => { if ( window.innerHeight + window.scrollY >= document.body.offsetHeight - 500 ) { loadMoreProducts(); } }); function loadMoreProducts() { page++; console.log('Loading page', page); } --- 14. سیستم تخفیف معکوس (Urgency) function countdown(hours) { let seconds = hours * 3600; const timer = setInterval(() => { seconds--; const h = Math.floor(seconds / 3600); const m = Math.floor((seconds % 3600) / 60); const s = seconds % 60; document.getElementById('timer').innerText = `${h}:${m}:${s}`; if (seconds <= 0) clearInterval(timer); }, 1000); } countdown(6); --- نتیجه اگر این سیستم‌ها را درست پیاده‌سازی کنید: سئو قوی‌تر می‌شود فروش بیشتر می‌شود نرخ تبدیل بالا می‌رود اعتماد کاربر بیشتر می‌شود رفتار سایت شبیه دیجی‌کالا می‌شود گوگل بهتر محصولات را می‌خواند ترب محصولات را بهتر ایندکس می‌کند و مهم‌تر: فروش واقعی بالا می‌رود. کدهای حرفه‌ای جاوااسکریپت برای: سئوی فروشگاهی اتصال ترب و گوگل اسکیما Product افزایش سرعت جستجوی زنده سبد خرید نوتیفیکیشن فروش Wishlist Lazy Load سیستم مشابه دیجی‌کالا آماده کردم.
    جستجو در محصولات
    کالایی در این صفحه موجود نیست
      پروفایلسبد خریددسته‌بندیخانه