I'd like to hide actions block on the single product page (only certain products):

enter image description here

I thought magento managed to show this information with a single phtml so I'd overrided entirely and insert an if block to show/hide this section.

But I see it uses a lot of templates and don't know how to do it to take control on it.

I did a similar question only for add a block Add block on single product page, but in this case I need to control the existing block.

I'm trying to solve the problem like @chirag said but I can't figure out why it's not working, so I'll put the names and paths:


<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <referenceContainer name="page.main.title">
        <block class="GSP\Mto\Block\Product\View\MtoSingle"

    <referenceBlock name="product.info" template="GSP_Mto::product/view/form.phtml" />


<p> test </p>

expected result: paragraph test instead of form qty and add to cart.

actual result: default magento template.

UPDATE: I'm looking around and I don't see nothing wrong, seems it has to be something about priorities. Magento just uses his template as default. If I write

<referenceBlock name="product.info" template="GSP_Mto::product/view/form.phtml" remove="true" />

It works, the addtocart and qty disappears. But when I only indicate to use my template, magento just show it as default.

The only way it 'works out' is writing a line on di.xml:

<preference for="Magento\Catalog\Block\Product\View" type="GSP\Mto\Block\Product\View" />

And copy the entire class on my module. But this is just ridiculous. And then messies the button addtocart not showing it, seems breaks something

It has to be a silly thing but it kept me an entirely day and I couldn't fix it.

UPDATE2: Tried to write directly on vendor\magento\module-catalog\view\frontend\layout\catalog_product_view.xml

<block class="Magento\Catalog\Block\Product\View" name="product.info" template="GSP_Mto::product/view/form.phtml" after="alert.urls">

My template. This is the only way that works everything but completely wrong way to do it.

I think I'm going to lose my head.

1 Answer 1


You can write your condition in three files for hiding this block.

1. product/view/addto.phtml

2. product/view/mailto.phtml

3. product/view/form.phtml

[NOTE] Copy content of this files in your custom files and then you can write your required condition.

Your catalog_product_view.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <referenceBlock name="product.info" template="{YourVendor}_{Your_Module}::product/view/form.phtml"></referenceBlock>
    <referenceBlock name="product.info.addto" template="{YourVendor}_{Your_Module}::product/view/addto.phtml"></referenceBlock>
    <referenceBlock name="product.info.mailto" template="{YourVendor}_{Your_Module}::product/view/mailto.phtml"></referenceBlock>
  • Looks nice, I thought there will be so many blocks to override. But I have a silly problem, don't know why magento still uses his template instead of mine. If I write <referenceBlock name="product.info.addto" remove="true" /> I see that block disappears but when I write like you did indicating my template doesn't work. Need to do anything else? Paths are correct. I tried to write: vendor_module::product/view/form.phtml and vendor_module/product/view/form.phtml
    – Marc Pont
    Dec 12, 2016 at 11:46
  • uppss, you have to use vendor_module::product/view/form.phtml. Dec 12, 2016 at 11:48
  • I've already tried, and not working. I hate magento for this things, how I know what is happening?
    – Marc Pont
    Dec 12, 2016 at 11:51
  • Have you check the path of your template file? Dec 12, 2016 at 11:54
  • Yes, also I tried to use another template that I know is working fine and nothing. There aren't something about priorities? seems it has to be that.
    – Marc Pont
    Dec 12, 2016 at 11:59

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.