src/ShopBundle/objects/TShopBasket/TShopBasketCore.class.php
protected function CreateOrderAllowCreation($sMessageConsumer, $bSkipPaymentValidation = false)
    {
        $oMsgManager = TCMSMessageManager::GetInstance();
        $bAllowCreation = true;

        if ($bAllowCreation) {
            if ($this->LockIsActive()) {
                // the order has already been created...
                $oMsgManager->AddMessage($sMessageConsumer, 'ERROR-ORDER-REQUEST-CREATE-ON-ALREADY-CREATED-ORDER');
                $bAllowCreation = false;
                // kill basket, and reset key
                $oBasket = TShopBasket::GetInstance();
                $this->UnlockBasket();
                $oBasket->ClearBasket();
                unset($oBasket);
            }
        }

        if ($bAllowCreation) {
            // prevent order creation if the last order is less then 10 seconds ago - the system will prevent this anyway, but we need to
            // show the user a sensible error message in this case
            if (true === $this->isReorderDueToDoubleClick()) {
                $bAllowCreation = false;
                $oMsgManager->AddMessage($sMessageConsumer, 'ERROR-ORDER-REQUEST-CREATE-ON-ALREADY-CREATED-ORDER');
            }
        }

        if ($bAllowCreation) {
            // now check if there are article in the basket
            if ($this->dCostTotal < 0) {
                // negativ orders are not permitted
                $oMsgManager->AddMessage($sMessageConsumer, 'ERROR-ORDER-REQUEST-CREATE-NEGATIV-ORDER');
                $bAllowCreation = false;
            }
        }

        if ($bAllowCreation) {
            if ($this->iTotalNumberOfUniqueArticles < 1 || $this->dTotalNumberOfArticles <= 0) {
                // no articles in order
                $oMsgManager->AddMessage($sMessageConsumer, 'ERROR-ORDER-REQUEST-CREATE-EMPTY-ORDER');
                $bAllowCreation = false;
            }
        }

        if ($bAllowCreation) {
            // check to make sure we have a billing addres for the user
            $oUser = TdbDataExtranetUser::GetInstance();
            $oBillingAdr = $oUser->GetBillingAddress();
            if (is_null($oBillingAdr) || !$oBillingAdr->ContainsData()) {
                $oMsgManager->AddMessage($sMessageConsumer, 'ERROR-ORDER-REQUEST-USER-HAS-NO-BILLING-ADDRESS');
                $bAllowCreation = false;
            }
        }

        if ($bAllowCreation) {
            // check if shipping and payment have been selected
            if (false == $this->HasValidShippingGroup()) {
                $oMsgManager->AddMessage($sMessageConsumer, 'ERROR-ORDER-REQUEST-SHIPPING-GROUP-NOT-VALID');
                $bAllowCreation = false;
            }
        }

        if ($bAllowCreation) {
            if (!$bSkipPaymentValidation) {
                if (false == $this->HasValidPaymentMethod()) {
                    $oMsgManager->AddMessage($sMessageConsumer, 'ERROR-ORDER-REQUEST-PAYMENT-METHOD-NOT-VALID');
                    $bAllowCreation = false;
                }
            }
        }

        return $bAllowCreation;
    }
protected function CreateOrderAllowCreation($sMessageConsumer, $bSkipPaymentValidation = false)
    {
        $oMsgManager = TCMSMessageManager::GetInstance();
        $bAllowCreation = true;

        if ($bAllowCreation) {
            if ($this->LockIsActive()) {
                // the order has already been created...
                $oMsgManager->AddMessage($sMessageConsumer, 'ERROR-ORDER-REQUEST-CREATE-ON-ALREADY-CREATED-ORDER');
                $bAllowCreation = false;
                // kill basket, and reset key
                $oBasket = TShopBasket::GetInstance();
                $this->UnlockBasket();
                $oBasket->ClearBasket();
                unset($oBasket);
            }
        }

        if ($bAllowCreation) {
            // prevent order creation if the last order is less then 10 seconds ago - the system will prevent this anyway, but we need to
            // show the user a sensible error message in this case
            if (true === $this->isReorderDueToDoubleClick()) {
                $bAllowCreation = false;
                $oMsgManager->AddMessage($sMessageConsumer, 'ERROR-ORDER-REQUEST-CREATE-ON-ALREADY-CREATED-ORDER');
            }
        }

        if ($bAllowCreation) {
            // now check if there are article in the basket
            if ($this->dCostTotal < 0) {
                // negativ orders are not permitted
                $oMsgManager->AddMessage($sMessageConsumer, 'ERROR-ORDER-REQUEST-CREATE-NEGATIV-ORDER');
                $bAllowCreation = false;
            }
        }

        if ($bAllowCreation) {
            if ($this->iTotalNumberOfUniqueArticles < 1 || $this->dTotalNumberOfArticles <= 0) {
                // no articles in order
                $oMsgManager->AddMessage($sMessageConsumer, 'ERROR-ORDER-REQUEST-CREATE-EMPTY-ORDER');
                $bAllowCreation = false;
            }
        }

        if ($bAllowCreation) {
            // check to make sure we have a billing addres for the user
            $oUser = TdbDataExtranetUser::GetInstance();
            $oBillingAdr = $oUser->GetBillingAddress();
            if (is_null($oBillingAdr) || !$oBillingAdr->ContainsData()) {
                $oMsgManager->AddMessage($sMessageConsumer, 'ERROR-ORDER-REQUEST-USER-HAS-NO-BILLING-ADDRESS');
                $bAllowCreation = false;
            }
        }

        if ($bAllowCreation) {
            // check if shipping and payment have been selected
            if (false == $this->HasValidShippingGroup()) {
                $oMsgManager->AddMessage($sMessageConsumer, 'ERROR-ORDER-REQUEST-SHIPPING-GROUP-NOT-VALID');
                $bAllowCreation = false;
            }
        }

        if ($bAllowCreation) {
            if (!$bSkipPaymentValidation) {
                if (false == $this->HasValidPaymentMethod()) {
                    $oMsgManager->AddMessage($sMessageConsumer, 'ERROR-ORDER-REQUEST-PAYMENT-METHOD-NOT-VALID');
                    $bAllowCreation = false;
                }
            }
        }

        return $bAllowCreation;
    }
protected function CreateOrderAllowCreation ( $ sMessageConsumer , $ bSkipPaymentValidation = false ) { $ oMsgManager = TCMSMessageManager :: GetInstance ( ) ; $ bAllowCreation = true ; if ( $ bAllowCreation ) { if ( $ this -> LockIsActive ( ) ) { // the order has already been created... $ oMsgManager -> AddMessage ( $ sMessageConsumer , 'ERROR-ORDER-REQUEST-CREATE-ON-ALREADY-CREATED-ORDER' ) ; $ bAllowCreation = false ; // kill basket, and reset key $ oBasket = TShopBasket :: GetInstance ( ) ; $ this -> UnlockBasket ( ) ; $ oBasket -> ClearBasket ( ) ; unset ( $ oBasket ) ; } } if ( $ bAllowCreation ) { // prevent order creation if the last order is less then 10 seconds ago - the system will prevent this anyway, but we need to // show the user a sensible error message in this case if ( true === $ this -> isReorderDueToDoubleClick ( ) ) { $ bAllowCreation = false ; $ oMsgManager -> AddMessage ( $ sMessageConsumer , 'ERROR-ORDER-REQUEST-CREATE-ON-ALREADY-CREATED-ORDER' ) ; } } if ( $ bAllowCreation ) { // now check if there are article in the basket if ( $ this -> dCostTotal < 0 ) { // negativ orders are not permitted $ oMsgManager -> AddMessage ( $ sMessageConsumer , 'ERROR-ORDER-REQUEST-CREATE-NEGATIV-ORDER' ) ; $ bAllowCreation = false ; } } if ( $ bAllowCreation ) { if ( $ this -> iTotalNumberOfUniqueArticles < 1 || $ this -> dTotalNumberOfArticles <= 0 ) { // no articles in order $ oMsgManager -> AddMessage ( $ sMessageConsumer , 'ERROR-ORDER-REQUEST-CREATE-EMPTY-ORDER' ) ; $ bAllowCreation = false ; } } if ( $ bAllowCreation ) { // check to make sure we have a billing addres for the user $ oUser = TdbDataExtranetUser :: GetInstance ( ) ; $ oBillingAdr = $ oUser -> GetBillingAddress ( ) ; if ( is_null ( $ oBillingAdr ) || ! $ oBillingAdr -> ContainsData ( ) ) { $ oMsgManager -> AddMessage ( $ sMessageConsumer , 'ERROR-ORDER-REQUEST-USER-HAS-NO-BILLING-ADDRESS' ) ; $ bAllowCreation = false ; } } if ( $ bAllowCreation ) { // check if shipping and payment have been selected if ( false == $ this -> HasValidShippingGroup ( ) ) { $ oMsgManager -> AddMessage ( $ sMessageConsumer , 'ERROR-ORDER-REQUEST-SHIPPING-GROUP-NOT-VALID' ) ; $ bAllowCreation = false ; } } if ( $ bAllowCreation ) { if ( ! $ bSkipPaymentValidation ) { if ( false == $ this -> HasValidPaymentMethod ( ) ) { $ oMsgManager -> AddMessage ( $ sMessageConsumer , 'ERROR-ORDER-REQUEST-PAYMENT-METHOD-NOT-VALID' ) ; $ bAllowCreation = false ; } } } return $ bAllowCreation ; }
return true if the basket may be saved as an order, false if we want to prevent saving the order.

@param string $sMessageConsumer       - message manager who we want to send errors to
@param bool   $bSkipPaymentValidation - set to true if you want to skip the validation of the selected payment method

@return bool
return true if the basket may be saved as an order false if we want to prevent saving the order .