source/Application/Model/Voucher.php
protected function _getProductDiscountValue($dPrice)
    {
        $oDiscount = $this->_getSerieDiscount();
        $aBasketItems = $this->_getBasketItems($oDiscount);

        // Basket Item Count and isAdmin check (unble to access property $oOrder->_getOrderBasket()->_blSkipVouchersAvailabilityChecking)
        if (!count($aBasketItems) && !$this->isAdmin()) {
            $oEx = oxNew(\OxidEsales\Eshop\Core\Exception\VoucherException::class);
            $oEx->setMessage('ERROR_MESSAGE_VOUCHER_NOVOUCHER');
            $oEx->setVoucherNr($this->oxvouchers__oxvouchernr->value);
            throw $oEx;
        }

        $oSeries = $this->getSerie();

        $oVoucherPrice = oxNew(\OxidEsales\Eshop\Core\Price::class);
        $oDiscountPrice = oxNew(\OxidEsales\Eshop\Core\Price::class);
        $oProductPrice = oxNew(\OxidEsales\Eshop\Core\Price::class);
        $oProductTotal = oxNew(\OxidEsales\Eshop\Core\Price::class);

        // Is the voucher discount applied to at least one basket item
        $blDiscountApplied = false;

        foreach ($aBasketItems as $aBasketItem) {
            // If discount was already applied for the voucher to at least one basket items, then break
            if ($blDiscountApplied and !empty($oSeries->oxvoucherseries__oxcalculateonce->value)) {
                break;
            }

            $oDiscountPrice->setPrice($aBasketItem['discount']);
            $oProductPrice->setPrice($aBasketItem['price']);

            // Individual voucher is not multiplied by article amount
            if (!$oSeries->oxvoucherseries__oxcalculateonce->value) {
                $oDiscountPrice->multiply($aBasketItem['amount']);
                $oProductPrice->multiply($aBasketItem['amount']);
            }

            $oVoucherPrice->add($oDiscountPrice->getBruttoPrice());
            $oProductTotal->add($oProductPrice->getBruttoPrice());

            if (!empty($aBasketItem['discount'])) {
                $blDiscountApplied = true;
            }
        }

        $dVoucher = $oVoucherPrice->getBruttoPrice();
        $dProduct = $oProductTotal->getBruttoPrice();

        if ($dVoucher > $dProduct) {
            return $dProduct;
        }

        return $dVoucher;
    }
protected function _getProductDiscountValue($dPrice)
    {
        $oDiscount = $this->_getSerieDiscount();
        $aBasketItems = $this->_getBasketItems($oDiscount);

        // Basket Item Count and isAdmin check (unble to access property $oOrder->_getOrderBasket()->_blSkipVouchersAvailabilityChecking)
        if (!count($aBasketItems) && !$this->isAdmin()) {
            $oEx = oxNew(\OxidEsales\Eshop\Core\Exception\VoucherException::class);
            $oEx->setMessage('ERROR_MESSAGE_VOUCHER_NOVOUCHER');
            $oEx->setVoucherNr($this->oxvouchers__oxvouchernr->value);
            throw $oEx;
        }

        $oSeries = $this->getSerie();

        $oVoucherPrice = oxNew(\OxidEsales\Eshop\Core\Price::class);
        $oDiscountPrice = oxNew(\OxidEsales\Eshop\Core\Price::class);
        $oProductPrice = oxNew(\OxidEsales\Eshop\Core\Price::class);
        $oProductTotal = oxNew(\OxidEsales\Eshop\Core\Price::class);

        // Is the voucher discount applied to at least one basket item
        $blDiscountApplied = false;

        foreach ($aBasketItems as $aBasketItem) {
            // If discount was already applied for the voucher to at least one basket items, then break
            if ($blDiscountApplied and !empty($oSeries->oxvoucherseries__oxcalculateonce->value)) {
                break;
            }

            $oDiscountPrice->setPrice($aBasketItem['discount']);
            $oProductPrice->setPrice($aBasketItem['price']);

            // Individual voucher is not multiplied by article amount
            if (!$oSeries->oxvoucherseries__oxcalculateonce->value) {
                $oDiscountPrice->multiply($aBasketItem['amount']);
                $oProductPrice->multiply($aBasketItem['amount']);
            }

            $oVoucherPrice->add($oDiscountPrice->getBruttoPrice());
            $oProductTotal->add($oProductPrice->getBruttoPrice());

            if (!empty($aBasketItem['discount'])) {
                $blDiscountApplied = true;
            }
        }

        $dVoucher = $oVoucherPrice->getBruttoPrice();
        $dProduct = $oProductTotal->getBruttoPrice();

        if ($dVoucher > $dProduct) {
            return $dProduct;
        }

        return $dVoucher;
    }
protected function _getProductDiscountValue ( $ dPrice ) { $ oDiscount = $ this -> _getSerieDiscount ( ) ; $ aBasketItems = $ this -> _getBasketItems ( $ oDiscount ) ; // Basket Item Count and isAdmin check (unble to access property $oOrder->_getOrderBasket()->_blSkipVouchersAvailabilityChecking) if ( ! count ( $ aBasketItems ) && ! $ this -> isAdmin ( ) ) { $ oEx = oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ VoucherException :: class ) ; $ oEx -> setMessage ( 'ERROR_MESSAGE_VOUCHER_NOVOUCHER' ) ; $ oEx -> setVoucherNr ( $ this -> oxvouchers__oxvouchernr -> value ) ; throw $ oEx ; } $ oSeries = $ this -> getSerie ( ) ; $ oVoucherPrice = oxNew ( \ OxidEsales \ Eshop \ Core \ Price :: class ) ; $ oDiscountPrice = oxNew ( \ OxidEsales \ Eshop \ Core \ Price :: class ) ; $ oProductPrice = oxNew ( \ OxidEsales \ Eshop \ Core \ Price :: class ) ; $ oProductTotal = oxNew ( \ OxidEsales \ Eshop \ Core \ Price :: class ) ; // Is the voucher discount applied to at least one basket item $ blDiscountApplied = false ; foreach ( $ aBasketItems as $ aBasketItem ) { // If discount was already applied for the voucher to at least one basket items, then break if ( $ blDiscountApplied and ! empty ( $ oSeries -> oxvoucherseries__oxcalculateonce -> value ) ) { break ; } $ oDiscountPrice -> setPrice ( $ aBasketItem [ 'discount' ] ) ; $ oProductPrice -> setPrice ( $ aBasketItem [ 'price' ] ) ; // Individual voucher is not multiplied by article amount if ( ! $ oSeries -> oxvoucherseries__oxcalculateonce -> value ) { $ oDiscountPrice -> multiply ( $ aBasketItem [ 'amount' ] ) ; $ oProductPrice -> multiply ( $ aBasketItem [ 'amount' ] ) ; } $ oVoucherPrice -> add ( $ oDiscountPrice -> getBruttoPrice ( ) ) ; $ oProductTotal -> add ( $ oProductPrice -> getBruttoPrice ( ) ) ; if ( ! empty ( $ aBasketItem [ 'discount' ] ) ) { $ blDiscountApplied = true ; } } $ dVoucher = $ oVoucherPrice -> getBruttoPrice ( ) ; $ dProduct = $ oProductTotal -> getBruttoPrice ( ) ; if ( $ dVoucher > $ dProduct ) { return $ dProduct ; } return $ dVoucher ; }
Returns the discount value used, if voucher is aplied only for specific products.

@param double $dPrice price to calculate discount on it

@throws oxVoucherException exception

@return double
Returns the discount value used if voucher is aplied only for specific products .