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

        if (is_null($oBasket)) {
            $oBasket = TShopBasket::GetInstance();
        }
        $oMessageManager = TCMSMessageManager::GetInstance();

        // get copy of vouchers
        $aVoucherList = $this->_items;
        $this->Destroy();
        $bInvalidVouchersFound = false;
        foreach ($aVoucherList as $iVoucherKey => $oVoucher) {
            /** @var $oVoucher TdbShopVoucher */
            $cVoucherAllowUseCode = $oVoucher->AllowUseOfVoucher();
            if (TdbShopVoucher::ALLOW_USE == $cVoucherAllowUseCode) {
                $this->AddItem($oVoucher);
            } else {
                $bInvalidVouchersFound = true;
                $this->RemoveInvalidVoucherHook($oVoucher, $oBasket);
                // send message that the voucher was removed
                $aMessageData = $oVoucher->GetObjectPropertiesAsArray();
                $aMessageData['iRemoveReasoneCode'] = $cVoucherAllowUseCode;
                $oMessageManager->AddMessage($sMessangerName, 'VOUCHER-ERROR-NO-LONGER-VALID-FOR-BASKET', $aMessageData);
            }
        }

        if ($bInvalidVouchersFound) {
            // recalculate the basket
            $oBasket->RecalculateBasket();
        }
    }
public function RemoveInvalidVouchers($sMessangerName, $oBasket = null)
    {
        // since the min value of the basket for which a voucher may work is affected by other vouchers,
        // we need to remove the vouchers first, and then add them one by one back to the basket
        // we suppress the add messages, but keep the negative messages

        if (is_null($oBasket)) {
            $oBasket = TShopBasket::GetInstance();
        }
        $oMessageManager = TCMSMessageManager::GetInstance();

        // get copy of vouchers
        $aVoucherList = $this->_items;
        $this->Destroy();
        $bInvalidVouchersFound = false;
        foreach ($aVoucherList as $iVoucherKey => $oVoucher) {
            /** @var $oVoucher TdbShopVoucher */
            $cVoucherAllowUseCode = $oVoucher->AllowUseOfVoucher();
            if (TdbShopVoucher::ALLOW_USE == $cVoucherAllowUseCode) {
                $this->AddItem($oVoucher);
            } else {
                $bInvalidVouchersFound = true;
                $this->RemoveInvalidVoucherHook($oVoucher, $oBasket);
                // send message that the voucher was removed
                $aMessageData = $oVoucher->GetObjectPropertiesAsArray();
                $aMessageData['iRemoveReasoneCode'] = $cVoucherAllowUseCode;
                $oMessageManager->AddMessage($sMessangerName, 'VOUCHER-ERROR-NO-LONGER-VALID-FOR-BASKET', $aMessageData);
            }
        }

        if ($bInvalidVouchersFound) {
            // recalculate the basket
            $oBasket->RecalculateBasket();
        }
    }
public function RemoveInvalidVouchers ( $ sMessangerName , $ oBasket = null ) { // since the min value of the basket for which a voucher may work is affected by other vouchers, // we need to remove the vouchers first, and then add them one by one back to the basket // we suppress the add messages, but keep the negative messages if ( is_null ( $ oBasket ) ) { $ oBasket = TShopBasket :: GetInstance ( ) ; } $ oMessageManager = TCMSMessageManager :: GetInstance ( ) ; // get copy of vouchers $ aVoucherList = $ this -> _items ; $ this -> Destroy ( ) ; $ bInvalidVouchersFound = false ; foreach ( $ aVoucherList as $ iVoucherKey => $ oVoucher ) { /** @var $oVoucher TdbShopVoucher */ $ cVoucherAllowUseCode = $ oVoucher -> AllowUseOfVoucher ( ) ; if ( TdbShopVoucher :: ALLOW_USE == $ cVoucherAllowUseCode ) { $ this -> AddItem ( $ oVoucher ) ; } else { $ bInvalidVouchersFound = true ; $ this -> RemoveInvalidVoucherHook ( $ oVoucher , $ oBasket ) ; // send message that the voucher was removed $ aMessageData = $ oVoucher -> GetObjectPropertiesAsArray ( ) ; $ aMessageData [ 'iRemoveReasoneCode' ] = $ cVoucherAllowUseCode ; $ oMessageManager -> AddMessage ( $ sMessangerName , 'VOUCHER-ERROR-NO-LONGER-VALID-FOR-BASKET' , $ aMessageData ) ; } } if ( $ bInvalidVouchersFound ) { // recalculate the basket $ oBasket -> RecalculateBasket ( ) ; } }
Removes all vouchers from the basket, that are not valid based on the contents of the basket and the current user
Returns the number of vouchers removed.

@param string      $sMessangerName
@param TShopBasket $oBasket

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