I'd like to hide actions block on the single product page (only certain products):
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"> <body> <referenceContainer name="page.main.title"> <block class="GSP\Mto\Block\Product\View\MtoSingle" name="product.view.mto" template="GSP_Mto::product/view/mto_single.phtml" after="-"> </block> </referenceContainer> <referenceBlock name="product.info" template="GSP_Mto::product/view/form.phtml" /> </body> </page>
<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
<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.