// Run this after the page fully loads window.addEventListener('DOMContentLoaded', function () { // Function to check if the user is logged in function isUserLoggedIn() { // Zoho Commerce usually adds a user icon or login element if not logged in const loginButton = document.querySelector('.zc-header__signin'); return !loginButton; // If login button doesn't exist, user is likely logged in } // Function to hide all price elements function hidePrices() { const priceElements = document.querySelectorAll('.zc-product__price, .zc-product-card__price, .zc-price'); priceElements.forEach(function (el) { el.style.display = 'none'; }); // Optional: Show a message in place of the price priceElements.forEach(function (el) { const notice = document.createElement('div'); notice.innerText = 'Login to view prices'; notice.style.fontWeight = 'bold'; notice.style.color = '#555'; el.parentNode.insertBefore(notice, el); }); } // Only hide prices if the user is not logged in if (!isUserLoggedIn()) { hidePrices(); } });