I don't want to use any commercial module for hiding price.and i don't want hide by using templates. is there any way to hide price from entire site using plug-ins or rewrites?



<preference for="Magento\Catalog\Pricing\Render\FinalPriceBox" type="Vendor\Module\Pricing\Render\FinalPriceBox" />



namespace Vendor\Module\Pricing\Render;

use Magento\Catalog\Pricing\Price;
use Magento\Framework\Pricing\Render;
use Magento\Framework\Pricing\Render\PriceBox as BasePriceBox;
use Magento\Msrp\Pricing\Price\MsrpPrice;

class FinalPriceBox extends \Magento\Catalog\Pricing\Render\FinalPriceBox
    protected function wrapResult($html)
        return '';  


| improve this answer | |
  • its not working. changes not effect. – Yogesh Jul 6 '17 at 10:23
  • FinalBox isn't cached ? – siddhesh Jul 14 '17 at 15:20
  • Works great. I need to hide regular/final price on related section and how to achieve that? – Jai Aug 18 '17 at 11:24
  • well, i just figure out that this only worked for homepage and product detail page, but not with WISH LIST page. I still have change phtml file – fudu Oct 4 '18 at 2:43
  • Its work fine !! – Chirag Gondaliya Jan 8 at 14:08

Create module (eg: CatalogHidePrice) with plugin.
di.xml should look like:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Catalog\Pricing\Render\FinalPriceBox">
        <plugin name="cataloghideprice_finalpricebox" type="NAMESPACE\CatalogHidePrice\Plugin\FinalPriceBox"/>

In the plugin class \Plugin\FinalPriceBox\FinalPriceBox do an around plugin (for me, I have to hide the price based on a product attribute)

function aroundToHtml($subject, callable $proceed)

        return '';
        return $proceed();

| improve this answer | |
  • I can't get the value of my attribute. These methods don't work: getMyAttribute() and getData('my_attribute'). Although the following method works $_product = $subject->getSaleableItem(); $myAttribute = $_product->getResource()->getAttribute('my_attribute')->getFrontend()->getValue($_product);. What could be the problem? – Victor S. Jul 5 '18 at 15:21
  • Lomosh HidePrice is an attribte? – Nagaraju K Nov 2 '18 at 6:56

The simplest way I can think of would be to just target the price's CSS class and hide it.

No modifying of any themes/template files required and can easily revert the changes by removing the style rule.

| improve this answer | |
  • Have you got any example of this? – jibin george Jul 12 '19 at 8:51
  • @jibingeorge it would vary depending on the theme/template, but just find the css class that is attached to the element you want hidden, then add or modify a style declaration to set it to display: none – codestr Aug 2 '19 at 2:19

I think this extension may solve your problems: https://www.mageplaza.com/magento-2-hide-price/

| improve this answer | |

Please try our free plugin Magento 2 Hide Price Free. It hides prices for unauthorised Magento customers or replaces it with custom text or button with the popup message. You can configure it on store view level. Let us know how it worked for you!


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.