0

I want to hide price from non registered users in magento 2 for specific products. I want to do this functionality by using any observer or plugins not from direct conditions in overwritten phtml files.

1 Answer 1

0

First check if user is logged in or not

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $objectManager->get('Magento\Customer\Model\Session');
if($customerSession->isLoggedIn()) {
   // show price 
}else {
 // show some custom message or hide complete price logic

}

Must read : How to check if customer is logged in or not in magento 2?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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