Bas do second… aapke deals ko ready kar rahe hain πŸ›’

Nanda Wholesale Mart
Delivery to
Choose Location
Wholesale Cart
// Global Wholesale Tier Dynamic Highlighting & Upsell Handler window.updateProductTierDisplay = function(qty, slug) { qty = parseInt(qty) || 0; // 1. Update product cards on home / category / subcategory / search pages const cards = document.querySelectorAll(`[id*="${slug}"]`); cards.forEach(card => { const tierRows = card.querySelectorAll('.tier-row'); let activeRow = null; tierRows.forEach(row => { const minQty = parseInt(row.getAttribute('data-min-qty') || '1'); if (qty >= minQty) { activeRow = row; } }); tierRows.forEach((row, idx) => { if (row === activeRow && qty > 0) { row.classList.add('bg-green-50', 'dark:bg-green-950/40', 'text-green-700', 'dark:text-green-300', 'font-bold'); row.classList.remove('text-gray-700', 'dark:text-gray-300', 'font-medium'); } else { row.classList.remove('bg-green-50', 'dark:bg-green-950/40', 'text-green-700', 'dark:text-green-300', 'font-bold'); if (idx === 0) { row.classList.add('text-gray-700', 'dark:text-gray-300', 'font-medium'); } else { row.classList.add('text-green-700', 'dark:text-green-400', 'font-semibold'); } } }); // Update Wholesale Tier Upsell Prompt const upsellContainer = card.querySelector('.tier-upsell-container'); if (upsellContainer) { const upsellTextEl = upsellContainer.querySelector('.upsell-text'); if (qty >= 1 && tierRows.length > 1) { let nextTier = null; tierRows.forEach(row => { const minQty = parseInt(row.getAttribute('data-min-qty') || '1'); if (minQty > qty && !nextTier) { nextTier = { minQty: minQty, price: row.getAttribute('data-price') || '' }; } }); if (nextTier) { const needed = nextTier.minQty - qty; if (upsellTextEl) upsellTextEl.textContent = `Add ${needed} more for ${nextTier.price}/u`; upsellContainer.classList.remove('hidden'); } else { if (upsellTextEl) upsellTextEl.textContent = 'βœ“ Best wholesale price unlocked!'; upsellContainer.classList.remove('hidden'); } } else { upsellContainer.classList.add('hidden'); } } }); // 2. Update Product Detail page bulk pricing if present if (typeof parsedProductTiers !== 'undefined' && parsedProductTiers.length > 0) { let active = parsedProductTiers[0]; if (qty > 0) { parsedProductTiers.forEach(t => { if (qty >= t.minQty) active = t; }); } else if (typeof activeSelectedTierId !== 'undefined') { const sel = parsedProductTiers.find(t => t.id == activeSelectedTierId); if (sel) active = sel; } parsedProductTiers.forEach(t => { const row = document.getElementById('tier-row-' + t.id); if (row) { const titleSpan = row.querySelector('span'); if (t.id === active.id) { row.className = 'grid grid-cols-2 px-4 py-3 items-center transition-all duration-150 cursor-pointer tier-slab-row bg-emerald-50/80 dark:bg-emerald-950/40 border-l-4 border-l-[#15803d] active-tier-row font-semibold'; if (titleSpan) titleSpan.className = 'text-sm text-[#15803d] dark:text-green-300 font-bold'; } else { row.className = 'grid grid-cols-2 px-4 py-3 items-center transition-all duration-150 cursor-pointer tier-slab-row bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-750'; if (titleSpan) titleSpan.className = 'text-sm text-gray-800 dark:text-gray-200 font-medium'; } } }); const qtySpan = document.getElementById('productDetailMainQty'); if (qtySpan) qtySpan.textContent = qty > 0 ? qty : 1; const liveTotalEl = document.getElementById('liveProductTotal'); if (liveTotalEl && typeof currencySymbol !== 'undefined') { const total = (qty > 0 ? qty : 1) * active.curPrice; const formatted = currencyPosition === 'left' ? `${currencySymbol}${total.toFixed(0)}` : `${total.toFixed(0)}${currencySymbol}`; liveTotalEl.textContent = `Total: ${formatted}`; } } };