---
title: "How to Hide Price for Guest Users in Magento 2"
url: "https://magecomp.com/blog/hide-price-for-guest-visitors-magento-2/"
date: "2020-12-01T10:06:44+00:00"
modified: "2025-02-20T09:18:10+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "How To"
  - "Magento 2"
word_count: 612
reading_time: "4 min read"
summary: "Hello Magento Folks,"
description: "Many times the store merchants think to hide the product price for some reasons. Learn How to Hide Price for guest visitors in Magento 2."
keywords: "How To, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "Magento 2: How to Add Custom Text after Billing Address and Shipping Address in Invoice PDF?"
    url: "https://magecomp.com/blog/magento-2-add-custom-text-after-billing-address-and-shipping-address-in-invoice-pdf/"
  - title: "Magento 2: Trigger an Event on Save Specific System Configuration Section"
    url: "https://magecomp.com/blog/magento-2-trigger-an-event-on-save-specific-system-configuration-section/"
  - title: "Why Its Right Time Magento 1 to Magento 2 Migration: The Benefits and Reasons"
    url: "https://magecomp.com/blog/right-time-magento-1-magento-2-migration-benefits/"
---

# How to Hide Price for Guest Users in Magento 2

_Published: December 1, 2020_  
_Author: Dhiren Vasoya_  

![How to Hide Price for Not Logged In Customers in Magento 2](https://magecomp.com/blog/wp-content/uploads/2020/12/How-to-Hide-Price-for-Not-Logged-In-Customers-in-Magento-2-1-1024x512.webp)

Hello Magento Folks,
In this article, I will illustrate How to hide price for guest visitors in Magento 2? Also, check our previously published article where I have illustrated [**How to Manage Order Status and Order state in Magento 2**](https://magecomp.com/blog/manage-order-status-and-order-state-magento-2/). Let’s Dig In.
[![Magento Malware Removal](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-Malware-Removal-CTA-6.webp)](https://magecomp.com/magento-malware-removal.html)

## Introduction:
Mainly the product price is one of the most mandatory things that customers are eager to know. Many times the store merchants think to hide the product price for some reasons. The reasons include the tough competition in the market so the store merchant is not willing to show the price. Or the reason may also include that the store merchant wants the customer to register and login to view the price in their Magento 2 store. Ther store merchants will allow the registered and logged in customers to view price. Here the store merchants will keep the catalog accessible for all the customers but it will be displayed to the logged-in customers only.
It involves hiding the price for guests users. When the price is hidden then the customers can’t judge the product and they will be interested in viewing the price. Viewing the product price is necessary as this will boost the customers buying point of view.
Follow the below steps **to hide price for guest visitors in Magento 2.**

Are you on the hunt for advanced features for hiding price then checkout [**Magento 2 Hide Product Price Extension**](https://magecomp.com/magento-2-hide-product-price.html) where you can find features like hiding the add to cart button for not logged in customer also you can select your desired/specific customer groups?
## Steps to hide price for not logged in customers in Magento 2:
**Step 1:** First you need to add di.xml in the following path: Vendor\Extension\etc
```
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
    <preference for="MagentoCatalogPricingRenderFinalPriceBox"
        type="VendorExtensionPricingRenderFinalPriceBox" />
    <preference for="MagentoConfigurableProductPricingRenderFinalPriceBox"
        type="VendorExtensionPricingRenderFinalPriceBox" />
</config>
```

[![Magento 2 Speed & Performance Optimization Services](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-2-Speed-Performance-Optimization-Services-CTA-2.webp)](https://magecomp.com/magento-performance-optimization.html)

**Step 2:** After this, you will require to **create FinalPriceBox.php** in the following path: **Vendor\Extension\Pricing\Render**

```
<?php

namespace VendorExtensionPricingRender;
use MagentoCatalogPricingPrice;
use MagentoFrameworkPricingRender;
use MagentoFrameworkPricingRenderPriceBox as BasePriceBox;
use MagentoMsrpPricingPriceMsrpPrice;
class FinalPriceBox extends MagentoCatalogPricingRenderFinalPriceBox
{
    protected $httpContext;

    public function __construct(
        MagentoFrameworkViewElementTemplateContext $context,
        MagentoFrameworkPricingSaleableInterface $saleableItem,
        MagentoFrameworkPricingPricePriceInterface $price,
        MagentoFrameworkPricingRenderRendererPool $rendererPool,
        array $data = [],
        MagentoCatalogModelProductPricingRendererSalableResolverInterface $salableResolver = null,
        MagentoCatalogPricingPriceMinimalPriceCalculatorInterface $minimalPriceCalculator = null,
        MagentoFrameworkAppHttpContext $httpContext
    ) {
    	$this->httpContext = $httpContext;
        parent::__construct($context,
                            $saleableItem,
                            $price,
                            $rendererPool,
                            $data,
                            $salableResolver,
                            $minimalPriceCalculator);
    }

    protected function wrapResult($html)
    {
        $isLoggedIn =    $this->httpContext->getValue(MagentoCustomerModelContext::CONTEXT_AUTH);
        if($isLoggedIn){
            return 'getData('css_classes') . '" ' .
                'data-role="priceBox" ' .
                'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
                '>' . $html . '';
        }else{
            $wording = 'Please Login To See Price';
            return 'getSaleableItem()->getId() . '"' .
                '>'.$wording.'';
        }
    }
}
```

That’s It.
## Conclusion:
Hence, implement the above code to hide price for not logged in customers in Magento 2. In case if you come across any difficulties in implementing the hide price for not logged in customers in Magento 2 feature then let me know in the comment section below.
[![hyva theme development](https://magecomp.com/blog/wp-content/uploads/2025/02/hyva-theme-development-CTA-6.webp)](https://magecomp.com/services/hyva-theme-development/)

Also, spread the solution with your Magento friends via Social Media.
**Happy Reading!**


---

_View the original post at: [https://magecomp.com/blog/hide-price-for-guest-visitors-magento-2/](https://magecomp.com/blog/hide-price-for-guest-visitors-magento-2/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-10-28 07:42:22 UTC_  
