Sometime we need to check the condition if customer is logged in or not:
/** @var \Magento\Framework\App\ObjectManager $ */ $obm = \Magento\Framework\App\ObjectManager::getInstance(); /** @var \Magento\Framework\App\Http\Context $context */ $context = $obm->get('Magento\Framework\App\Http\Context'); /** @var bool $isLoggedIn */ $isLoggedIn = $context->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH);
Once you have the $isLoggedIn variable, you can check condition as per below.
<?php if($isLoggedIn): ?> //your condition code <?php else: ?> //your condition code <?php endif; ?>
0 Comments