<?php namespace PHPCodez\Disableaddtocart\Helper; use \Magento\Framework\App\Helper\AbstractHelper; use \Magento\Customer\Model\Session; class Data extends AbstractHelper { protected $_customerSession; public function __construct(Session $_customerSession) { $this->_customerSession = $_customerSession; } public function getCustomerGroup(){ return $this->_customerSession->isLoggedIn()?$this->_customerSession->getCustomer()->getGroupId():0; } }