src/ShopBundle/objects/TShopBasket/TShopBasketArticleCore.class.php
public function ApplyDiscount(TdbShopDiscount $oShopDiscount, $dMaxValueUsable = 0)
    {
        $dRemainingValue = 0;
        if (is_null($this->oActingShopDiscountList)) {
            $this->oActingShopDiscountList = new TShopBasketArticleDiscountList();
        }
        if ('absolut' == $oShopDiscount->fieldValueType) {
            $dUsedValue = $dMaxValueUsable;
            if ($this->dPriceTotalAfterDiscount < $dUsedValue) {
                $dUsedValue = $this->dPriceTotalAfterDiscount;
                $dRemainingValue = $dMaxValueUsable - $this->dPriceTotalAfterDiscount;
            }
            $oShopDiscount->dRealValueUsed = $dUsedValue;
        } else {
            $oShopDiscount->dRealValueUsed = round($this->dPriceTotalAfterDiscount * ($oShopDiscount->fieldValue / 100), 2);
        }
        $this->dPriceTotalAfterDiscount = $this->dPriceTotalAfterDiscount - $oShopDiscount->dRealValueUsed;
        $this->dPriceAfterDiscount = $this->dPriceTotalAfterDiscount / $this->dAmount;

        $this->dPriceAfterDiscountWithoutVouchers = $this->dPriceAfterDiscount;
        $this->dPriceTotalAfterDiscountWithoutVouchers = $this->dPriceTotalAfterDiscount;
        $this->oActingShopDiscountList->AddItem($oShopDiscount);

        return $dRemainingValue;
    }
public function ApplyDiscount(TdbShopDiscount $oShopDiscount, $dMaxValueUsable = 0)
    {
        $dRemainingValue = 0;
        if (is_null($this->oActingShopDiscountList)) {
            $this->oActingShopDiscountList = new TShopBasketArticleDiscountList();
        }
        if ('absolut' == $oShopDiscount->fieldValueType) {
            $dUsedValue = $dMaxValueUsable;
            if ($this->dPriceTotalAfterDiscount < $dUsedValue) {
                $dUsedValue = $this->dPriceTotalAfterDiscount;
                $dRemainingValue = $dMaxValueUsable - $this->dPriceTotalAfterDiscount;
            }
            $oShopDiscount->dRealValueUsed = $dUsedValue;
        } else {
            $oShopDiscount->dRealValueUsed = round($this->dPriceTotalAfterDiscount * ($oShopDiscount->fieldValue / 100), 2);
        }
        $this->dPriceTotalAfterDiscount = $this->dPriceTotalAfterDiscount - $oShopDiscount->dRealValueUsed;
        $this->dPriceAfterDiscount = $this->dPriceTotalAfterDiscount / $this->dAmount;

        $this->dPriceAfterDiscountWithoutVouchers = $this->dPriceAfterDiscount;
        $this->dPriceTotalAfterDiscountWithoutVouchers = $this->dPriceTotalAfterDiscount;
        $this->oActingShopDiscountList->AddItem($oShopDiscount);

        return $dRemainingValue;
    }
public function ApplyDiscount ( TdbShopDiscount $ oShopDiscount , $ dMaxValueUsable = 0 ) { $ dRemainingValue = 0 ; if ( is_null ( $ this -> oActingShopDiscountList ) ) { $ this -> oActingShopDiscountList = new TShopBasketArticleDiscountList ( ) ; } if ( 'absolut' == $ oShopDiscount -> fieldValueType ) { $ dUsedValue = $ dMaxValueUsable ; if ( $ this -> dPriceTotalAfterDiscount < $ dUsedValue ) { $ dUsedValue = $ this -> dPriceTotalAfterDiscount ; $ dRemainingValue = $ dMaxValueUsable - $ this -> dPriceTotalAfterDiscount ; } $ oShopDiscount -> dRealValueUsed = $ dUsedValue ; } else { $ oShopDiscount -> dRealValueUsed = round ( $ this -> dPriceTotalAfterDiscount * ( $ oShopDiscount -> fieldValue / 100 ) , 2 ) ; } $ this -> dPriceTotalAfterDiscount = $ this -> dPriceTotalAfterDiscount - $ oShopDiscount -> dRealValueUsed ; $ this -> dPriceAfterDiscount = $ this -> dPriceTotalAfterDiscount / $ this -> dAmount ; $ this -> dPriceAfterDiscountWithoutVouchers = $ this -> dPriceAfterDiscount ; $ this -> dPriceTotalAfterDiscountWithoutVouchers = $ this -> dPriceTotalAfterDiscount ; $ this -> oActingShopDiscountList -> AddItem ( $ oShopDiscount ) ; return $ dRemainingValue ; }
apply a discount to the article (note that the method will not check if the discount
may be applied - it assumes you checked that using the function in TShopDiscount.

@param TdbShopDiscount $oShopDiscount
@param dobule          $dMaxValueUsable - for absolute value discounts, this parameter defines how much may be at most applied to the article

@return float - returns the remaining discount value to distribute (0 if the discount is a percent discount)
apply a discount to the article ( note that the method will not check if the discount may be applied - it assumes you checked that using the function in TShopDiscount .