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)
Solved! Go to Solution.
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
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
Hello @chathuramk
if works then mark as a solution so it will help to other.
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;
}
}
hello @chathuramk
namespace\modulename\Pricing\Render\FinalPriceBox
where namespace and modulename is your module name.
Hello @chathuramk
are still facing any issue?
if not then mark as a solution.
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