1

I'm Hiding Price using Plugin. the Plugin is Hiding price for every product except the multi value products. My code is

Vender/Module/Plugin/Price.php

<?php

namespace Vender\Module\Plugin;

class Price
{
function afterToHtml(\Magento\Catalog\Pricing\Render\FinalPriceBox $subject, $result)
 {
return " ";
}
}

Vender/Module/etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">

        <type name="Magento\Catalog\Pricing\Render\FinalPriceBox">
            <plugin name="price_hide" type="Vender\Module\Plugin\Price"/>        
        </type>
</config>

For other Product it shows like enter image description here

and for the Multi Price Products it shows like enter image description here

Now How to hide price of multi price product using Plugin.. Thanks in Advance

1

Below Code is working for me:

enter image description here

app/code/Vendor/Module/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="Vendor\Module\Plugin\Price" sortOrder="1" disabled="false"/>        
    </type>
</config>

Vendor\Module\Plugin\Price.php

<?php

namespace Vendor\Module\Plugin;

    class Price
    {
        function aroundToHtml(\Magento\Catalog\Pricing\Render\FinalPriceBox $subject, callable $proceed) {         
                return '';
        }
    }
  • Thank you Sooo much Bro.. It works for me :) – Asad Khan Feb 19 at 8:10
  • The Only issue I'm getting now is that the price is hidden everywhere and if I return some text then it doesn't return anything just hide the price everywhere – Asad Khan Feb 19 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.