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.
Asked
Active
Viewed 248 times
1 Answers
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?
inrsaurabh
- 1,676
- 2
- 26
- 54