🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Add Login to View Price in Shopify? 

By Sanjay JethvaUpdated on Feb 21, 2025 3 min read

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. 

Hide Price in Frontend

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

Navigate to Themes

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

Edit Code

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. 

Add the Code to the theme.liquid file

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.

Hide Price in Frontend

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. 

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.