Magento 2 – How to Remove a Block from Specific Product

designlayoutmagento-2.1magento2

I want to remove Price block from specific product. I tried to updated Layout Update XML but it is not working

I have tried this <referenceBlock name="product.info.price" remove="true"/> but it do not work.

I read some where it will only accept the <referenceContainer>... not <referenceBlock name="block.name" remove="true"/>

So I tried

<container name="trash.bin" htmlTag="div" />
<move element="product.info.price" destination="trash.bin" />
<referenceContainer name="trash.bin" remove="true" />

this did not work either.Any solution?

Best Answer

I tested it on the Magento CE 2.1.7 and the layout update works fine. I've added the layout for the custom product (by its id) app/code/Vendor/Module/view/frontend/layout/catalog_product_view_id_2049.xml with the lines:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="product.info.price" remove="true"/>
    </body>
</page>

Here is product view page before the changes (having price block with a value 100$):

price block with a value 100$

After implementing the changes there is no price block at this place:

without price block

PS: tested on the Magento blank theme.