src/ShopBundle/objects/TShopBasket/TShopBasketCore.class.php
protected function CheckBasketVoucherAvailable($sMessageConsumer)
    {
        $bBasketVoucherAvailable = true;
        $oVoucherList = $this->GetVoucherList();
        $oMessageManager = TCMSMessageManager::GetInstance();
        if ($oVoucherList) {
            if ($oVoucherList->Length() > 0) {
                $oVoucherList->GoToStart();
                while ($oBasketVoucher = $oVoucherList->Next()) {
                    $sVoucherCode = $oBasketVoucher->fieldCode;
                    $sBasketVoucherKey = $oBasketVoucher->sBasketVoucherKey;
                    $sBasketVoucherSeriesId = $oBasketVoucher->fieldShopVoucherSeriesId;
                    $oVoucher = TdbShopVoucher::GetNewInstance();
                    $bVoucherLoaded = $oVoucher->Load($oBasketVoucher->id);
                    if (($bVoucherLoaded && $oVoucher->fieldIsUsedUp) || !$bVoucherLoaded) {
                        $oNextAvailableVoucher = $this->GetNextAvailableVoucher($sVoucherCode, $sBasketVoucherSeriesId, $sMessageConsumer);

                        /**
                         * next voucher with same code is available, so auto add that one.
                         * as we do not want to inform the customer that this happened,
                         * we create a temporary message consumer for RemoveVoucher and AddVoucher messages and clear them afterwards.
                         */
                        if (!is_null($oNextAvailableVoucher)) {
                            $this->RemoveVoucher($sBasketVoucherKey, $sMessageConsumer.'-TO-BE-REMOVED');
                            $this->AddVoucher($oNextAvailableVoucher, $sMessageConsumer.'-TO-BE-REMOVED');
                            $oMessageManager->ClearMessages($sMessageConsumer.'-TO-BE-REMOVED');
                        } else {
                            $this->RemoveVoucher($sBasketVoucherKey, $sMessageConsumer);
                            $bBasketVoucherAvailable = false;
                            $this->bMarkAsRecalculationNeeded = true;
                            $oMsgManager = TCMSMessageManager::GetInstance();
                            $oMsgManager->AddMessage($sMessageConsumer, 'ERROR-ORDER-REQUEST-VOUCHER-NOT-LONGER-AVAILABLE', array('sVoucherCode' => $sVoucherCode));
                        }
                    }
                }
            }
        }

        return $bBasketVoucherAvailable;
    }
protected function CheckBasketVoucherAvailable($sMessageConsumer)
    {
        $bBasketVoucherAvailable = true;
        $oVoucherList = $this->GetVoucherList();
        $oMessageManager = TCMSMessageManager::GetInstance();
        if ($oVoucherList) {
            if ($oVoucherList->Length() > 0) {
                $oVoucherList->GoToStart();
                while ($oBasketVoucher = $oVoucherList->Next()) {
                    $sVoucherCode = $oBasketVoucher->fieldCode;
                    $sBasketVoucherKey = $oBasketVoucher->sBasketVoucherKey;
                    $sBasketVoucherSeriesId = $oBasketVoucher->fieldShopVoucherSeriesId;
                    $oVoucher = TdbShopVoucher::GetNewInstance();
                    $bVoucherLoaded = $oVoucher->Load($oBasketVoucher->id);
                    if (($bVoucherLoaded && $oVoucher->fieldIsUsedUp) || !$bVoucherLoaded) {
                        $oNextAvailableVoucher = $this->GetNextAvailableVoucher($sVoucherCode, $sBasketVoucherSeriesId, $sMessageConsumer);

                        /**
                         * next voucher with same code is available, so auto add that one.
                         * as we do not want to inform the customer that this happened,
                         * we create a temporary message consumer for RemoveVoucher and AddVoucher messages and clear them afterwards.
                         */
                        if (!is_null($oNextAvailableVoucher)) {
                            $this->RemoveVoucher($sBasketVoucherKey, $sMessageConsumer.'-TO-BE-REMOVED');
                            $this->AddVoucher($oNextAvailableVoucher, $sMessageConsumer.'-TO-BE-REMOVED');
                            $oMessageManager->ClearMessages($sMessageConsumer.'-TO-BE-REMOVED');
                        } else {
                            $this->RemoveVoucher($sBasketVoucherKey, $sMessageConsumer);
                            $bBasketVoucherAvailable = false;
                            $this->bMarkAsRecalculationNeeded = true;
                            $oMsgManager = TCMSMessageManager::GetInstance();
                            $oMsgManager->AddMessage($sMessageConsumer, 'ERROR-ORDER-REQUEST-VOUCHER-NOT-LONGER-AVAILABLE', array('sVoucherCode' => $sVoucherCode));
                        }
                    }
                }
            }
        }

        return $bBasketVoucherAvailable;
    }
protected function CheckBasketVoucherAvailable ( $ sMessageConsumer ) { $ bBasketVoucherAvailable = true ; $ oVoucherList = $ this -> GetVoucherList ( ) ; $ oMessageManager = TCMSMessageManager :: GetInstance ( ) ; if ( $ oVoucherList ) { if ( $ oVoucherList -> Length ( ) > 0 ) { $ oVoucherList -> GoToStart ( ) ; while ( $ oBasketVoucher = $ oVoucherList -> Next ( ) ) { $ sVoucherCode = $ oBasketVoucher -> fieldCode ; $ sBasketVoucherKey = $ oBasketVoucher -> sBasketVoucherKey ; $ sBasketVoucherSeriesId = $ oBasketVoucher -> fieldShopVoucherSeriesId ; $ oVoucher = TdbShopVoucher :: GetNewInstance ( ) ; $ bVoucherLoaded = $ oVoucher -> Load ( $ oBasketVoucher -> id ) ; if ( ( $ bVoucherLoaded && $ oVoucher -> fieldIsUsedUp ) || ! $ bVoucherLoaded ) { $ oNextAvailableVoucher = $ this -> GetNextAvailableVoucher ( $ sVoucherCode , $ sBasketVoucherSeriesId , $ sMessageConsumer ) ; /**
                         * next voucher with same code is available, so auto add that one.
                         * as we do not want to inform the customer that this happened,
                         * we create a temporary message consumer for RemoveVoucher and AddVoucher messages and clear them afterwards.
                         */ if ( ! is_null ( $ oNextAvailableVoucher ) ) { $ this -> RemoveVoucher ( $ sBasketVoucherKey , $ sMessageConsumer . '-TO-BE-REMOVED' ) ; $ this -> AddVoucher ( $ oNextAvailableVoucher , $ sMessageConsumer . '-TO-BE-REMOVED' ) ; $ oMessageManager -> ClearMessages ( $ sMessageConsumer . '-TO-BE-REMOVED' ) ; } else { $ this -> RemoveVoucher ( $ sBasketVoucherKey , $ sMessageConsumer ) ; $ bBasketVoucherAvailable = false ; $ this -> bMarkAsRecalculationNeeded = true ; $ oMsgManager = TCMSMessageManager :: GetInstance ( ) ; $ oMsgManager -> AddMessage ( $ sMessageConsumer , 'ERROR-ORDER-REQUEST-VOUCHER-NOT-LONGER-AVAILABLE' , array ( 'sVoucherCode' => $ sVoucherCode ) ) ; } } } } } return $ bBasketVoucherAvailable ; }
Check all vouchers in basket and check if voucher was not in use by other order.
If one voucher was used in other order try to get another one with in the same series and voucher code.

@param string $sMessageConsumer

@return bool
Check all vouchers in basket and check if voucher was not in use by other order . If one voucher was used in other order try to get another one with in the same series and voucher code .