I want to completely hide the price from the store. Be it in the catalog, product, minicart or cart. I need to do this through a custom module.
Any help is appreciated. Thanks!
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI want to completely hide the price from the store. Be it in the catalog, product, minicart or cart. I need to do this through a custom module.
Any help is appreciated. Thanks!
This is a whole story here. But this should get you going.
The block used for product rendering in product view, product listing and so on is Magento\Catalog\Pricing\Render.
One example of usage in a layout file could be something like this.
<block class="Magento\Catalog\Pricing\Render" name="product.price.final">
<arguments>
<argument name="price_render" xsi:type="string">product.price.render.default</argument>
<argument name="price_type_code" xsi:type="string">final_price</argument>
<argument name="zone" xsi:type="string">item_view</argument>
</arguments>
</block>
To remove a block you need to extend the layout file in your module|theme.
After extending the layout file you can remove a block with the following instruction
<referenceBlock name="block_name" remove="true"/>
What I would start doing is
For the checkout area is a whole other story. Checkout is rendered with ui components. And some other areas that use them. I'm not sure how you are going to go about that.
This is the recently viewed widget where price is included via ui components. link to widget
Completely hide price from the store
app\code\Vendorename\Modulename\etc\frontend
di.xml
<?xml version="1.0" encoding="UTF-8"?>
<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="price_hide" type="Vendorename\Modulename\Plugin\HidePriceBox" sortOrder="1" disabled="false"/>
</type>
</config>
app\code\Vendorename\Modulename\Plugin
HidePriceBox.php
<?php
namespace Vendorename\Modulename\Plugin;
class HidePriceBox
{
function afterToHtml(\Magento\Catalog\Pricing\Render\FinalPriceBox $subject, $result)
{
// put your code for specific store view show and hide.
// for show price box then use this line return $result;
return ''; // hide price
}
}
I Hope This Helps You.