239 $this->
init(
'oxorder');
255 if ($sName ==
'oDelSet') {
259 if ($sName ==
'oxorder__oxbillcountry') {
263 if ($sName ==
'oxorder__oxdelcountry') {
283 $this->oxorder__oxorderdate =
new oxField($oUtilsDate->formatDBDate($this->oxorder__oxorderdate->value));
284 $this->oxorder__oxsenddate =
new oxField($oUtilsDate->formatDBDate($this->oxorder__oxsenddate->value));
297 if ($sCountryId && $sCountryId !=
'-1') {
298 $oCountry =
oxNew(
'oxcountry');
300 $sTitle = $oCountry->oxcountry__oxtitle->value;
315 $sSelect =
"SELECT `oxorderarticles`.* FROM `oxorderarticles`
316 WHERE `oxorderarticles`.`oxorderid` = '" . $this->
getId() .
"'" .
317 ($blExcludeCanceled ?
" AND `oxorderarticles`.`oxstorno` != 1 " :
" ") .
"
318 ORDER BY `oxorderarticles`.`oxartid`, `oxorderarticles`.`oxselvariant`, `oxorderarticles`.`oxpersparam` ";
321 $oArticles =
oxNew(
'oxlist');
322 $oArticles->init(
'oxorderarticle');
323 $oArticles->selectString($sSelect);
338 if ($blExcludeCanceled) {
342 } elseif ($this->_oArticles === null) {
356 $this->_oArticles = $oOrderArticleList;
366 if ($this->_oDelPrice != null) {
370 $this->_oDelPrice =
oxNew(
'oxprice');
371 $this->_oDelPrice->setBruttoPriceMode();
372 $this->_oDelPrice->setPrice($this->oxorder__oxdelcost->value, $this->oxorder__oxdelvat->value);
384 if ($this->_oWrappingPrice != null) {
388 $this->_oWrappingPrice =
oxNew(
'oxprice');
389 $this->_oWrappingPrice->setBruttoPriceMode();
390 $this->_oWrappingPrice->setPrice($this->oxorder__oxwrapcost->value, $this->oxorder__oxwrapvat->value);
402 if ($this->_oGidtCardPrice != null) {
403 return $this->_oGidtCardPrice;
406 $this->_oGidtCardPrice =
oxNew(
'oxprice');
407 $this->_oGidtCardPrice->setBruttoPriceMode();
408 $this->_oGidtCardPrice->setPrice($this->oxorder__oxgiftcardcost->value, $this->oxorder__oxgiftcardvat->value);
410 return $this->_oGidtCardPrice;
421 if ($this->_oPaymentPrice != null) {
425 $this->_oPaymentPrice =
oxNew(
'oxprice');
426 $this->_oPaymentPrice->setBruttoPriceMode();
427 $this->_oPaymentPrice->setPrice($this->oxorder__oxpaycost->value, $this->oxorder__oxpayvat->value);
441 if ($this->_oTsProtectionPrice != null) {
445 $this->_oTsProtectionPrice =
oxNew(
'oxprice');
446 $this->_oTsProtectionPrice->setBruttoPriceMode();
447 $this->_oTsProtectionPrice->setPrice($this->oxorder__oxtsprotectcosts->value, $this->getConfig()->getConfigParam(
'dDefaultVAT'));
461 $dTotalNetSum += $this->oxorder__oxtotalnetsum->value;
466 return $dTotalNetSum;
501 if (!$blRecalculatingOrder) {
503 $this->
setId($sGetChallenge);
522 if (!$blRecalculatingOrder) {
534 if (!$blRecalculatingOrder) {
536 if ($blRet !==
true) {
541 if (!$this->oxorder__oxordernr->value) {
550 if ($blRet !==
true) {
560 if (!$blRecalculatingOrder) {
578 if (!$blRecalculatingOrder) {
584 if (!$blRecalculatingOrder) {
600 return (
bool) $this->oxorder__oxisnettomode->value;
612 $sQ =
'update oxorder set oxtransstatus=' . $oDb->quote($sStatus) .
' where oxid=' . $oDb->quote($this->
getId());
628 if (strpos($sVat,
'.') < strpos($sVat,
',')) {
629 $sVat = str_replace(array(
'.',
','), array(
'',
'.'), $sVat);
631 $sVat = str_replace(
',',
'', $sVat);
634 return (
float) $sVat;
642 $this->oxorder__oxartvat1 =
new oxField(null);
643 $this->oxorder__oxartvatprice1 =
new oxField(null);
644 $this->oxorder__oxartvat2 =
new oxField(null);
645 $this->oxorder__oxartvatprice2 =
new oxField(null);
661 if (
$myConfig->getConfigParam(
'blStoreIPs') && $this->oxorder__oxip->value === null) {
683 if (($oPaymentCost = $oBasket->
getCosts(
'oxpayment'))) {
689 if (($oDeliveryCost = $oBasket->
getCosts(
'oxdelivery'))) {
697 if (!isset($this->oxorder__oxremark) || $this->oxorder__oxremark->value === null) {
702 $oCur =
$myConfig->getActShopCurrencyObject();
703 $this->oxorder__oxcurrency =
new oxField($oCur->name);
708 $this->oxorder__oxvoucherdiscount =
new oxField($oVoucherDiscount->getBruttoPrice(),
oxField::T_RAW);
712 if ($this->_blReloadDiscount) {
715 if (count($aDiscounts) > 0) {
716 foreach ($aDiscounts as $oDiscount) {
717 $dDiscount += $oDiscount->dDiscount;
748 if ($this->_iOrderLang === null) {
749 if (isset($this->oxorder__oxlang->value)) {
750 $this->_iOrderLang =
oxRegistry::getLang()->validateLanguage($this->oxorder__oxlang->value);
767 $this->oxorder__oxuserid =
new oxField($oUser->getId());
770 $this->oxorder__oxbillcompany = clone $oUser->oxuser__oxcompany;
771 $this->oxorder__oxbillemail = clone $oUser->oxuser__oxusername;
772 $this->oxorder__oxbillfname = clone $oUser->oxuser__oxfname;
773 $this->oxorder__oxbilllname = clone $oUser->oxuser__oxlname;
774 $this->oxorder__oxbillstreet = clone $oUser->oxuser__oxstreet;
775 $this->oxorder__oxbillstreetnr = clone $oUser->oxuser__oxstreetnr;
776 $this->oxorder__oxbilladdinfo = clone $oUser->oxuser__oxaddinfo;
777 $this->oxorder__oxbillustid = clone $oUser->oxuser__oxustid;
778 $this->oxorder__oxbillcity = clone $oUser->oxuser__oxcity;
779 $this->oxorder__oxbillcountryid = clone $oUser->oxuser__oxcountryid;
780 $this->oxorder__oxbillstateid = clone $oUser->oxuser__oxstateid;
781 $this->oxorder__oxbillzip = clone $oUser->oxuser__oxzip;
782 $this->oxorder__oxbillfon = clone $oUser->oxuser__oxfon;
783 $this->oxorder__oxbillfax = clone $oUser->oxuser__oxfax;
784 $this->oxorder__oxbillsal = clone $oUser->oxuser__oxsal;
790 $this->oxorder__oxdelcompany = clone $oDelAdress->oxaddress__oxcompany;
791 $this->oxorder__oxdelfname = clone $oDelAdress->oxaddress__oxfname;
792 $this->oxorder__oxdellname = clone $oDelAdress->oxaddress__oxlname;
793 $this->oxorder__oxdelstreet = clone $oDelAdress->oxaddress__oxstreet;
794 $this->oxorder__oxdelstreetnr = clone $oDelAdress->oxaddress__oxstreetnr;
795 $this->oxorder__oxdeladdinfo = clone $oDelAdress->oxaddress__oxaddinfo;
796 $this->oxorder__oxdelcity = clone $oDelAdress->oxaddress__oxcity;
797 $this->oxorder__oxdelcountryid = clone $oDelAdress->oxaddress__oxcountryid;
798 $this->oxorder__oxdelstateid = clone $oDelAdress->oxaddress__oxstateid;
799 $this->oxorder__oxdelzip = clone $oDelAdress->oxaddress__oxzip;
800 $this->oxorder__oxdelfon = clone $oDelAdress->oxaddress__oxfon;
801 $this->oxorder__oxdelfax = clone $oDelAdress->oxaddress__oxfax;
802 $this->oxorder__oxdelsal = clone $oDelAdress->oxaddress__oxsal;
816 if (($oWrappingCost = $oBasket->
getCosts(
'oxwrapping'))) {
822 if (($oGiftCardCost = $oBasket->
getCosts(
'oxgiftcard'))) {
843 $this->_oArticles =
oxNew(
'oxlist');
847 foreach ($aArticleList as $oContent) {
851 $oProduct = $oContent->getArticle(
true, null,
true);
854 if ($oProduct->isOrderArticle()) {
855 $oOrderArticle = $oProduct;
859 if ($iCurrLang != $oProduct->getLanguage()) {
860 $oProduct->loadInLang($iCurrLang, $oProduct->getProductId());
865 if (count($aChosenSelList = $oContent->getChosenSelList())) {
866 foreach ($aChosenSelList as $oItem) {
870 $sSelList .=
"{$oItem->name} : {$oItem->value}";
874 $oOrderArticle =
oxNew(
'oxorderarticle');
875 $oOrderArticle->setIsNewOrderItem(
true);
876 $oOrderArticle->copyThis($oProduct);
877 $oOrderArticle->setId();
879 $oOrderArticle->oxorderarticles__oxartnum = clone $oProduct->oxarticles__oxartnum;
880 $oOrderArticle->oxorderarticles__oxselvariant =
new oxField(trim($sSelList .
' ' . $oProduct->oxarticles__oxvarselect->getRawValue()),
oxField::T_RAW);
881 $oOrderArticle->oxorderarticles__oxshortdesc =
new oxField($oProduct->oxarticles__oxshortdesc->getRawValue(),
oxField::T_RAW);
883 $oOrderArticle->oxorderarticles__oxtitle =
new oxField(trim($oProduct->oxarticles__oxtitle->getRawValue()),
oxField::T_RAW);
886 if (!is_array($aPersParams = $oProduct->getPersParams())) {
887 $aPersParams = $oContent->getPersParams();
889 if (is_array($aPersParams) && count($aPersParams)) {
895 $oOrderArticle->oxorderarticles__oxorderid =
new oxField($this->
getId());
896 $oOrderArticle->oxorderarticles__oxartid =
new oxField($oContent->getProductId());
897 $oOrderArticle->oxorderarticles__oxamount =
new oxField($oContent->getAmount());
900 $oPrice = $oContent->getPrice();
903 $oOrderArticle->oxorderarticles__oxbrutprice =
new oxField($oPrice->getBruttoPrice(),
oxField::T_RAW);
906 $oUnitPtice = $oContent->getUnitPrice();
907 $oOrderArticle->oxorderarticles__oxnprice =
new oxField($oUnitPtice->getNettoPrice(),
oxField::T_RAW);
908 $oOrderArticle->oxorderarticles__oxbprice =
new oxField($oUnitPtice->getBruttoPrice(),
oxField::T_RAW);
914 $oOrderArticle->oxorderarticles__oxordershopid =
new oxField($oContent->getShopId(),
oxField::T_RAW);
917 $oOrderArticle->oxorderarticles__oxisbundle =
new oxField($oContent->isBundle());
922 $oOrderArticle->oProduct = $oProduct;
924 $oOrderArticle->setArticle($oProduct);
927 $this->_oArticles->offsetSet($oOrderArticle->getId(), $oOrderArticle);
945 $oPayTransaction->setPaymentParams($oUserpayment);
947 if (!$oPayTransaction->executePayment($oBasket->
getPrice()->getBruttoPrice(), $this)) {
951 if (method_exists($oPayTransaction,
'getLastError')) {
952 if (($sLastError = $oPayTransaction->getLastError())) {
958 if (method_exists($oPayTransaction,
'getLastErrorNo')) {
959 if (($iLastErrorNo = $oPayTransaction->getLastErrorNo())) {
960 return $iLastErrorNo;
978 return oxNew(
'oxPaymentGateway');
990 $oPayment =
oxNew(
'oxpayment');
992 if (!$oPayment->load($sPaymentid)) {
998 $oPayment->setDynValues(
oxRegistry::getUtils()->assignValuesFromText($oPayment->oxpayments__oxvaldesc->value));
1003 if (is_array($aPaymentDynValues = $oPayment->getDynValues())) {
1004 foreach ($aPaymentDynValues as $key => $oVal) {
1005 if (isset($aDynvalue[$oVal->name])) {
1006 $oVal->value = $aDynvalue[$oVal->name];
1010 $aPaymentDynValues[$key] = $oVal;
1011 $aDynVal[$oVal->name] = $oVal->value;
1018 $oUserpayment =
oxNew(
'oxuserpayment');
1019 $oUserpayment->oxuserpayments__oxuserid = clone $this->oxorder__oxuserid;
1022 $oUserpayment->oxpayments__oxdesc = clone $oPayment->oxpayments__oxdesc;
1023 $oUserpayment->oxpayments__oxlongdesc = clone $oPayment->oxpayments__oxlongdesc;
1024 $oUserpayment->setDynValues($aPaymentDynValues);
1025 $oUserpayment->save();
1029 $this->oxorder__oxpaymenttype = clone $oUserpayment->oxuserpayments__oxpaymentsid;
1032 return $oUserpayment;
1054 foreach ($aArticleList as $oContent) {
1055 if (($sWishId = $oContent->getWishId())) {
1058 if ($sWishId == $oUser->getId()) {
1059 $oUserBasket = $oUser->getBasket(
'wishlist');
1061 $aWhere = array(
'oxuserbaskets.oxuserid' => $sWishId,
'oxuserbaskets.oxtitle' =>
'wishlist');
1062 $oUserBasket =
oxNew(
'oxuserbasket');
1063 $oUserBasket->assignRecord($oUserBasket->buildSelectString($aWhere));
1068 if (!($sProdId = $oContent->getWishArticleId())) {
1069 $sProdId = $oContent->getProductId();
1071 $oUserBasketItem = $oUserBasket->getItem($sProdId, $oContent->getSelList());
1072 $dNewAmount = $oUserBasketItem->oxuserbasketitems__oxamount->value - $oContent->getAmount();
1073 if ($dNewAmount < 0) {
1076 $oUserBasket->addItemToBasket($sProdId, $dNewAmount, $oContent->getSelList(),
true);
1099 if ($oUser->getBasket(
'noticelist')->oxuserbaskets__oxid->value === null) {
1104 if ($oUserBasket = $oUser->getBasket(
'noticelist')) {
1106 foreach ($aArticleList as $oContent) {
1107 $sProdId = $oContent->getProductId();
1110 $oUserBasketItem = $oUserBasket->getItem($sProdId, $oContent->getSelList(), $oContent->getPersParams());
1111 $dNewAmount = $oUserBasketItem->oxuserbasketitems__oxamount->value - $oContent->getAmount();
1112 if ($dNewAmount < 0) {
1115 $oUserBasket->addItemToBasket($sProdId, $dNewAmount, $oContent->getSelList(),
true, $oContent->getPersParams());
1126 $sDate = date(
'Y-m-d H:i:s',
oxRegistry::get(
"oxUtilsDate")->getTime());
1127 $sQ =
'update oxorder set oxorderdate=' . $oDb->quote($sDate) .
' where oxid=' . $oDb->quote($this->
getId());
1141 $this->_aVoucherList = $oBasket->getVouchers();
1143 if (is_array($this->_aVoucherList)) {
1144 foreach ($this->_aVoucherList as $sVoucherId => $oSimpleVoucher) {
1145 $oVoucher =
oxNew(
'oxvoucher');
1146 $oVoucher->load($sVoucherId);
1147 $oVoucher->markAsUsed($this->oxorder__oxid->value, $oUser->oxuser__oxid->value, $oSimpleVoucher->dVoucherdiscount);
1149 $this->_aVoucherList[$sVoucherId] = $oVoucher;
1161 if (($blSave = parent::save())) {
1165 if ($oOrderArticles && count($oOrderArticles) > 0) {
1166 foreach ($oOrderArticles as $oOrderArticle) {
1167 $oOrderArticle->save();
1187 if ($soxAddressId) {
1188 $oDelAdress =
oxNew(
'oxaddress');
1189 $oDelAdress->load($soxAddressId);
1192 if ($oDelAdress->oxaddress__oxcountryid->value && $oDelAdress->oxaddress__oxcountryid->value != -1) {
1193 $oCountry =
oxNew(
'oxcountry');
1194 $oCountry->load($oDelAdress->oxaddress__oxcountryid->value);
1195 $oDelAdress->oxaddress__oxcountry = clone $oCountry->oxcountry__oxtitle;
1212 foreach ($oBasket->getContents() as $key => $oContent) {
1214 $oProd = $oContent->getArticle(
true, null,
true);
1216 $oBasket->removeItem($key);
1219 $oBasket->removeItem($key);
1224 $dArtStockAmount = $oBasket->getArtStockInBasket($oProd->getId(), $key);
1225 $iOnStock = $oProd->checkForStock($oContent->getAmount(), $dArtStockAmount);
1226 if ($iOnStock !==
true) {
1228 $oEx =
oxNew(
'oxOutOfStockException');
1229 $oEx->
setMessage(
'ERROR_MESSAGE_OUTOFSTOCK_OUTOFSTOCK');
1230 $oEx->
setArticleNr($oProd->oxarticles__oxartnum->value);
1232 $oEx->setBasketIndex($key);
1234 if (!is_numeric($iOnStock)) {
1237 $oEx->setRemainingAmount($iOnStock);
1254 if (!$this->oxorder__oxorderdate->value) {
1255 $this->oxorder__oxorderdate =
new oxField(date(
'Y-m-d H:i:s', $oUtilsDate->getTime()),
oxField::T_RAW);
1257 $this->oxorder__oxorderdate =
new oxField($oUtilsDate->formatDBDate($this->oxorder__oxorderdate->value,
true));
1261 $this->oxorder__oxsenddate =
new oxField($oUtilsDate->formatDBDate($this->oxorder__oxsenddate->value,
true));
1277 return $sCounterIdent;
1291 $sQ =
"update oxorder set oxordernr = ? where oxid = ?";
1292 $blUpdate = ( bool ) $oDb->execute($sQ, array($iCnt, $this->
getId()));
1295 $this->oxorder__oxordernr =
new oxField($iCnt);
1308 $this->_aSkipSaveFields = array(
'oxtimestamp',
'oxorderdate');
1309 $this->oxorder__oxsenddate =
new oxField(
oxRegistry::get(
"oxUtilsDate")->formatDBDate($this->oxorder__oxsenddate->value,
true));
1322 public function delete($sOxId = null)
1325 if (!$this->
load($sOxId)) {
1329 } elseif (!$sOxId) {
1330 $sOxId = $this->
getId();
1341 foreach ($oOrderArticles as $oOrderArticle) {
1342 $oOrderArticle->delete();
1347 $oPaymentType->delete();
1376 $oBasket->calculateBasket(
true);
1392 if (defined(
'OXID_PHP_UNIT')) {
1409 $this->_oOrderBasket =
oxNew(
"oxBasket");
1410 $this->_oOrderBasket->enableSaveToDataBase(
false);
1413 $this->_oOrderBasket->setCalculationModeNetto($this->
isNettoMode());
1416 $this->_oOrderBasket->setStockCheckMode($blStockCheck);
1419 $this->_oOrderBasket->setBasketUser($this->
getOrderUser());
1422 $this->_oOrderBasket->setOrderId($this->
getId());
1425 $aCurrencies = $this->
getConfig()->getCurrencyArray();
1426 foreach ($aCurrencies as $oCur) {
1427 if ($oCur->name == $this->oxorder__oxcurrency->value) {
1428 $oBasketCur = $oCur;
1434 $this->_oOrderBasket->setBasketCurrency($oBasketCur);
1437 $this->_oOrderBasket->setCardId($this->oxorder__oxcardid->value);
1438 $this->_oOrderBasket->setCardMessage($this->oxorder__oxcardtext->value);
1440 if ($this->_blReloadDiscount) {
1443 $this->_oOrderBasket->setSkipVouchersChecking(
true);
1446 $sQ =
'select oxid from oxvouchers where oxorderid = ' . $oDb->quote($this->
getId());
1447 $aVouchers = $oDb->getAll($sQ);
1448 foreach ($aVouchers as $aVoucher) {
1449 $this->_oOrderBasket->addVoucher($aVoucher[
'oxid']);
1452 $this->_oOrderBasket->setDiscountCalcMode(
false);
1453 $this->_oOrderBasket->setVoucherDiscount($this->oxorder__oxvoucherdiscount->value);
1454 $this->_oOrderBasket->setTotalDiscount($this->oxorder__oxdiscount->value);
1458 if (!$this->_blReloadDelivery) {
1462 $this->_oOrderBasket->setShipping($this->oxorder__oxdeltype->value);
1463 $this->_oOrderBasket->setDeliveryPrice(null);
1467 $this->_oOrderBasket->setPayment($this->oxorder__oxpaymenttype->value);
1481 $this->oxorder__oxdeltype =
new oxField($sDeliveryId);
1491 if ($this->_oUser === null) {
1492 $this->_oUser =
oxNew(
"oxuser");
1493 $this->_oUser->load($this->oxorder__oxuserid->value);
1496 if ($this->_isLoaded) {
1498 $this->_oUser->oxuser__oxcompany = clone $this->oxorder__oxbillcompany;
1499 $this->_oUser->oxuser__oxusername = clone $this->oxorder__oxbillemail;
1500 $this->_oUser->oxuser__oxfname = clone $this->oxorder__oxbillfname;
1501 $this->_oUser->oxuser__oxlname = clone $this->oxorder__oxbilllname;
1502 $this->_oUser->oxuser__oxstreet = clone $this->oxorder__oxbillstreet;
1503 $this->_oUser->oxuser__oxstreetnr = clone $this->oxorder__oxbillstreetnr;
1504 $this->_oUser->oxuser__oxaddinfo = clone $this->oxorder__oxbilladdinfo;
1505 $this->_oUser->oxuser__oxustid = clone $this->oxorder__oxbillustid;
1508 $this->_oUser->oxuser__oxcity = clone $this->oxorder__oxbillcity;
1509 $this->_oUser->oxuser__oxcountryid = clone $this->oxorder__oxbillcountryid;
1510 $this->_oUser->oxuser__oxstateid = clone $this->oxorder__oxbillstateid;
1511 $this->_oUser->oxuser__oxzip = clone $this->oxorder__oxbillzip;
1512 $this->_oUser->oxuser__oxfon = clone $this->oxorder__oxbillfon;
1513 $this->_oUser->oxuser__oxfax = clone $this->oxorder__oxbillfax;
1514 $this->_oUser->oxuser__oxsal = clone $this->oxorder__oxbillsal;
1554 public function genPdf($sFilename, $iSelLang = 0)
1565 $sQ =
'select max(oxorder.oxinvoicenr) from oxorder where oxorder.oxshopid = "' . $this->
getConfig()->getShopId() .
'" ';
1567 return ((
int )
oxDb::getDb()->getOne($sQ,
false) + 1);
1577 $sQ =
'select max(cast(oxorder.oxbillnr as unsigned)) from oxorder where oxorder.oxshopid = "' . $this->
getConfig()->getShopId() .
'" ';
1579 return ((
int )
oxDb::getDb()->getOne($sQ,
false) + 1);
1590 if (!($sShipId = $this->oxorder__oxdelcountryid->value)) {
1591 $sShipId = $this->oxorder__oxbillcountryid->value;
1598 foreach ($oOrderArticles as $sItemId => $oItem) {
1599 if ($oItem->isBundle()) {
1600 $oOrderArticles->offsetUnset($sItemId);
1608 $oBasket->calculateBasket(
true);
1611 $oDeliveryList =
oxNew(
"oxDeliveryList",
"core");
1612 $oDeliveryList->setCollectFittingDeliveriesSets(
true);
1614 return $oDeliveryList->getDeliveryList($oBasket, $this->
getOrderUser(), $sShipId);
1625 $aVouchers = array();
1626 $sSelect =
"select oxvouchernr from oxvouchers where oxorderid = " . $oDb->quote($this->oxorder__oxid->value);
1627 $rs = $oDb->select($sSelect);
1628 if ($rs !=
false && $rs->recordCount() > 0) {
1630 $aVouchers[] = $rs->fields[
'oxvouchernr'];
1647 $sSelect =
'select sum(oxtotalordersum / oxcurrate) from oxorder where ';
1648 $sSelect .=
'oxshopid = "' . $this->
getConfig()->getShopId() .
'" and oxorder.oxstorno != "1" ';
1651 $sSelect .=
'and oxorderdate like "' . date(
'Y-m-d') .
'%" ';
1654 return (
double )
oxDb::getDb()->getOne($sSelect,
false,
false);
1666 $sSelect =
'select count(*) from oxorder where ';
1667 $sSelect .=
'oxshopid = "' . $this->
getConfig()->getShopId() .
'" and oxorder.oxstorno != "1" ';
1670 $sSelect .=
'and oxorderdate like "' . date(
'Y-m-d') .
'%" ';
1673 return (
int )
oxDb::getDb()->getOne($sSelect,
false,
false);
1691 if ($oDb->getOne(
'select oxid from oxorder where oxid = ' . $oDb->quote($sOxId),
false,
false)) {
1712 $this->_oUser = $oUser;
1713 $this->_oBasket = $oBasket;
1714 $this->_oPayment = $oPayment;
1716 $oxEmail =
oxNew(
'oxemail');
1719 if ($oxEmail->sendOrderEMailToUser($this)) {
1725 $oxEmail->sendOrderEMailToOwner($this);
1767 if ($this->_oDelSet == null) {
1769 $this->_oDelSet =
oxNew(
'oxdeliveryset');
1770 $this->_oDelSet->load($this->oxorder__oxdeltype->value);
1783 if ($this->oxorder__oxpaymentid->value && $this->_oPaymentType === null) {
1784 $this->_oPaymentType =
false;
1785 $oPaymentType =
oxNew(
'oxuserpayment');
1786 if ($oPaymentType->load($this->oxorder__oxpaymentid->value)) {
1787 $this->_oPaymentType = $oPaymentType;
1801 if ($this->oxorder__oxcardid->value && $this->_oGiftCard == null) {
1802 $this->_oGiftCard =
oxNew(
'oxwrapping');
1803 $this->_oGiftCard->load($this->oxorder__oxcardid->value);
1816 $this->_blSeparateNumbering = $blSeparateNumbering;
1829 $sQ =
'select oxorder.oxpaymenttype from oxorder where oxorder.oxshopid="' . $this->
getConfig()->getShopId() .
'" and oxorder.oxuserid=' . $oDb->quote($sUserId) .
' order by oxorder.oxorderdate desc ';
1830 $sLastPaymentId = $oDb->getOne($sQ,
false,
false);
1832 return $sLastPaymentId;
1844 if (count($aOrderArticles) > 0) {
1847 foreach ($aOrderArticles as $oOrderArticle) {
1848 $oBasket->addOrderArticleToBasket($oOrderArticle);
1862 if (count($aArticles) > 0) {
1865 foreach ($aArticles as $oArticle) {
1866 $aSel = isset($oArticle->oxorderarticles__oxselvariant) ? $oArticle->oxorderarticles__oxselvariant->value : null;
1867 $aPersParam = isset($oArticle->oxorderarticles__oxpersparam) ? $oArticle->getPersParams() : null;
1868 $oBasket->addToBasket(
1869 $oArticle->oxorderarticles__oxartid->value,
1870 $oArticle->oxorderarticles__oxamount->value,
1884 $oCur = $this->
getConfig()->getActShopCurrencyObject();
1886 return number_format((
double) $this->oxorder__oxtotalordersum->value, $oCur->decimal,
'.',
'');
1899 if ($this->oxorder__oxartvat1->value) {
1900 $aVats[$this->oxorder__oxartvat1->value] = $this->oxorder__oxartvatprice1->value;
1902 if ($this->oxorder__oxartvat2->value) {
1903 $aVats[$this->oxorder__oxartvat2->value] = $this->oxorder__oxartvatprice2->value;
1906 if ($blFormatCurrency) {
1908 $oCur = $this->
getConfig()->getActShopCurrencyObject();
1909 foreach ($aVats as $sKey => $dVat) {
1910 $aVats[$sKey] = $oLang->formatCurrency($dVat, $oCur);
1924 if (!$this->oxorder__oxbillcountry->value) {
1928 return $this->oxorder__oxbillcountry;
1938 if (!$this->oxorder__oxdelcountry->value) {
1942 return $this->oxorder__oxdelcountry;
1952 $this->_blReloadDelivery = $blReload;
1962 $this->_blReloadDiscount = $blReload;
1970 $this->oxorder__oxstorno =
new oxField(1);
1971 if ($this->
save()) {
1978 $oOrderArticle->cancelOrderArticle();
1991 if ($this->_oOrderCurrency === null) {
1994 $aCurrencies = $this->
getConfig()->getCurrencyArray();
1995 $this->_oOrderCurrency = current($aCurrencies);
1997 foreach ($aCurrencies as $oCurr) {
1998 if ($oCurr->name == $this->oxorder__oxcurrency->value) {
1999 $this->_oOrderCurrency = $oCurr;
2022 if (!$iValidState) {
2027 if (!$iValidState) {
2032 if (!$iValidState) {
2037 if (!$iValidState) {
2042 return $iValidState;
2054 return $oBasket->isBelowMinOrderPrice() ? self::ORDER_STATE_BELOWMINPRICE : null;
2067 $sDelAddressMD5 = $this->
getConfig()->getRequestParameter(
'sDeliveryAddressMD5');
2069 $sDeliveryAddress = $oUser->getEncodedDeliveryAddress();
2072 $oRequiredAddressFields =
oxNew(
'oxRequiredAddressFields');
2075 $oFieldsValidator =
oxNew(
'oxRequiredFieldsValidator');
2076 $oFieldsValidator->setRequiredFields($oRequiredAddressFields->getBillingFields());
2077 $blFieldsValid = $oFieldsValidator->validateFields($oUser);
2081 if ($blFieldsValid && $oDeliveryAddress) {
2082 $sDeliveryAddress .= $oDeliveryAddress->getEncodedDeliveryAddress();
2084 $oFieldsValidator->setRequiredFields($oRequiredAddressFields->getDeliveryFields());
2085 $blFieldsValid = $oFieldsValidator->validateFields($oDeliveryAddress);
2089 if ($sDelAddressMD5 != $sDeliveryAddress || !$blFieldsValid) {
2109 if ($oBasket->getPaymentId() ==
'oxempty') {
2114 $oDelSet =
oxNew(
"oxdeliveryset");
2115 $sTable = $oDelSet->getViewName();
2117 $sQ =
"select 1 from {$sTable} where {$sTable}.oxid=" .
2118 $oDb->quote($oBasket->getShippingId()) .
" and " . $oDelSet->getSqlActiveSnippet();
2120 if (!$oDb->getOne($sQ,
false,
false)) {
2136 $paymentId = $oBasket->getPaymentId();
2154 if (($oTsProtectionCost = $oBasket->
getCosts(
'oxtsprotection'))) {
2155 $this->oxorder__oxtsprotectcosts =
new oxField($oTsProtectionCost->getBruttoPrice(),
oxField::T_RAW);
2173 $aValues[
'tsProductId'] = $this->oxorder__oxtsprotectid->value;
2175 $oCur = $this->
getConfig()->getActShopCurrencyObject();
2176 $aValues[
'currency'] = $oCur->name;
2177 $aValues[
'buyerEmail'] = $this->oxorder__oxbillemail->value;
2178 $aValues[
'shopCustomerID'] = $this->oxorder__oxuserid->value;
2179 $aValues[
'shopOrderID'] = $this->oxorder__oxordernr->value;
2180 $aValues[
'orderDate'] = $this->oxorder__oxorderdate->value;
2184 $oTsProtection =
oxNew(
'oxtsprotection');
2185 $oTsProtection->requestForTsProtection($aValues, $sPaymentId);
2197 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxtotalnetsum->value, $this->getOrderCurrency());
2207 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxtotalbrutsum->value, $this->getOrderCurrency());
2217 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxdelcost->value, $this->getOrderCurrency());
2239 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxpaycost->value, $this->getOrderCurrency());
2249 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxwrapcost->value, $this->getOrderCurrency());
2259 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxgiftcardcost->value, $this->getOrderCurrency());
2269 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxvoucherdiscount->value, $this->getOrderCurrency());
2279 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxdiscount->value, $this->getOrderCurrency());
2289 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxtotalordersum->value, $this->getOrderCurrency());
2299 return $this->oxorder__oxtrackcode->value;
2310 if ($this->_sShipTrackUrl === null) {
2311 $sParcelService = $oConfig->getConfigParam(
'sParcelService');
2313 if ($sParcelService && $sTrackingCode) {
2314 $this->_sShipTrackUrl = str_replace(
"##ID##", $sTrackingCode, $sParcelService);
2333 $paymentModel =
oxNew(
"oxpayment");
2334 $tableName = $paymentModel->getViewName();
2342 {$tableName}.oxid = {$db->quote($paymentId)}
2343 and {$paymentModel->getSqlActiveSnippet()}
2346 return (
bool) $db->getOne($sql);
2358 $paymentId = $basket->getPaymentId();
2359 $paymentModel =
oxNew(
"oxpayment");
2360 $paymentModel->load($paymentId);
2363 $shopId = $this->
getConfig()->getShopId();
2365 return $paymentModel->isValidPayment(
2369 $basket->getPriceForPayment(),
2370 $basket->getShippingId()
2379 $dynamicValues = $this->
getSession()->getVariable(
'dynvalue');
2381 if (!$dynamicValues) {
2389 return $dynamicValues;
2397 $dynamicValues = null;
2400 if (is_array($dynamicValuesList)) {
2401 foreach ($dynamicValuesList as $value) {
2402 $dynamicValues[$value->name] = $value->value;
2406 return $dynamicValues;