src/ShopBundle/objects/TShopBasket/TShopBasketDiscountCoreList.class.php
public function RemoveInvalidDiscounts($sMessangerName = null)
    {
        // since the min value of the basket for which a discount may work is affected by other discounts,
        // we need to remove the discounts first, and then add them one by one back to the basket
        // we suppress the add messages, but keep the negative messages

        $oMessageManager = TCMSMessageManager::GetInstance();

        // get copy of discounts
        $aDiscountList = $this->_items;
        $this->Destroy();
        foreach ($aDiscountList as $iDiscountKey => $oDiscount) {
            /** @var $oDiscount TdbShopDiscount */
            $cDiscountAllowUseCode = $oDiscount->AllowUseOfDiscount();
            if (TdbShopDiscount::ALLOW_USE == $cDiscountAllowUseCode) {
                $this->AddItem($oDiscount);
            } else {
                if (!is_null($sMessangerName)) {
                    // send message that the discount was removed
                    $aMessageData = $oDiscount->GetObjectPropertiesAsArray();
                    $aMessageData['iRemoveReasoneCode'] = $cDiscountAllowUseCode;
                    $oMessageManager->AddMessage($sMessangerName, 'DISCOUNT-ERROR-NO-LONGER-VALID-FOR-BASKET', $aMessageData);
                }
            }
        }
    }
public function RemoveInvalidDiscounts($sMessangerName = null)
    {
        // since the min value of the basket for which a discount may work is affected by other discounts,
        // we need to remove the discounts first, and then add them one by one back to the basket
        // we suppress the add messages, but keep the negative messages

        $oMessageManager = TCMSMessageManager::GetInstance();

        // get copy of discounts
        $aDiscountList = $this->_items;
        $this->Destroy();
        foreach ($aDiscountList as $iDiscountKey => $oDiscount) {
            /** @var $oDiscount TdbShopDiscount */
            $cDiscountAllowUseCode = $oDiscount->AllowUseOfDiscount();
            if (TdbShopDiscount::ALLOW_USE == $cDiscountAllowUseCode) {
                $this->AddItem($oDiscount);
            } else {
                if (!is_null($sMessangerName)) {
                    // send message that the discount was removed
                    $aMessageData = $oDiscount->GetObjectPropertiesAsArray();
                    $aMessageData['iRemoveReasoneCode'] = $cDiscountAllowUseCode;
                    $oMessageManager->AddMessage($sMessangerName, 'DISCOUNT-ERROR-NO-LONGER-VALID-FOR-BASKET', $aMessageData);
                }
            }
        }
    }
public function RemoveInvalidDiscounts ( $ sMessangerName = null ) { // since the min value of the basket for which a discount may work is affected by other discounts, // we need to remove the discounts first, and then add them one by one back to the basket // we suppress the add messages, but keep the negative messages $ oMessageManager = TCMSMessageManager :: GetInstance ( ) ; // get copy of discounts $ aDiscountList = $ this -> _items ; $ this -> Destroy ( ) ; foreach ( $ aDiscountList as $ iDiscountKey => $ oDiscount ) { /** @var $oDiscount TdbShopDiscount */ $ cDiscountAllowUseCode = $ oDiscount -> AllowUseOfDiscount ( ) ; if ( TdbShopDiscount :: ALLOW_USE == $ cDiscountAllowUseCode ) { $ this -> AddItem ( $ oDiscount ) ; } else { if ( ! is_null ( $ sMessangerName ) ) { // send message that the discount was removed $ aMessageData = $ oDiscount -> GetObjectPropertiesAsArray ( ) ; $ aMessageData [ 'iRemoveReasoneCode' ] = $ cDiscountAllowUseCode ; $ oMessageManager -> AddMessage ( $ sMessangerName , 'DISCOUNT-ERROR-NO-LONGER-VALID-FOR-BASKET' , $ aMessageData ) ; } } } }
Removes all discounts from the basket, that are not valid based on the contents of the basket and the current user
Returns the number of discounts removed.

@param string $sMessangerName - optional message manager to which we output why a discount was removed

@return int
Removes all discounts from the basket that are not valid based on the contents of the basket and the current user Returns the number of discounts removed .