cancel
Showing results for 
Search instead for 
Did you mean: 

Hide product price for specific products

SOLVED

Hide product price for specific products

I am using an extension for enable "Add to Quote" option instead of "Add to Cart" for some specific products.

How can I hide price for "Add to Quote" enabled products (attribute ves_enable_quote) and display "Price on request" text?? (as per below image)

 

hideprice.PNG

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Hide product price for specific products

Hello @chathuramk 

 

for that, you need to create a plugin for FinalPriceBox for a simple product

di.xml code

 

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> 
	<preference for="Magento\Catalog\Pricing\Render\FinalPriceBox" type="namespace\modulename\Pricing\Render\FinalPriceBox" />	
    </type>
</config>

class FinalPriceBox

 

protected function _toHtml()
    {
 // condion here 
   if(//your condtion)
{
return '<div class="price-box"></div>';
}else{
$result = parent::_toHtml();
return $result;
}
}

hope it will help you.

 

if works then mark as solution

 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

View solution in original post

7 REPLIES 7

Re: Hide product price for specific products

Hello @chathuramk 

 

for that, you need to create a plugin for FinalPriceBox for a simple product

di.xml code

 

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> 
	<preference for="Magento\Catalog\Pricing\Render\FinalPriceBox" type="namespace\modulename\Pricing\Render\FinalPriceBox" />	
    </type>
</config>

class FinalPriceBox

 

protected function _toHtml()
    {
 // condion here 
   if(//your condtion)
{
return '<div class="price-box"></div>';
}else{
$result = parent::_toHtml();
return $result;
}
}

hope it will help you.

 

if works then mark as solution

 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Hide product price for specific products

Hello @chathuramk 

 

if works then mark as a solution so it will help to other.

 

 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Hide product price for specific products

Hello @Sunil Patel ,

 

Thank you for your reply.

I created folder structure for new extension and added di.xml in etc folder. I have no idea about second code. where to add below code?

 

protected function _toHtml()
    {
 // condion here 
   if(//your condtion)
{
return '<div class="price-box"></div>';
}else{
$result = parent::_toHtml();
return $result;
}
}

Re: Hide product price for specific products

hello @chathuramk 

 

namespace\modulename\Pricing\Render\FinalPriceBox

 

where namespace and modulename is your module name.

 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Hide product price for specific products

Hello @chathuramk 

 

are still facing any issue?

 

if not then mark as a solution.


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Hide product price for specific products

Hi,

Yes still having issues Smiley Sad I’m not expert in creating magento extensions

Re: Hide product price for specific products

Hello @chathuramk 

Why don't you purchase readymade extension 

Not much costly https://magecomp.com/magento-2-hide-price.html

https://magecomp.com/magento-2-call-for-price.html

https://magecomp.com/magento-2-email-quote.html

Was my answer helpful? You can accept it as a solution.
175+ Professional Extensions for M1 & M2
Need a developer?Just visit Contact Us Now