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');
995 $oPayment =
oxNew(
'oxpayment');
997 if (!$oPayment->load($sPaymentid)) {
1003 if (is_array($aStoredDynvalue = $oUserpayment->getDynValues())) {
1004 foreach ($aStoredDynvalue as $oVal) {
1005 $aDynvalue[$oVal->name] = $oVal->value;
1010 $oPayment->setDynValues(
oxRegistry::getUtils()->assignValuesFromText($oPayment->oxpayments__oxvaldesc->value));
1015 if (is_array($aPaymentDynValues = $oPayment->getDynValues())) {
1016 foreach ($aPaymentDynValues as $key => $oVal) {
1017 if (isset($aDynvalue[$oVal->name])) {
1018 $oVal->value = $aDynvalue[$oVal->name];
1022 $aPaymentDynValues[$key] = $oVal;
1023 $aDynVal[$oVal->name] = $oVal->value;
1030 $oUserpayment =
oxNew(
'oxuserpayment');
1031 $oUserpayment->oxuserpayments__oxuserid = clone $this->oxorder__oxuserid;
1034 $oUserpayment->oxpayments__oxdesc = clone $oPayment->oxpayments__oxdesc;
1035 $oUserpayment->oxpayments__oxlongdesc = clone $oPayment->oxpayments__oxlongdesc;
1036 $oUserpayment->setDynValues($aPaymentDynValues);
1037 $oUserpayment->save();
1041 $this->oxorder__oxpaymenttype = clone $oUserpayment->oxuserpayments__oxpaymentsid;
1044 return $oUserpayment;
1066 foreach ($aArticleList as $oContent) {
1067 if (($sWishId = $oContent->getWishId())) {
1070 if ($sWishId == $oUser->getId()) {
1071 $oUserBasket = $oUser->getBasket(
'wishlist');
1073 $aWhere = array(
'oxuserbaskets.oxuserid' => $sWishId,
'oxuserbaskets.oxtitle' =>
'wishlist');
1074 $oUserBasket =
oxNew(
'oxuserbasket');
1075 $oUserBasket->assignRecord($oUserBasket->buildSelectString($aWhere));
1080 if (!($sProdId = $oContent->getWishArticleId())) {
1081 $sProdId = $oContent->getProductId();
1083 $oUserBasketItem = $oUserBasket->getItem($sProdId, $oContent->getSelList());
1084 $dNewAmount = $oUserBasketItem->oxuserbasketitems__oxamount->value - $oContent->getAmount();
1085 if ($dNewAmount < 0) {
1088 $oUserBasket->addItemToBasket($sProdId, $dNewAmount, $oContent->getSelList(),
true);
1111 if ($oUser->getBasket(
'noticelist')->oxuserbaskets__oxid->value === null) {
1116 if ($oUserBasket = $oUser->getBasket(
'noticelist')) {
1118 foreach ($aArticleList as $oContent) {
1119 $sProdId = $oContent->getProductId();
1122 $oUserBasketItem = $oUserBasket->getItem($sProdId, $oContent->getSelList(), $oContent->getPersParams());
1123 $dNewAmount = $oUserBasketItem->oxuserbasketitems__oxamount->value - $oContent->getAmount();
1124 if ($dNewAmount < 0) {
1127 $oUserBasket->addItemToBasket($sProdId, $dNewAmount, $oContent->getSelList(),
true, $oContent->getPersParams());
1138 $sDate = date(
'Y-m-d H:i:s',
oxRegistry::get(
"oxUtilsDate")->getTime());
1139 $sQ =
'update oxorder set oxorderdate=' . $oDb->quote($sDate) .
' where oxid=' . $oDb->quote($this->
getId());
1153 $this->_aVoucherList = $oBasket->getVouchers();
1155 if (is_array($this->_aVoucherList)) {
1156 foreach ($this->_aVoucherList as $sVoucherId => $oSimpleVoucher) {
1157 $oVoucher =
oxNew(
'oxvoucher');
1158 $oVoucher->load($sVoucherId);
1159 $oVoucher->markAsUsed($this->oxorder__oxid->value, $oUser->oxuser__oxid->value, $oSimpleVoucher->dVoucherdiscount);
1161 $this->_aVoucherList[$sVoucherId] = $oVoucher;
1173 if (($blSave = parent::save())) {
1177 if ($oOrderArticles && count($oOrderArticles) > 0) {
1178 foreach ($oOrderArticles as $oOrderArticle) {
1179 $oOrderArticle->save();
1199 if ($soxAddressId) {
1200 $oDelAdress =
oxNew(
'oxaddress');
1201 $oDelAdress->load($soxAddressId);
1204 if ($oDelAdress->oxaddress__oxcountryid->value && $oDelAdress->oxaddress__oxcountryid->value != -1) {
1205 $oCountry =
oxNew(
'oxcountry');
1206 $oCountry->load($oDelAdress->oxaddress__oxcountryid->value);
1207 $oDelAdress->oxaddress__oxcountry = clone $oCountry->oxcountry__oxtitle;
1224 foreach ($oBasket->getContents() as $key => $oContent) {
1226 $oProd = $oContent->getArticle(
true, null,
true);
1228 $oBasket->removeItem($key);
1231 $oBasket->removeItem($key);
1236 $dArtStockAmount = $oBasket->getArtStockInBasket($oProd->getId(), $key);
1237 $iOnStock = $oProd->checkForStock($oContent->getAmount(), $dArtStockAmount);
1238 if ($iOnStock !==
true) {
1240 $oEx =
oxNew(
'oxOutOfStockException');
1241 $oEx->
setMessage(
'ERROR_MESSAGE_OUTOFSTOCK_OUTOFSTOCK');
1242 $oEx->
setArticleNr($oProd->oxarticles__oxartnum->value);
1244 $oEx->setBasketIndex($key);
1246 if (!is_numeric($iOnStock)) {
1249 $oEx->setRemainingAmount($iOnStock);
1266 if (!$this->oxorder__oxorderdate->value) {
1267 $this->oxorder__oxorderdate =
new oxField(date(
'Y-m-d H:i:s', $oUtilsDate->getTime()),
oxField::T_RAW);
1269 $this->oxorder__oxorderdate =
new oxField($oUtilsDate->formatDBDate($this->oxorder__oxorderdate->value,
true));
1273 $this->oxorder__oxsenddate =
new oxField($oUtilsDate->formatDBDate($this->oxorder__oxsenddate->value,
true));
1289 return $sCounterIdent;
1303 $sQ =
"update oxorder set oxordernr = ? where oxid = ?";
1304 $blUpdate = ( bool ) $oDb->execute($sQ, array($iCnt, $this->
getId()));
1307 $this->oxorder__oxordernr =
new oxField($iCnt);
1320 $this->_aSkipSaveFields = array(
'oxtimestamp',
'oxorderdate');
1321 $this->oxorder__oxsenddate =
new oxField(
oxRegistry::get(
"oxUtilsDate")->formatDBDate($this->oxorder__oxsenddate->value,
true));
1334 public function delete($sOxId = null)
1337 if (!$this->
load($sOxId)) {
1341 } elseif (!$sOxId) {
1342 $sOxId = $this->
getId();
1353 foreach ($oOrderArticles as $oOrderArticle) {
1354 $oOrderArticle->delete();
1359 $oPaymentType->delete();
1388 $oBasket->calculateBasket(
true);
1404 if (defined(
'OXID_PHP_UNIT')) {
1421 $this->_oOrderBasket =
oxNew(
"oxBasket");
1422 $this->_oOrderBasket->enableSaveToDataBase(
false);
1425 $this->_oOrderBasket->setCalculationModeNetto($this->
isNettoMode());
1428 $this->_oOrderBasket->setStockCheckMode($blStockCheck);
1431 $this->_oOrderBasket->setBasketUser($this->
getOrderUser());
1434 $this->_oOrderBasket->setOrderId($this->
getId());
1437 $aCurrencies = $this->
getConfig()->getCurrencyArray();
1438 foreach ($aCurrencies as $oCur) {
1439 if ($oCur->name == $this->oxorder__oxcurrency->value) {
1440 $oBasketCur = $oCur;
1446 $this->_oOrderBasket->setBasketCurrency($oBasketCur);
1449 $this->_oOrderBasket->setCardId($this->oxorder__oxcardid->value);
1450 $this->_oOrderBasket->setCardMessage($this->oxorder__oxcardtext->value);
1452 if ($this->_blReloadDiscount) {
1455 $this->_oOrderBasket->setSkipVouchersChecking(
true);
1458 $sQ =
'select oxid from oxvouchers where oxorderid = ' . $oDb->quote($this->
getId());
1459 $aVouchers = $oDb->getAll($sQ);
1460 foreach ($aVouchers as $aVoucher) {
1461 $this->_oOrderBasket->addVoucher($aVoucher[
'oxid']);
1464 $this->_oOrderBasket->setDiscountCalcMode(
false);
1465 $this->_oOrderBasket->setVoucherDiscount($this->oxorder__oxvoucherdiscount->value);
1466 $this->_oOrderBasket->setTotalDiscount($this->oxorder__oxdiscount->value);
1470 if (!$this->_blReloadDelivery) {
1474 $this->_oOrderBasket->setShipping($this->oxorder__oxdeltype->value);
1475 $this->_oOrderBasket->setDeliveryPrice(null);
1479 $this->_oOrderBasket->setPayment($this->oxorder__oxpaymenttype->value);
1493 $this->oxorder__oxdeltype =
new oxField($sDeliveryId);
1503 if ($this->_oUser === null) {
1504 $this->_oUser =
oxNew(
"oxuser");
1505 $this->_oUser->load($this->oxorder__oxuserid->value);
1508 if ($this->_isLoaded) {
1510 $this->_oUser->oxuser__oxcompany = clone $this->oxorder__oxbillcompany;
1511 $this->_oUser->oxuser__oxusername = clone $this->oxorder__oxbillemail;
1512 $this->_oUser->oxuser__oxfname = clone $this->oxorder__oxbillfname;
1513 $this->_oUser->oxuser__oxlname = clone $this->oxorder__oxbilllname;
1514 $this->_oUser->oxuser__oxstreet = clone $this->oxorder__oxbillstreet;
1515 $this->_oUser->oxuser__oxstreetnr = clone $this->oxorder__oxbillstreetnr;
1516 $this->_oUser->oxuser__oxaddinfo = clone $this->oxorder__oxbilladdinfo;
1517 $this->_oUser->oxuser__oxustid = clone $this->oxorder__oxbillustid;
1520 $this->_oUser->oxuser__oxcity = clone $this->oxorder__oxbillcity;
1521 $this->_oUser->oxuser__oxcountryid = clone $this->oxorder__oxbillcountryid;
1522 $this->_oUser->oxuser__oxstateid = clone $this->oxorder__oxbillstateid;
1523 $this->_oUser->oxuser__oxzip = clone $this->oxorder__oxbillzip;
1524 $this->_oUser->oxuser__oxfon = clone $this->oxorder__oxbillfon;
1525 $this->_oUser->oxuser__oxfax = clone $this->oxorder__oxbillfax;
1526 $this->_oUser->oxuser__oxsal = clone $this->oxorder__oxbillsal;
1566 public function genPdf($sFilename, $iSelLang = 0)
1577 $sQ =
'select max(oxorder.oxinvoicenr) from oxorder where oxorder.oxshopid = "' . $this->
getConfig()->getShopId() .
'" ';
1579 return ((
int )
oxDb::getDb()->getOne($sQ,
false) + 1);
1589 $sQ =
'select max(cast(oxorder.oxbillnr as unsigned)) from oxorder where oxorder.oxshopid = "' . $this->
getConfig()->getShopId() .
'" ';
1591 return ((
int )
oxDb::getDb()->getOne($sQ,
false) + 1);
1602 if (!($sShipId = $this->oxorder__oxdelcountryid->value)) {
1603 $sShipId = $this->oxorder__oxbillcountryid->value;
1610 foreach ($oOrderArticles as $sItemId => $oItem) {
1611 if ($oItem->isBundle()) {
1612 $oOrderArticles->offsetUnset($sItemId);
1620 $oBasket->calculateBasket(
true);
1623 $oDeliveryList =
oxNew(
"oxDeliveryList",
"core");
1624 $oDeliveryList->setCollectFittingDeliveriesSets(
true);
1626 return $oDeliveryList->getDeliveryList($oBasket, $this->
getOrderUser(), $sShipId);
1637 $aVouchers = array();
1638 $sSelect =
"select oxvouchernr from oxvouchers where oxorderid = " . $oDb->quote($this->oxorder__oxid->value);
1639 $rs = $oDb->select($sSelect);
1640 if ($rs !=
false && $rs->recordCount() > 0) {
1642 $aVouchers[] = $rs->fields[
'oxvouchernr'];
1659 $sSelect =
'select sum(oxtotalordersum / oxcurrate) from oxorder where ';
1660 $sSelect .=
'oxshopid = "' . $this->
getConfig()->getShopId() .
'" and oxorder.oxstorno != "1" ';
1663 $sSelect .=
'and oxorderdate like "' . date(
'Y-m-d') .
'%" ';
1666 return (
double )
oxDb::getDb()->getOne($sSelect,
false,
false);
1678 $sSelect =
'select count(*) from oxorder where ';
1679 $sSelect .=
'oxshopid = "' . $this->
getConfig()->getShopId() .
'" and oxorder.oxstorno != "1" ';
1682 $sSelect .=
'and oxorderdate like "' . date(
'Y-m-d') .
'%" ';
1685 return (
int )
oxDb::getDb()->getOne($sSelect,
false,
false);
1703 if ($oDb->getOne(
'select oxid from oxorder where oxid = ' . $oDb->quote($sOxId),
false,
false)) {
1724 $this->_oUser = $oUser;
1725 $this->_oBasket = $oBasket;
1726 $this->_oPayment = $oPayment;
1728 $oxEmail =
oxNew(
'oxemail');
1731 if ($oxEmail->sendOrderEMailToUser($this)) {
1737 $oxEmail->sendOrderEMailToOwner($this);
1779 if ($this->_oDelSet == null) {
1781 $this->_oDelSet =
oxNew(
'oxdeliveryset');
1782 $this->_oDelSet->load($this->oxorder__oxdeltype->value);
1795 if ($this->oxorder__oxpaymentid->value && $this->_oPaymentType === null) {
1796 $this->_oPaymentType =
false;
1797 $oPaymentType =
oxNew(
'oxuserpayment');
1798 if ($oPaymentType->load($this->oxorder__oxpaymentid->value)) {
1799 $this->_oPaymentType = $oPaymentType;
1813 if ($this->oxorder__oxcardid->value && $this->_oGiftCard == null) {
1814 $this->_oGiftCard =
oxNew(
'oxwrapping');
1815 $this->_oGiftCard->load($this->oxorder__oxcardid->value);
1828 $this->_blSeparateNumbering = $blSeparateNumbering;
1841 $sQ =
'select oxorder.oxpaymenttype from oxorder where oxorder.oxshopid="' . $this->
getConfig()->getShopId() .
'" and oxorder.oxuserid=' . $oDb->quote($sUserId) .
' order by oxorder.oxorderdate desc ';
1842 $sLastPaymentId = $oDb->getOne($sQ,
false,
false);
1844 return $sLastPaymentId;
1856 if (count($aOrderArticles) > 0) {
1859 foreach ($aOrderArticles as $oOrderArticle) {
1860 $oBasket->addOrderArticleToBasket($oOrderArticle);
1874 if (count($aArticles) > 0) {
1877 foreach ($aArticles as $oArticle) {
1878 $aSel = isset($oArticle->oxorderarticles__oxselvariant) ? $oArticle->oxorderarticles__oxselvariant->value : null;
1879 $aPersParam = isset($oArticle->oxorderarticles__oxpersparam) ? $oArticle->getPersParams() : null;
1880 $oBasket->addToBasket(
1881 $oArticle->oxorderarticles__oxartid->value,
1882 $oArticle->oxorderarticles__oxamount->value,
1896 $oCur = $this->
getConfig()->getActShopCurrencyObject();
1898 return number_format((
double) $this->oxorder__oxtotalordersum->value, $oCur->decimal,
'.',
'');
1911 if ($this->oxorder__oxartvat1->value) {
1912 $aVats[$this->oxorder__oxartvat1->value] = $this->oxorder__oxartvatprice1->value;
1914 if ($this->oxorder__oxartvat2->value) {
1915 $aVats[$this->oxorder__oxartvat2->value] = $this->oxorder__oxartvatprice2->value;
1918 if ($blFormatCurrency) {
1920 $oCur = $this->
getConfig()->getActShopCurrencyObject();
1921 foreach ($aVats as $sKey => $dVat) {
1922 $aVats[$sKey] = $oLang->formatCurrency($dVat, $oCur);
1936 if (!$this->oxorder__oxbillcountry->value) {
1940 return $this->oxorder__oxbillcountry;
1950 if (!$this->oxorder__oxdelcountry->value) {
1954 return $this->oxorder__oxdelcountry;
1964 $this->_blReloadDelivery = $blReload;
1974 $this->_blReloadDiscount = $blReload;
1982 $this->oxorder__oxstorno =
new oxField(1);
1983 if ($this->
save()) {
1990 $oOrderArticle->cancelOrderArticle();
2003 if ($this->_oOrderCurrency === null) {
2006 $aCurrencies = $this->
getConfig()->getCurrencyArray();
2007 $this->_oOrderCurrency = current($aCurrencies);
2009 foreach ($aCurrencies as $oCurr) {
2010 if ($oCurr->name == $this->oxorder__oxcurrency->value) {
2011 $this->_oOrderCurrency = $oCurr;
2034 if (!$iValidState) {
2039 if (!$iValidState) {
2044 if (!$iValidState) {
2049 if (!$iValidState) {
2054 return $iValidState;
2066 return $oBasket->isBelowMinOrderPrice() ? self::ORDER_STATE_BELOWMINPRICE : null;
2079 $sDelAddressMD5 = $this->
getConfig()->getRequestParameter(
'sDeliveryAddressMD5');
2081 $sDeliveryAddress = $oUser->getEncodedDeliveryAddress();
2084 $oRequiredAddressFields =
oxNew(
'oxRequiredAddressFields');
2087 $oFieldsValidator =
oxNew(
'oxRequiredFieldsValidator');
2088 $oFieldsValidator->setRequiredFields($oRequiredAddressFields->getBillingFields());
2089 $blFieldsValid = $oFieldsValidator->validateFields($oUser);
2093 if ($blFieldsValid && $oDeliveryAddress) {
2094 $sDeliveryAddress .= $oDeliveryAddress->getEncodedDeliveryAddress();
2096 $oFieldsValidator->setRequiredFields($oRequiredAddressFields->getDeliveryFields());
2097 $blFieldsValid = $oFieldsValidator->validateFields($oDeliveryAddress);
2101 if ($sDelAddressMD5 != $sDeliveryAddress || !$blFieldsValid) {
2121 if ($oBasket->getPaymentId() ==
'oxempty') {
2126 $oDelSet =
oxNew(
"oxdeliveryset");
2127 $sTable = $oDelSet->getViewName();
2129 $sQ =
"select 1 from {$sTable} where {$sTable}.oxid=" .
2130 $oDb->quote($oBasket->getShippingId()) .
" and " . $oDelSet->getSqlActiveSnippet();
2132 if (!$oDb->getOne($sQ,
false,
false)) {
2150 $oPayment =
oxNew(
"oxpayment");
2151 $sTable = $oPayment->getViewName();
2153 $sQ =
"select 1 from {$sTable} where {$sTable}.oxid=" .
2154 $oDb->quote($oBasket->getPaymentId()) .
" and " . $oPayment->getSqlActiveSnippet();
2156 if (!$oDb->getOne($sQ,
false,
false)) {
2172 if (($oTsProtectionCost = $oBasket->
getCosts(
'oxtsprotection'))) {
2173 $this->oxorder__oxtsprotectcosts =
new oxField($oTsProtectionCost->getBruttoPrice(),
oxField::T_RAW);
2191 $aValues[
'tsProductId'] = $this->oxorder__oxtsprotectid->value;
2193 $oCur = $this->
getConfig()->getActShopCurrencyObject();
2194 $aValues[
'currency'] = $oCur->name;
2195 $aValues[
'buyerEmail'] = $this->oxorder__oxbillemail->value;
2196 $aValues[
'shopCustomerID'] = $this->oxorder__oxuserid->value;
2197 $aValues[
'shopOrderID'] = $this->oxorder__oxordernr->value;
2198 $aValues[
'orderDate'] = $this->oxorder__oxorderdate->value;
2202 $oTsProtection =
oxNew(
'oxtsprotection');
2203 $oTsProtection->requestForTsProtection($aValues, $sPaymentId);
2215 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxtotalnetsum->value, $this->getOrderCurrency());
2225 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxtotalbrutsum->value, $this->getOrderCurrency());
2235 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxdelcost->value, $this->getOrderCurrency());
2257 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxpaycost->value, $this->getOrderCurrency());
2267 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxwrapcost->value, $this->getOrderCurrency());
2277 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxgiftcardcost->value, $this->getOrderCurrency());
2287 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxvoucherdiscount->value, $this->getOrderCurrency());
2297 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxdiscount->value, $this->getOrderCurrency());
2307 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxtotalordersum->value, $this->getOrderCurrency());
2317 return $this->oxorder__oxtrackcode->value;
2328 if ($this->_sShipTrackUrl === null) {
2329 $sParcelService = $oConfig->getConfigParam(
'sParcelService');
2331 if ($sParcelService && $sTrackingCode) {
2332 $this->_sShipTrackUrl = str_replace(
"##ID##", $sTrackingCode, $sParcelService);