src/ShopBundle/objects/db/TShopVoucher.class.php
public function GetValue($bCalculateVoucher = false, $dMaxValueAllowed = null, $bSponsoredVouchers = false)
    {
        if ($bCalculateVoucher) {
            $oSeries = &$this->GetFieldShopVoucherSeries();
            $dValue = $oSeries->fieldValue;
            $oBasket = TShopBasket::GetInstance();
            $dBasketValueApplicableForVoucher = $oBasket->GetBasketSumForVoucher($this);
            if ('prozent' == $oSeries->fieldValueType) {
                $dValue = round($dBasketValueApplicableForVoucher * ($dValue / 100), 2);
            } else {
                // now we need to subtract the amount already used...
                $dValue = $dValue - $this->GetValuePreviouslyUsed_GetValueHook();
            }

            // now if the voucher is worth more than the current basket, we need to use only the part that we can
            if ($dBasketValueApplicableForVoucher < $dValue) {
                $dValue = $dBasketValueApplicableForVoucher;
            }
            if ($dValue > $dMaxValueAllowed) {
                $dValue = $dMaxValueAllowed;
            }

            // if this is a NOT sponsored voucher, we need to reduce the article value
            if (false == $bSponsoredVouchers) {
                $oBasket->ApplyNoneSponsoredVoucherValueToItems($this, $dValue);
            }
            $this->voucherValueInBasket = $dValue;
        }

        return $this->voucherValueInBasket;
    }
public function GetValue($bCalculateVoucher = false, $dMaxValueAllowed = null, $bSponsoredVouchers = false)
    {
        if ($bCalculateVoucher) {
            $oSeries = &$this->GetFieldShopVoucherSeries();
            $dValue = $oSeries->fieldValue;
            $oBasket = TShopBasket::GetInstance();
            $dBasketValueApplicableForVoucher = $oBasket->GetBasketSumForVoucher($this);
            if ('prozent' == $oSeries->fieldValueType) {
                $dValue = round($dBasketValueApplicableForVoucher * ($dValue / 100), 2);
            } else {
                // now we need to subtract the amount already used...
                $dValue = $dValue - $this->GetValuePreviouslyUsed_GetValueHook();
            }

            // now if the voucher is worth more than the current basket, we need to use only the part that we can
            if ($dBasketValueApplicableForVoucher < $dValue) {
                $dValue = $dBasketValueApplicableForVoucher;
            }
            if ($dValue > $dMaxValueAllowed) {
                $dValue = $dMaxValueAllowed;
            }

            // if this is a NOT sponsored voucher, we need to reduce the article value
            if (false == $bSponsoredVouchers) {
                $oBasket->ApplyNoneSponsoredVoucherValueToItems($this, $dValue);
            }
            $this->voucherValueInBasket = $dValue;
        }

        return $this->voucherValueInBasket;
    }
public function GetValue ( $ bCalculateVoucher = false , $ dMaxValueAllowed = null , $ bSponsoredVouchers = false ) { if ( $ bCalculateVoucher ) { $ oSeries = & $ this -> GetFieldShopVoucherSeries ( ) ; $ dValue = $ oSeries -> fieldValue ; $ oBasket = TShopBasket :: GetInstance ( ) ; $ dBasketValueApplicableForVoucher = $ oBasket -> GetBasketSumForVoucher ( $ this ) ; if ( 'prozent' == $ oSeries -> fieldValueType ) { $ dValue = round ( $ dBasketValueApplicableForVoucher * ( $ dValue / 100 ) , 2 ) ; } else { // now we need to subtract the amount already used... $ dValue = $ dValue - $ this -> GetValuePreviouslyUsed_GetValueHook ( ) ; } // now if the voucher is worth more than the current basket, we need to use only the part that we can if ( $ dBasketValueApplicableForVoucher < $ dValue ) { $ dValue = $ dBasketValueApplicableForVoucher ; } if ( $ dValue > $ dMaxValueAllowed ) { $ dValue = $ dMaxValueAllowed ; } // if this is a NOT sponsored voucher, we need to reduce the article value if ( false == $ bSponsoredVouchers ) { $ oBasket -> ApplyNoneSponsoredVoucherValueToItems ( $ this , $ dValue ) ; } $ this -> voucherValueInBasket = $ dValue ; } return $ this -> voucherValueInBasket ; }
Returns the value of the voucher - takes the current basket and user into consideration.

@param bool  $bCalculateVoucher - set to true when we calculate the voucher value for the basket
this should only be set to true when calling the method through the TShopBasketVoucherList::GetVoucherValue
@param float $dMaxValueAllowed  - if a value is passed, then the voucher will never exceed the value passed

@return float
Returns the value of the voucher - takes the current basket and user into consideration .