Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
2 added 137 characters in body
source | link

you can get group Id by following code

protected $_customerSession;

public function __construct(
        ....    
        \Magento\Customer\Model\Session $customerSession,
        ....
    ) {


        $this->_customerSession = $customerSession;

    }

$groupIdpublic =function getGroupId(){
 if($this->_customerSession->isLoggedIn()):
        echo $customerGroup=$this->_customerSession->getCustomer()->getGroupId();
    endif;

}

you can get group Id by following code

protected $_customerSession;

public function __construct(
        ....    
        \Magento\Customer\Model\Session $customerSession,
        ....
    ) {


        $this->_customerSession = $customerSession;

    }

$groupId = $this->_customerSession->getCustomer()->getGroupId();

you can get group Id by following code

protected $_customerSession;

public function __construct(
        ....    
        \Magento\Customer\Model\Session $customerSession,
        ....
    ) {


        $this->_customerSession = $customerSession;

    }

public function getGroupId(){
 if($this->_customerSession->isLoggedIn()):
        echo $customerGroup=$this->_customerSession->getCustomer()->getGroupId();
    endif;

}
1
source | link

you can get group Id by following code

protected $_customerSession;

public function __construct(
        ....    
        \Magento\Customer\Model\Session $customerSession,
        ....
    ) {


        $this->_customerSession = $customerSession;

    }

$groupId = $this->_customerSession->getCustomer()->getGroupId();