function updateLoyaltyUI() { if (!loyaltySection || typeof LOYALTY_SETTINGS === 'undefined' || !LOYALTY_SETTINGS.is_enabled) return; if (currentCustomer) { loyaltySection.classList.remove('d-none'); if (loyaltyPointsDisplay) loyaltyPointsDisplay.textContent = currentCustomer.points + ' pts'; if (redeemLoyaltyBtn) { const hasLoyaltyItem = cart.some(item => item.is_loyalty); const hasNonLoyaltyItem = cart.some(item => !item.is_loyalty); redeemLoyaltyBtn.disabled = !currentCustomer.eligible_for_free_meal || !hasLoyaltyItem || hasNonLoyaltyItem; if (loyaltyMessage) { if (currentCustomer.eligible_for_free_meal) { const count = currentCustomer.eligible_count || 1; loyaltyMessage.innerHTML = `Eligible for ${count} Free Product${count > 1 ? 's' : ''}!`; if (hasNonLoyaltyItem) { loyaltyMessage.innerHTML += '
(Remove non-loyalty products to redeem)
'; } else if (!hasLoyaltyItem) { loyaltyMessage.innerHTML += '
(Add a loyalty product to redeem)
'; } } else { loyaltyMessage.textContent = `${currentCustomer.points_needed || 0} pts away from a free product.`; } } } } else { loyaltySection.classList.add('d-none'); } }