method can be used to modify the data saved to order before the save is executed.

@param TShopBasket $oBasket
@param array       $aOrderData
169946
protected function LoadFromBasketPostProcessData($oBasket, &$aOrderData)
    {
        parent::LoadFromBasketPostProcessData($oBasket, $aOrderData);
        $oUser = TdbDataExtranetUser::GetInstance();
        $oShipping = $oUser->GetShippingAddress();
        $aOrderData['adr_shipping_is_dhl_packstation'] = $oShipping->fieldIsDhlPackstation;
    }
1320654
public function setQuickCheckoutBasket()
    {
        $oObjectFactory = $this->getObjectFactory();
        $oSession = $this->getSession();

        // Create new temp basket and copy the products to it
        $oCurrentBasket = $oSession->getBasket();
        $oSession->setVariable(self::BESTITAMAZONPAY_TEMP_BASKET, serialize($oCurrentBasket));

        //Reset current basket
        $oSession->setBasket($oObjectFactory->createOxidObject('oxBasket'));
    }
963017
public function SendShopReviewMail($aOrder)
    {
        $bMailWasSend = false;

        $oUser = TdbDataExtranetUser::GetNewInstance();
        $oUser->Load($aOrder['data_extranet_user_id']);

        if ($this->AllowSendingMailForOrder($oUser, $aOrder)) {
            $oRatingService = $this->GetSuitableRatingService($oUser, $aOrder);
            if (null !== $oRatingService) {
                $bMailWasSend = $oRatingService->SendShopRatingEmail($oUser, $aOrder);
                if ($bMailWasSend) {
                    $query = "UPDATE `shop_order` SET `pkg_shop_rating_service_mail_sent` = '1', `pkg_shop_rating_service_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($oRatingService->id)."' WHERE `id` = '".MySqlLegacySupport::getInstance()->real_escape_string($aOrder['id'])."'";
                    MySqlLegacySupport::getInstance()->query($query);
                    if (false == $this->bDisableSentHistory) {
                        $sNewID = TTools::GetUUID();
                        $iSendDate = date('Y-m-d H:i:s');
                        $query = "INSERT INTO `pkg_shop_rating_service_history`
                               SET `id` = '".MySqlLegacySupport::getInstance()->real_escape_string($sNewID)."',
                                   `data_extranet_user_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($oUser->id)."',
                                   `shop_order_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($aOrder['id'])."',
                                   `date` = '".MySqlLegacySupport::getInstance()->real_escape_string($iSendDate)."',
                                   `pkg_shop_rating_service_id_list` = '".MySqlLegacySupport::getInstance()->real_escape_string($oRatingService->id)."'
                           ";
                        if ($this->bDebug) {
                            echo __LINE__.': '.$query."\n<br />\n";
                        }
                        MySqlLegacySupport::getInstance()->query($query);
                    }
                }
            }
        }

        return $bMailWasSend;
    }
252122
public function validatePayment( $oBasket )
    {
        $mReturn = $this->_OxpsPaymorrowOxOrder_validatePayment_parent( $oBasket );

        if ( is_null( $mReturn ) ) {

            /** @var oxPayment|OxpsPaymorrowOxPayment $oPayment */
            $oPayment = oxNew( 'oxPayment' );
            $sPaymentId = (string) $oBasket->getPaymentId();

            if ( !$oPayment->load( $sPaymentId ) or !$oPayment->isPaymorrowActiveAndMapped() ) {
                return $mReturn;
            }

            /** @var OxpsPaymorrowRequestControllerProxy $pmGateWay */
            $pmGateWay = oxNew( 'OxpsPaymorrowRequestControllerProxy');

            if ( !$pmGateWay->validatePendingOrder() ) {

                return self::ORDER_STATE_INVALIDPAYMENT;
            }
        }

        return $mReturn;
    }
416664
protected function _validateBasket(\OxidEsales\Eshop\Application\Model\Basket $oBasket)
    {
        $aCurrContent = $oBasket->getContents();
        if (empty($aCurrContent)) {
            return;
        }

        $iCurrLang = \OxidEsales\Eshop\Core\Registry::getLang()->getBaseLanguage();
        foreach ($aCurrContent as $oContent) {
            if ($oContent->getLanguageId() != $iCurrLang) {
                $oContent->setLanguageId($iCurrLang);
            }
        }
    }
763089
protected function GetBasketStatistics($oBasket)
    {
        $sBasketstatistics = '';
        $sBasketstatistics .= "------------------------------------\r\n\r\n";
        $sBasketstatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.basket_content')."\r\n";
        $sBasketstatistics .= "------------------------------------\r\n";
        $oArticleList = $oBasket->GetBasketContents();
        $oArticleList->GoToStart();
        while ($oArticle = $oArticleList->Next()) {
            $sBasketstatistics .= TGlobal::Translate(
                    'chameleon_system_shop.cron_send_basket_stats.basket_content_line',
                    array(
                        '%amount%' => '',
                        '%name%' => '',
                        '%price%' => '',
                        '%totalPrice%' => '',
                    )
                )."\r\n";
        }
        $sBasketstatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.basket_content_total', array('%basketTotal%' => $oBasket->dCostArticlesTotal))."\r\n";
        $this->sTotalMoneyCanceled = $this->sTotalMoneyCanceled + $oBasket->dCostArticlesTotal;
        $sBasketstatistics .= "------------------------------------\r\n";

        return $sBasketstatistics;
    }
961859
public function SaveVouchers(TShopBasketVoucherList $oBasketVoucherList)
    {
        if (!is_null($this->id) && !is_null($oBasketVoucherList) && $oBasketVoucherList->Length() > 0) {
            $oBasketVoucherList->GoToStart();
            while ($oVoucherItemUsed = $oBasketVoucherList->Next()) {
                $oVoucherItemUsed->CommitVoucherUseForCurrentUser($this->id);
            }
        }
    }
396138
public function CommitVoucherUseForCurrentUser($iShopOrderId)
    {
        $oShopVoucherUse = TdbShopVoucherUse::GetNewInstance();
        /** @var $oShopvoucherUse TdbShopVoucherUse */
        $aData = array('shop_voucher_id' => $this->id, 'date_used' => date('Y-m-d H:i:s'), 'value_used' => $this->GetValue(), 'shop_order_id' => $iShopOrderId);
        // hook to post-convert value (as may be required when dealing with currency)
        $this->CommitVoucherUseForCurrentUserPreSaveHook($aData);
        $oShopVoucherUse->LoadFromRow($aData);
        $oShopVoucherUse->AllowEditByAll(true);
        $oShopVoucherUse->Save();

        if ($this->checkMarkVoucherAsCompletelyUsed()) {
            $this->MarkVoucherAsCompletelyUsed();
        }
    }
1335930
protected function SetShippingTypeForArticle(TShopBasketArticle &$oItem, TdbShopShippingType &$oShippingType)
    {
        $iCurrentPos = $this->getItemPointer();
        $this->GoToStart();
        $bFound = false;
        while (!$bFound && ($oExistingItem = &$this->Next())) {
            /** @var $oExistingItem TShopBasketArticle */
            if ($oExistingItem->IsSameAs($oItem)) {
                $bFound = true;
            }
        }
        if ($bFound) {
            $oExistingItem->SetActingShippingType($oShippingType);
        }
        $this->setItemPointer($iCurrentPos);
    }
226050
public function saveOrder($orderData, $shop)
    {
        $endpoint = 'woocommerce/alternative_save_order';

        $params = array_merge($this->prepareParams(), ['order_data' => $orderData, 'shop' => $shop] );

        return $this->restClient->post( $endpoint, $params );
    }
1225510
protected function PostUpdateItemHook($oUpdatedItem)
    {
        reset($this->aObservers);
        foreach (array_keys($this->aObservers) as $sObserverName) {
            $this->aObservers[$sObserverName]->OnBasketItemUpdateEvent($oUpdatedItem);
        }
    }
231548
public function validateDelivery($oBasket)
    {
        // proceed with no delivery
        // used for other countries
        if ($oBasket->getPaymentId() == 'oxempty') {
            return;
        }
        // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804).
        $masterDb = \OxidEsales\Eshop\Core\DatabaseProvider::getMaster();

        $oDelSet = oxNew(\OxidEsales\Eshop\Application\Model\DeliverySet::class);
        $sTable = $oDelSet->getViewName();

        $sQ = "select 1 from {$sTable} where {$sTable}.oxid=" .
              $masterDb->quote($oBasket->getShippingId()) . " and " . $oDelSet->getSqlActiveSnippet();

        // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804).
        if (!$masterDb->getOne($sQ)) {
            // throwing exception
            return self::ORDER_STATE_INVALIDDELIVERY;
        }
    }
183
public function getBaseBasketPriceForPaymentCostCalc($oBasket)
    {
        $dBasketPrice = 0;
        $iRules = $this->oxpayments__oxaddsumrules->value;

        // products brutto price
        if (!$iRules || ($iRules & self::PAYMENT_ADDSUMRULE_ALLGOODS)) {
            $dBasketPrice += $oBasket->getProductsPrice()->getSum($oBasket->isCalculationModeNetto());
        }

        // discounts
        if ((!$iRules || ($iRules & self::PAYMENT_ADDSUMRULE_DISCOUNTS)) &&
            ($oCosts = $oBasket->getTotalDiscount())
        ) {
            $dBasketPrice -= $oCosts->getPrice();
        }

        // vouchers
        if (!$iRules || ($iRules & self::PAYMENT_ADDSUMRULE_VOUCHERS)) {
            $dBasketPrice -= $oBasket->getVoucherDiscValue();
        }

        // delivery
        if ((!$iRules || ($iRules & self::PAYMENT_ADDSUMRULE_SHIPCOSTS)) &&
            ($oCosts = $oBasket->getCosts('oxdelivery'))
        ) {
            if ($oBasket->isCalculationModeNetto()) {
                $dBasketPrice += $oCosts->getNettoPrice();
            } else {
                $dBasketPrice += $oCosts->getBruttoPrice();
            }
        }

        // wrapping
        if (($iRules & self::PAYMENT_ADDSUMRULE_GIFTS) &&
            ($oCosts = $oBasket->getCosts('oxwrapping'))
        ) {
            if ($oBasket->isCalculationModeNetto()) {
                $dBasketPrice += $oCosts->getNettoPrice();
            } else {
                $dBasketPrice += $oCosts->getBruttoPrice();
            }
        }

        // gift card
        if (($iRules & self::PAYMENT_ADDSUMRULE_GIFTS) &&
            ($oCosts = $oBasket->getCosts('oxgiftcard'))
        ) {
            if ($oBasket->isCalculationModeNetto()) {
                $dBasketPrice += $oCosts->getNettoPrice();
            } else {
                $dBasketPrice += $oCosts->getBruttoPrice();
            }
        }

        return $dBasketPrice;
    }
710406
public function loadOrderArticles($aOrders)
    {
        if (!count($aOrders)) {
            $this->clear();

            return;
        }

        foreach ($aOrders as $iKey => $oOrder) {
            $aOrdersIds[] = $oOrder->getId();
        }

        $oBaseObject = $this->getBaseObject();
        $sArticleTable = $oBaseObject->getViewName();
        $sArticleFields = $oBaseObject->getSelectFields();
        $sArticleFields = str_replace("`$sArticleTable`.`oxid`", "`oxorderarticles`.`oxartid` AS `oxid`", $sArticleFields);

        $sSelect = "SELECT $sArticleFields FROM oxorderarticles ";
        $sSelect .= "left join $sArticleTable on oxorderarticles.oxartid = $sArticleTable.oxid ";
        $sSelect .= "WHERE oxorderarticles.oxorderid IN ( '" . implode("','", $aOrdersIds) . "' ) ";
        $sSelect .= "order by $sArticleTable.oxid ";

        $this->selectString($sSelect);

        // not active or not available products must not have button "tobasket"
        $sNow = date('Y-m-d H:i:s');
        foreach ($this as $oArticle) {
            if (!$oArticle->oxarticles__oxactive->value &&
                ($oArticle->oxarticles__oxactivefrom->value > $sNow ||
                 $oArticle->oxarticles__oxactiveto->value < $sNow
                )
            ) {
                $oArticle->setBuyableState(false);
            }
        }
    }
1216967
public function ExecutePayment(TdbShopOrder &$oOrder, $sMessageConsumer = '')
    {
        $bPaymentOk = parent::ExecutePayment($oOrder);

        if ($bPaymentOk && $this->TransactionMatchesCurrentBasketState()) {
            $bPaymentOk = $this->UpdateTransaction('SAS'); //capture
        } else {
            $bPaymentOk = false;
        }

        return $bPaymentOk;
    }
1370977
protected function _setOrderTransactionErrorStatus(oxOrder $oOrder, stdClass $oData, $sStatus = null)
    {
        if (isset($oData->Error->Code) && (bool) $oData->Error->Code !== false) {
            if ($sStatus === null) {
                $sStatus = 'AMZ-Error-'.$oData->Error->Code;
            }

            $oOrder->assign(array('oxtransstatus' => $sStatus));
            $oOrder->save();

            return true;
        }

        return false;
    }
527223
public function validateOrder($oBasket, $oUser)
    {
        // validating stock
        $iValidState = $this->validateStock($oBasket);

        if (!$iValidState) {
            // validating delivery
            $iValidState = $this->validateDelivery($oBasket);
        }

        if (!$iValidState) {
            // validating payment
            $iValidState = $this->validatePayment($oBasket);
        }

        if (!$iValidState) {
            //0003110 validating delivery address, it is not be changed during checkout process
            $iValidState = $this->validateDeliveryAddress($oUser);
        }

        if (!$iValidState) {
            // validating minimum price
            $iValidState = $this->validateBasket($oBasket);
        }

        return $iValidState;
    }