If you want to hide the whole website’s product price and want to make it appear only for login users then this article is a catch for you.
1. Create file di.xml on app/code/Magemonkeys/Hideproductprice/etc
1 2 3 4 5 6 7 |
<?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="Magemonkeys\Hideproductprice\Plugin\HidePriceBox" sortOrder="1" disabled="false"/> </type> </config> |
2. Create file HidePriceBox.php on app/code/Magemonkeys/Hideproductprice/Plugin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<?php namespace Magemonkeys\Hideproductprice\Plugin; class HidePriceBox { protected $_customerSession; public function __construct( \Magento\Customer\Model\Session $customerSession ) { $this->_customerSession = $customerSession; } function afterToHtml(\Magento\Catalog\Pricing\Render\FinalPriceBox $subject, $result) { if($this->_customerSession->getCustomer()->getGroupId()) { return $result; }else{ return '<h3>PLEASE DO LOGIN AND SHOW THE PRICE</h3>'; } } } |
3. Result
[crayon-63d3df913834a826106962/] Using above fucntion Images can be imported directly from...
Override view block using di.xml and add the below code...
You can check a list of called layout XML for...
Follow the below steps to install and set up PWA...
If you want to remove all leading zero's from order,...
Let our Magento expert connect to discuss your requirement.
We offer Magento
certified developers.
Our Magento clientele
is 500+.
We sign NDA for the
security of your projects.
We’ve performed 100+
Magento migration projects.
Free quotation
on your project.
Three months warranty on
code developed by us.