source/Application/Controller/Admin/OrderMain.php
public function save()
    {
        parent::save();

        $soxId = $this->getEditObjectId();
        $aParams = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("editval");

        $oOrder = oxNew(\OxidEsales\Eshop\Application\Model\Order::class);
        if ($soxId != "-1") {
            $oOrder->load($soxId);
        } else {
            $aParams['oxorder__oxid'] = null;
        }

        $needOrderRecalculate = false;
        if (is_array($aParams)) {
            foreach ($aParams as $parameter => $value) {
                //parameter changes for not whitelisted parameters trigger order recalculation
                $orderField = $oOrder->$parameter;
                if (($value != $orderField->value) && !in_array($parameter, $this->fieldsTriggerNoOrderRecalculation)) {
                    $needOrderRecalculate = true;
                    continue;
                }
            }
        }

        //change payment
        $sPayId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("setPayment");
        if (!empty($sPayId) && ($sPayId != $oOrder->oxorder__oxpaymenttype->value)) {
            $aParams['oxorder__oxpaymenttype'] = $sPayId;
            $needOrderRecalculate = true;
        }

        $oOrder->assign($aParams);

        $aDynvalues = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("dynvalue");
        if (isset($aDynvalues)) {
            $oPayment = oxNew(\OxidEsales\Eshop\Application\Model\UserPayment::class);
            $oPayment->load($oOrder->oxorder__oxpaymentid->value);
            $oPayment->oxuserpayments__oxvalue->setValue(\OxidEsales\Eshop\Core\Registry::getUtils()->assignValuesToText($aDynvalues));
            $oPayment->save();
            $needOrderRecalculate = true;
        }
        //change delivery set
        $sDelSetId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("setDelSet");
        if (!empty($sDelSetId) && ($sDelSetId != $oOrder->oxorder__oxdeltype->value)) {
            $oOrder->oxorder__oxpaymenttype->setValue("oxempty");
            $oOrder->setDelivery($sDelSetId);
            $needOrderRecalculate = true;
        } else {
            // keeps old delivery cost
            $oOrder->reloadDelivery(false);
        }

        if ($needOrderRecalculate) {
            // keeps old discount
            $oOrder->reloadDiscount(false);
            $oOrder->recalculateOrder();
        } else {
            //nothing changed in order that requires a full recalculation
            $oOrder->save();
        }

        // set oxid if inserted
        $this->setEditObjectId($oOrder->getId());
    }
public function save()
    {
        parent::save();

        $soxId = $this->getEditObjectId();
        $aParams = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("editval");

        $oOrder = oxNew(\OxidEsales\Eshop\Application\Model\Order::class);
        if ($soxId != "-1") {
            $oOrder->load($soxId);
        } else {
            $aParams['oxorder__oxid'] = null;
        }

        $needOrderRecalculate = false;
        if (is_array($aParams)) {
            foreach ($aParams as $parameter => $value) {
                //parameter changes for not whitelisted parameters trigger order recalculation
                $orderField = $oOrder->$parameter;
                if (($value != $orderField->value) && !in_array($parameter, $this->fieldsTriggerNoOrderRecalculation)) {
                    $needOrderRecalculate = true;
                    continue;
                }
            }
        }

        //change payment
        $sPayId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("setPayment");
        if (!empty($sPayId) && ($sPayId != $oOrder->oxorder__oxpaymenttype->value)) {
            $aParams['oxorder__oxpaymenttype'] = $sPayId;
            $needOrderRecalculate = true;
        }

        $oOrder->assign($aParams);

        $aDynvalues = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("dynvalue");
        if (isset($aDynvalues)) {
            $oPayment = oxNew(\OxidEsales\Eshop\Application\Model\UserPayment::class);
            $oPayment->load($oOrder->oxorder__oxpaymentid->value);
            $oPayment->oxuserpayments__oxvalue->setValue(\OxidEsales\Eshop\Core\Registry::getUtils()->assignValuesToText($aDynvalues));
            $oPayment->save();
            $needOrderRecalculate = true;
        }
        //change delivery set
        $sDelSetId = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("setDelSet");
        if (!empty($sDelSetId) && ($sDelSetId != $oOrder->oxorder__oxdeltype->value)) {
            $oOrder->oxorder__oxpaymenttype->setValue("oxempty");
            $oOrder->setDelivery($sDelSetId);
            $needOrderRecalculate = true;
        } else {
            // keeps old delivery cost
            $oOrder->reloadDelivery(false);
        }

        if ($needOrderRecalculate) {
            // keeps old discount
            $oOrder->reloadDiscount(false);
            $oOrder->recalculateOrder();
        } else {
            //nothing changed in order that requires a full recalculation
            $oOrder->save();
        }

        // set oxid if inserted
        $this->setEditObjectId($oOrder->getId());
    }
public function save ( ) { parent :: save ( ) ; $ soxId = $ this -> getEditObjectId ( ) ; $ aParams = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "editval" ) ; $ oOrder = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Order :: class ) ; if ( $ soxId != "-1" ) { $ oOrder -> load ( $ soxId ) ; } else { $ aParams [ 'oxorder__oxid' ] = null ; } $ needOrderRecalculate = false ; if ( is_array ( $ aParams ) ) { foreach ( $ aParams as $ parameter => $ value ) { //parameter changes for not whitelisted parameters trigger order recalculation $ orderField = $ oOrder -> $ parameter ; if ( ( $ value != $ orderField -> value ) && ! in_array ( $ parameter , $ this -> fieldsTriggerNoOrderRecalculation ) ) { $ needOrderRecalculate = true ; continue ; } } } //change payment $ sPayId = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "setPayment" ) ; if ( ! empty ( $ sPayId ) && ( $ sPayId != $ oOrder -> oxorder__oxpaymenttype -> value ) ) { $ aParams [ 'oxorder__oxpaymenttype' ] = $ sPayId ; $ needOrderRecalculate = true ; } $ oOrder -> assign ( $ aParams ) ; $ aDynvalues = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "dynvalue" ) ; if ( isset ( $ aDynvalues ) ) { $ oPayment = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ UserPayment :: class ) ; $ oPayment -> load ( $ oOrder -> oxorder__oxpaymentid -> value ) ; $ oPayment -> oxuserpayments__oxvalue -> setValue ( \ OxidEsales \ Eshop \ Core \ Registry :: getUtils ( ) -> assignValuesToText ( $ aDynvalues ) ) ; $ oPayment -> save ( ) ; $ needOrderRecalculate = true ; } //change delivery set $ sDelSetId = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "setDelSet" ) ; if ( ! empty ( $ sDelSetId ) && ( $ sDelSetId != $ oOrder -> oxorder__oxdeltype -> value ) ) { $ oOrder -> oxorder__oxpaymenttype -> setValue ( "oxempty" ) ; $ oOrder -> setDelivery ( $ sDelSetId ) ; $ needOrderRecalculate = true ; } else { // keeps old delivery cost $ oOrder -> reloadDelivery ( false ) ; } if ( $ needOrderRecalculate ) { // keeps old discount $ oOrder -> reloadDiscount ( false ) ; $ oOrder -> recalculateOrder ( ) ; } else { //nothing changed in order that requires a full recalculation $ oOrder -> save ( ) ; } // set oxid if inserted $ this -> setEditObjectId ( $ oOrder -> getId ( ) ) ; }
Saves main orders configuration parameters.
Saves main orders configuration parameters .