source/Application/Model/Voucher.php
protected function _isValidUserGroup($oUser)
    {
        $oVoucherSeries = $this->getSerie();
        $oUserGroups = $oVoucherSeries->setUserGroups();

        if (!$oUserGroups->count()) {
            return true;
        }

        if ($oUser) {
            foreach ($oUserGroups as $oGroup) {
                if ($oUser->inGroup($oGroup->getId())) {
                    return true;
                }
            }
        }

        $oEx = oxNew(\OxidEsales\Eshop\Core\Exception\VoucherException::class);
        $oEx->setMessage('ERROR_MESSAGE_VOUCHER_NOTVALIDUSERGROUP');
        $oEx->setVoucherNr($this->oxvouchers__oxvouchernr->value);
        throw $oEx;
    }
protected function _isValidUserGroup($oUser)
    {
        $oVoucherSeries = $this->getSerie();
        $oUserGroups = $oVoucherSeries->setUserGroups();

        if (!$oUserGroups->count()) {
            return true;
        }

        if ($oUser) {
            foreach ($oUserGroups as $oGroup) {
                if ($oUser->inGroup($oGroup->getId())) {
                    return true;
                }
            }
        }

        $oEx = oxNew(\OxidEsales\Eshop\Core\Exception\VoucherException::class);
        $oEx->setMessage('ERROR_MESSAGE_VOUCHER_NOTVALIDUSERGROUP');
        $oEx->setVoucherNr($this->oxvouchers__oxvouchernr->value);
        throw $oEx;
    }
protected function _isValidUserGroup ( $ oUser ) { $ oVoucherSeries = $ this -> getSerie ( ) ; $ oUserGroups = $ oVoucherSeries -> setUserGroups ( ) ; if ( ! $ oUserGroups -> count ( ) ) { return true ; } if ( $ oUser ) { foreach ( $ oUserGroups as $ oGroup ) { if ( $ oUser -> inGroup ( $ oGroup -> getId ( ) ) ) { return true ; } } } $ oEx = oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ VoucherException :: class ) ; $ oEx -> setMessage ( 'ERROR_MESSAGE_VOUCHER_NOTVALIDUSERGROUP' ) ; $ oEx -> setVoucherNr ( $ this -> oxvouchers__oxvouchernr -> value ) ; throw $ oEx ; }
Checks if user belongs to the same group as the voucher. Returns true on sucess.

@param object $oUser user object

@throws oxVoucherException exception

@return bool
Checks if user belongs to the same group as the voucher . Returns true on sucess .