I need to hide price in selected product in category list page. [PFA]

enter image description here

I know, there are many extensions for it.

I have used 2-3 extensions for the same but it changes my theme. Because they override list.phtml file.

I need to change only Price div and add my custom code but I can't figure out how to achieve this?


Before Extension

enter image description here

After Extension

enter image description here

Does anyone know block name for that Price div ?

  • Are you want to hide price only from list page? Jun 22, 2017 at 5:20
  • I have dropdown in product edit page in admin side. So price should be hide in which I have select yes and need to put a button instead of Add to cart button. Jun 22, 2017 at 5:38
  • have you overrider list.phtml file in your theme? Jun 22, 2017 at 5:43
  • Yes. And so when I use any other theme, it doesn't look good because of my list.phtml file. Jun 22, 2017 at 5:50

1 Answer 1


You can set your condition based on your product value show/hide in list file,

Your theme list.phtml file would be, app/design/frontend/{Packagename}/{themename}/Magento_Catalog/templates/product/list.phtml file

Price rendering in list file using one line, <?php /* @escapeNotVerified */ echo $block->getProductPrice($_product) ?>

Inside list.phtml file

    $productShow = Your condition.....;
<?php if($productShow){ ?>
<?php /* @escapeNotVerified */ echo $block->getProductPrice($_product) ?>
<?php } ?>

Now Block file,

function for price render is coming from block file,


 public function getProductDetailsHtml(\Magento\Catalog\Model\Product $product)
        $renderer = $this->getDetailsRenderer($product->getTypeId());
        if ($renderer) {
            return $renderer->toHtml();
        return '';
  • Would you please explain with more words ? I haven't more knowledge of where to create file and where to write that function getProductDetailsHtml. Jun 22, 2017 at 7:13
  • This is default core function of magento you have to write your code inside list.phtml file of your theme. Jun 22, 2017 at 7:17
  • I am creating extension and list.phtml file in it. I can't change in other vendor's theme folders. At this point, design issue is occurs. One can change theme after some time, then again I have to change theme's list.phtml file. Jun 22, 2017 at 7:24
  • you can keep above code in list.phtml of your module Jun 22, 2017 at 7:27
  • That code is only for price, right ? Do I need to keep other code as it is ? Jun 22, 2017 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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