If you want to hide the product price and display “login to view price” in your Shopify, this simple guide will help you to achieve it without any technical hassles.
At the end of the blog, we will be able to achieve the following if you follow all the instructions correctly.

Steps to Hide Price Until Logged in to Shopify
Step 1: Navigate to Theme Editor
Login to your Shopify admin and head to Online Store > Themes

Then, click on the three dots beside the Customize button and select Edit code for your current theme.

Step 2: Add the Code to The theme.liquid file
Next, head to theme.liquid and in the Theme File editor, open the theme.liquid file and paste the following code before the closing </body> tag:
<script> window.isLoggedIn = {% if customer %} true {% else %} false {% endif %}; document.addEventListener('DOMContentLoaded', function() { var priceElements = document.querySelectorAll('.product-price, .price, .product-card__price'); priceElements.forEach(function(priceElement) { if (window.isLoggedIn) { priceElement.style.display = 'inline'; } else { priceElement.style.display = 'none'; var loginMessage = document.createElement('span'); loginMessage.innerHTML = '<a href="/account/login">Login</a> to view price'; priceElement.parentNode.appendChild(loginMessage); // Add the login message next to the price element } }); }); </script>
You can modify the messaging that you would like to keep instead of “login to see the price” and click Save.

Step 3: Hide Price in the Front End
Test the functionality, try browsing your Shopify store without login and you will notice the product prices are hidden. This simple method will not display pricing to the guest (not logged in) customers on product as well as collection pages.

Make Your Shopify Product Shareable
The method mentioned above encourages guest visitors to create an account with your store to view pricing; this way, you can keep engaging with them whenever needed.
Another way to engage is by adding a WhatsApp share button to Shopify.
Your customers can share their favourite products from the store with their friends and family — maximizing your brand awareness.