235 $this->
init(
'oxorder');
251 if ($sName ==
'oDelSet') {
255 if ($sName ==
'oxorder__oxbillcountry') {
259 if ($sName ==
'oxorder__oxdelcountry') {
279 $this->oxorder__oxorderdate =
new oxField($oUtilsDate->formatDBDate($this->oxorder__oxorderdate->value));
280 $this->oxorder__oxsenddate =
new oxField($oUtilsDate->formatDBDate($this->oxorder__oxsenddate->value));
293 if ($sCountryId && $sCountryId !=
'-1') {
294 $oCountry =
oxNew(
'oxcountry');
296 $sTitle = $oCountry->oxcountry__oxtitle->value;
311 $sSelect =
"SELECT `oxorderarticles`.* FROM `oxorderarticles`
312 WHERE `oxorderarticles`.`oxorderid` = '" . $this->
getId() .
"'" .
313 ($blExcludeCanceled ?
" AND `oxorderarticles`.`oxstorno` != 1 " :
" ") .
"
314 ORDER BY `oxorderarticles`.`oxartid`, `oxorderarticles`.`oxselvariant`, `oxorderarticles`.`oxpersparam` ";
317 $oArticles =
oxNew(
'oxlist');
318 $oArticles->init(
'oxorderarticle');
319 $oArticles->selectString($sSelect);
334 if ($blExcludeCanceled) {
338 } elseif ($this->_oArticles === null) {
352 $this->_oArticles = $oOrderArticleList;
362 if ($this->_oDelPrice != null) {
366 $this->_oDelPrice =
oxNew(
'oxprice');
367 $this->_oDelPrice->setBruttoPriceMode();
368 $this->_oDelPrice->setPrice($this->oxorder__oxdelcost->value, $this->oxorder__oxdelvat->value);
380 if ($this->_oWrappingPrice != null) {
384 $this->_oWrappingPrice =
oxNew(
'oxprice');
385 $this->_oWrappingPrice->setBruttoPriceMode();
386 $this->_oWrappingPrice->setPrice($this->oxorder__oxwrapcost->value, $this->oxorder__oxwrapvat->value);
398 if ($this->_oGidtCardPrice != null) {
399 return $this->_oGidtCardPrice;
402 $this->_oGidtCardPrice =
oxNew(
'oxprice');
403 $this->_oGidtCardPrice->setBruttoPriceMode();
404 $this->_oGidtCardPrice->setPrice($this->oxorder__oxgiftcardcost->value, $this->oxorder__oxgiftcardvat->value);
406 return $this->_oGidtCardPrice;
417 if ($this->_oPaymentPrice != null) {
421 $this->_oPaymentPrice =
oxNew(
'oxprice');
422 $this->_oPaymentPrice->setBruttoPriceMode();
423 $this->_oPaymentPrice->setPrice($this->oxorder__oxpaycost->value, $this->oxorder__oxpayvat->value);
435 if ($this->_oTsProtectionPrice != null) {
439 $this->_oTsProtectionPrice =
oxNew(
'oxprice');
440 $this->_oTsProtectionPrice->setBruttoPriceMode();
441 $this->_oTsProtectionPrice->setPrice($this->oxorder__oxtsprotectcosts->value, $this->getConfig()->getConfigParam(
'dDefaultVAT'));
455 $dTotalNetSum += $this->oxorder__oxtotalnetsum->value;
460 return $dTotalNetSum;
495 if (!$blRecalculatingOrder) {
497 $this->
setId($sGetChallenge);
516 if (!$blRecalculatingOrder) {
528 if (!$blRecalculatingOrder) {
530 if ($blRet !==
true) {
535 if (!$this->oxorder__oxordernr->value) {
543 $blRet = $this->_executeTsProtection($oBasket);
544 if ($blRet !==
true) {
554 if (!$blRecalculatingOrder) {
572 if (!$blRecalculatingOrder) {
578 if (!$blRecalculatingOrder) {
594 return (
bool) $this->oxorder__oxisnettomode->value;
606 $sQ =
'update oxorder set oxtransstatus=' . $oDb->quote($sStatus) .
' where oxid=' . $oDb->quote($this->
getId());
622 if (strpos($sVat,
'.') < strpos($sVat,
',')) {
623 $sVat = str_replace(array(
'.',
','), array(
'',
'.'), $sVat);
625 $sVat = str_replace(
',',
'', $sVat);
628 return (
float) $sVat;
636 $this->oxorder__oxartvat1 =
new oxField(null);
637 $this->oxorder__oxartvatprice1 =
new oxField(null);
638 $this->oxorder__oxartvat2 =
new oxField(null);
639 $this->oxorder__oxartvatprice2 =
new oxField(null);
655 if (
$myConfig->getConfigParam(
'blStoreIPs') && $this->oxorder__oxip->value === null) {
677 if (($oPaymentCost = $oBasket->
getCosts(
'oxpayment'))) {
683 if (($oDeliveryCost = $oBasket->
getCosts(
'oxdelivery'))) {
691 if (!isset($this->oxorder__oxremark) || $this->oxorder__oxremark->value === null) {
696 $oCur =
$myConfig->getActShopCurrencyObject();
697 $this->oxorder__oxcurrency =
new oxField($oCur->name);
702 $this->oxorder__oxvoucherdiscount =
new oxField($oVoucherDiscount->getBruttoPrice(),
oxField::T_RAW);
706 if ($this->_blReloadDiscount) {
709 if (count($aDiscounts) > 0) {
710 foreach ($aDiscounts as $oDiscount) {
711 $dDiscount += $oDiscount->dDiscount;
742 if ($this->_iOrderLang === null) {
743 if (isset($this->oxorder__oxlang->value)) {
744 $this->_iOrderLang =
oxRegistry::getLang()->validateLanguage($this->oxorder__oxlang->value);
761 $this->oxorder__oxuserid =
new oxField($oUser->getId());
764 $this->oxorder__oxbillcompany = clone $oUser->oxuser__oxcompany;
765 $this->oxorder__oxbillemail = clone $oUser->oxuser__oxusername;
766 $this->oxorder__oxbillfname = clone $oUser->oxuser__oxfname;
767 $this->oxorder__oxbilllname = clone $oUser->oxuser__oxlname;
768 $this->oxorder__oxbillstreet = clone $oUser->oxuser__oxstreet;
769 $this->oxorder__oxbillstreetnr = clone $oUser->oxuser__oxstreetnr;
770 $this->oxorder__oxbilladdinfo = clone $oUser->oxuser__oxaddinfo;
771 $this->oxorder__oxbillustid = clone $oUser->oxuser__oxustid;
772 $this->oxorder__oxbillcity = clone $oUser->oxuser__oxcity;
773 $this->oxorder__oxbillcountryid = clone $oUser->oxuser__oxcountryid;
774 $this->oxorder__oxbillstateid = clone $oUser->oxuser__oxstateid;
775 $this->oxorder__oxbillzip = clone $oUser->oxuser__oxzip;
776 $this->oxorder__oxbillfon = clone $oUser->oxuser__oxfon;
777 $this->oxorder__oxbillfax = clone $oUser->oxuser__oxfax;
778 $this->oxorder__oxbillsal = clone $oUser->oxuser__oxsal;
784 $this->oxorder__oxdelcompany = clone $oDelAdress->oxaddress__oxcompany;
785 $this->oxorder__oxdelfname = clone $oDelAdress->oxaddress__oxfname;
786 $this->oxorder__oxdellname = clone $oDelAdress->oxaddress__oxlname;
787 $this->oxorder__oxdelstreet = clone $oDelAdress->oxaddress__oxstreet;
788 $this->oxorder__oxdelstreetnr = clone $oDelAdress->oxaddress__oxstreetnr;
789 $this->oxorder__oxdeladdinfo = clone $oDelAdress->oxaddress__oxaddinfo;
790 $this->oxorder__oxdelcity = clone $oDelAdress->oxaddress__oxcity;
791 $this->oxorder__oxdelcountryid = clone $oDelAdress->oxaddress__oxcountryid;
792 $this->oxorder__oxdelstateid = clone $oDelAdress->oxaddress__oxstateid;
793 $this->oxorder__oxdelzip = clone $oDelAdress->oxaddress__oxzip;
794 $this->oxorder__oxdelfon = clone $oDelAdress->oxaddress__oxfon;
795 $this->oxorder__oxdelfax = clone $oDelAdress->oxaddress__oxfax;
796 $this->oxorder__oxdelsal = clone $oDelAdress->oxaddress__oxsal;
810 if (($oWrappingCost = $oBasket->
getCosts(
'oxwrapping'))) {
816 if (($oGiftCardCost = $oBasket->
getCosts(
'oxgiftcard'))) {
837 $this->_oArticles =
oxNew(
'oxlist');
841 foreach ($aArticleList as $oContent) {
845 $oProduct = $oContent->getArticle(
true, null,
true);
848 if ($oProduct->isOrderArticle()) {
849 $oOrderArticle = $oProduct;
853 if ($iCurrLang != $oProduct->getLanguage()) {
854 $oProduct->loadInLang($iCurrLang, $oProduct->getProductId());
859 if (count($aChosenSelList = $oContent->getChosenSelList())) {
860 foreach ($aChosenSelList as $oItem) {
864 $sSelList .=
"{$oItem->name} : {$oItem->value}";
868 $oOrderArticle =
oxNew(
'oxorderarticle');
869 $oOrderArticle->setIsNewOrderItem(
true);
870 $oOrderArticle->copyThis($oProduct);
871 $oOrderArticle->setId();
873 $oOrderArticle->oxorderarticles__oxartnum = clone $oProduct->oxarticles__oxartnum;
874 $oOrderArticle->oxorderarticles__oxselvariant =
new oxField(trim($sSelList .
' ' . $oProduct->oxarticles__oxvarselect->getRawValue()),
oxField::T_RAW);
875 $oOrderArticle->oxorderarticles__oxshortdesc =
new oxField($oProduct->oxarticles__oxshortdesc->getRawValue(),
oxField::T_RAW);
877 $oOrderArticle->oxorderarticles__oxtitle =
new oxField(trim($oProduct->oxarticles__oxtitle->getRawValue()),
oxField::T_RAW);
880 if (!is_array($aPersParams = $oProduct->getPersParams())) {
881 $aPersParams = $oContent->getPersParams();
883 if (is_array($aPersParams) && count($aPersParams)) {
889 $oOrderArticle->oxorderarticles__oxorderid =
new oxField($this->
getId());
890 $oOrderArticle->oxorderarticles__oxartid =
new oxField($oContent->getProductId());
891 $oOrderArticle->oxorderarticles__oxamount =
new oxField($oContent->getAmount());
894 $oPrice = $oContent->getPrice();
897 $oOrderArticle->oxorderarticles__oxbrutprice =
new oxField($oPrice->getBruttoPrice(),
oxField::T_RAW);
900 $oUnitPtice = $oContent->getUnitPrice();
901 $oOrderArticle->oxorderarticles__oxnprice =
new oxField($oUnitPtice->getNettoPrice(),
oxField::T_RAW);
902 $oOrderArticle->oxorderarticles__oxbprice =
new oxField($oUnitPtice->getBruttoPrice(),
oxField::T_RAW);
908 $oOrderArticle->oxorderarticles__oxordershopid =
new oxField($oContent->getShopId(),
oxField::T_RAW);
911 $oOrderArticle->oxorderarticles__oxisbundle =
new oxField($oContent->isBundle());
916 $oOrderArticle->oProduct = $oProduct;
918 $oOrderArticle->setArticle($oProduct);
921 $this->_oArticles->offsetSet($oOrderArticle->getId(), $oOrderArticle);
939 $oPayTransaction->setPaymentParams($oUserpayment);
941 if (!$oPayTransaction->executePayment($oBasket->
getPrice()->getBruttoPrice(), $this)) {
945 if (method_exists($oPayTransaction,
'getLastError')) {
946 if (($sLastError = $oPayTransaction->getLastError())) {
952 if (method_exists($oPayTransaction,
'getLastErrorNo')) {
953 if (($iLastErrorNo = $oPayTransaction->getLastErrorNo())) {
954 return $iLastErrorNo;
972 return oxNew(
'oxPaymentGateway');
989 $oPayment =
oxNew(
'oxpayment');
991 if (!$oPayment->load($sPaymentid)) {
997 if (is_array($aStoredDynvalue = $oUserpayment->getDynValues())) {
998 foreach ($aStoredDynvalue as $oVal) {
999 $aDynvalue[$oVal->name] = $oVal->value;
1004 $oPayment->setDynValues(
oxRegistry::getUtils()->assignValuesFromText($oPayment->oxpayments__oxvaldesc->value));
1009 if (is_array($aPaymentDynValues = $oPayment->getDynValues())) {
1010 foreach ($aPaymentDynValues as $key => $oVal) {
1011 if (isset($aDynvalue[$oVal->name])) {
1012 $oVal->value = $aDynvalue[$oVal->name];
1016 $aPaymentDynValues[$key] = $oVal;
1017 $aDynVal[$oVal->name] = $oVal->value;
1024 $oUserpayment =
oxNew(
'oxuserpayment');
1025 $oUserpayment->oxuserpayments__oxuserid = clone $this->oxorder__oxuserid;
1028 $oUserpayment->oxpayments__oxdesc = clone $oPayment->oxpayments__oxdesc;
1029 $oUserpayment->oxpayments__oxlongdesc = clone $oPayment->oxpayments__oxlongdesc;
1030 $oUserpayment->setDynValues($aPaymentDynValues);
1031 $oUserpayment->save();
1035 $this->oxorder__oxpaymenttype = clone $oUserpayment->oxuserpayments__oxpaymentsid;
1038 return $oUserpayment;
1060 foreach ($aArticleList as $oContent) {
1061 if (($sWishId = $oContent->getWishId())) {
1064 if ($sWishId == $oUser->getId()) {
1065 $oUserBasket = $oUser->getBasket(
'wishlist');
1067 $aWhere = array(
'oxuserbaskets.oxuserid' => $sWishId,
'oxuserbaskets.oxtitle' =>
'wishlist');
1068 $oUserBasket =
oxNew(
'oxuserbasket');
1069 $oUserBasket->assignRecord($oUserBasket->buildSelectString($aWhere));
1074 if (!($sProdId = $oContent->getWishArticleId())) {
1075 $sProdId = $oContent->getProductId();
1077 $oUserBasketItem = $oUserBasket->getItem($sProdId, $oContent->getSelList());
1078 $dNewAmount = $oUserBasketItem->oxuserbasketitems__oxamount->value - $oContent->getAmount();
1079 if ($dNewAmount < 0) {
1082 $oUserBasket->addItemToBasket($sProdId, $dNewAmount, $oContent->getSelList(),
true);
1098 if ($oUserBasket = $oUser->getBasket(
'noticelist')) {
1100 foreach ($aArticleList as $oContent) {
1101 $sProdId = $oContent->getProductId();
1104 $oUserBasketItem = $oUserBasket->getItem($sProdId, $oContent->getSelList(), $oContent->getPersParams());
1105 $dNewAmount = $oUserBasketItem->oxuserbasketitems__oxamount->value - $oContent->getAmount();
1106 if ($dNewAmount < 0) {
1109 $oUserBasket->addItemToBasket($sProdId, $dNewAmount, $oContent->getSelList(),
true, $oContent->getPersParams());
1120 $sDate = date(
'Y-m-d H:i:s',
oxRegistry::get(
"oxUtilsDate")->getTime());
1121 $sQ =
'update oxorder set oxorderdate=' . $oDb->quote($sDate) .
' where oxid=' . $oDb->quote($this->
getId());
1135 $this->_aVoucherList = $oBasket->getVouchers();
1137 if (is_array($this->_aVoucherList)) {
1138 foreach ($this->_aVoucherList as $sVoucherId => $oSimpleVoucher) {
1139 $oVoucher =
oxNew(
'oxvoucher');
1140 $oVoucher->load($sVoucherId);
1141 $oVoucher->markAsUsed($this->oxorder__oxid->value, $oUser->oxuser__oxid->value, $oSimpleVoucher->dVoucherdiscount);
1143 $this->_aVoucherList[$sVoucherId] = $oVoucher;
1155 if (($blSave = parent::save())) {
1159 if ($oOrderArticles && count($oOrderArticles) > 0) {
1160 foreach ($oOrderArticles as $oOrderArticle) {
1161 $oOrderArticle->save();
1181 if ($soxAddressId) {
1182 $oDelAdress =
oxNew(
'oxaddress');
1183 $oDelAdress->load($soxAddressId);
1186 if ($oDelAdress->oxaddress__oxcountryid->value && $oDelAdress->oxaddress__oxcountryid->value != -1) {
1187 $oCountry =
oxNew(
'oxcountry');
1188 $oCountry->load($oDelAdress->oxaddress__oxcountryid->value);
1189 $oDelAdress->oxaddress__oxcountry = clone $oCountry->oxcountry__oxtitle;
1204 public function validateStock($oBasket)
1206 foreach ($oBasket->getContents() as $key => $oContent) {
1208 $oProd = $oContent->getArticle(
true, null,
true);
1210 $oBasket->removeItem($key);
1213 $oBasket->removeItem($key);
1218 $dArtStockAmount = $oBasket->getArtStockInBasket($oProd->getId(), $key);
1219 $iOnStock = $oProd->checkForStock($oContent->getAmount(), $dArtStockAmount);
1220 if ($iOnStock !==
true) {
1222 $oEx =
oxNew(
'oxOutOfStockException');
1223 $oEx->
setMessage(
'ERROR_MESSAGE_OUTOFSTOCK_OUTOFSTOCK');
1224 $oEx->
setArticleNr($oProd->oxarticles__oxartnum->value);
1226 $oEx->setBasketIndex($key);
1228 if (!is_numeric($iOnStock)) {
1231 $oEx->setRemainingAmount($iOnStock);
1248 if (!$this->oxorder__oxorderdate->value) {
1249 $this->oxorder__oxorderdate =
new oxField(date(
'Y-m-d H:i:s', $oUtilsDate->getTime()),
oxField::T_RAW);
1251 $this->oxorder__oxorderdate =
new oxField($oUtilsDate->formatDBDate($this->oxorder__oxorderdate->value,
true));
1255 $this->oxorder__oxsenddate =
new oxField($oUtilsDate->formatDBDate($this->oxorder__oxsenddate->value,
true));
1271 return $sCounterIdent;
1285 $sQ =
"update oxorder set oxordernr = ? where oxid = ?";
1286 $blUpdate = ( bool ) $oDb->execute($sQ, array($iCnt, $this->
getId()));
1289 $this->oxorder__oxordernr =
new oxField($iCnt);
1302 $this->_aSkipSaveFields = array(
'oxtimestamp',
'oxorderdate');
1303 $this->oxorder__oxsenddate =
new oxField(
oxRegistry::get(
"oxUtilsDate")->formatDBDate($this->oxorder__oxsenddate->value,
true));
1316 public function delete($sOxId = null)
1319 if (!$this->
load($sOxId)) {
1323 } elseif (!$sOxId) {
1324 $sOxId = $this->
getId();
1335 foreach ($oOrderArticles as $oOrderArticle) {
1336 $oOrderArticle->delete();
1341 $oPaymentType->delete();
1370 $oBasket->calculateBasket(
true);
1386 if (defined(
'OXID_PHP_UNIT')) {
1403 $this->_oOrderBasket =
oxNew(
"oxBasket");
1404 $this->_oOrderBasket->enableSaveToDataBase(
false);
1407 $this->_oOrderBasket->setCalculationModeNetto($this->
isNettoMode());
1410 $this->_oOrderBasket->setStockCheckMode($blStockCheck);
1413 $this->_oOrderBasket->setBasketUser($this->
getOrderUser());
1416 $this->_oOrderBasket->setOrderId($this->
getId());
1419 $aCurrencies = $this->
getConfig()->getCurrencyArray();
1420 foreach ($aCurrencies as $oCur) {
1421 if ($oCur->name == $this->oxorder__oxcurrency->value) {
1422 $oBasketCur = $oCur;
1428 $this->_oOrderBasket->setBasketCurrency($oBasketCur);
1431 $this->_oOrderBasket->setCardId($this->oxorder__oxcardid->value);
1432 $this->_oOrderBasket->setCardMessage($this->oxorder__oxcardtext->value);
1434 if ($this->_blReloadDiscount) {
1437 $this->_oOrderBasket->setSkipVouchersChecking(
true);
1440 $sQ =
'select oxid from oxvouchers where oxorderid = ' . $oDb->quote($this->
getId());
1441 $aVouchers = $oDb->getAll($sQ);
1442 foreach ($aVouchers as $aVoucher) {
1443 $this->_oOrderBasket->addVoucher($aVoucher[
'oxid']);
1446 $this->_oOrderBasket->setDiscountCalcMode(
false);
1447 $this->_oOrderBasket->setVoucherDiscount($this->oxorder__oxvoucherdiscount->value);
1448 $this->_oOrderBasket->setTotalDiscount($this->oxorder__oxdiscount->value);
1452 if (!$this->_blReloadDelivery) {
1456 $this->_oOrderBasket->setShipping($this->oxorder__oxdeltype->value);
1457 $this->_oOrderBasket->setDeliveryPrice(null);
1461 $this->_oOrderBasket->setPayment($this->oxorder__oxpaymenttype->value);
1475 $this->oxorder__oxdeltype =
new oxField($sDeliveryId);
1485 if ($this->_oUser === null) {
1486 $this->_oUser =
oxNew(
"oxuser");
1487 $this->_oUser->load($this->oxorder__oxuserid->value);
1490 if ($this->_isLoaded) {
1492 $this->_oUser->oxuser__oxcompany = clone $this->oxorder__oxbillcompany;
1493 $this->_oUser->oxuser__oxusername = clone $this->oxorder__oxbillemail;
1494 $this->_oUser->oxuser__oxfname = clone $this->oxorder__oxbillfname;
1495 $this->_oUser->oxuser__oxlname = clone $this->oxorder__oxbilllname;
1496 $this->_oUser->oxuser__oxstreet = clone $this->oxorder__oxbillstreet;
1497 $this->_oUser->oxuser__oxstreetnr = clone $this->oxorder__oxbillstreetnr;
1498 $this->_oUser->oxuser__oxaddinfo = clone $this->oxorder__oxbilladdinfo;
1499 $this->_oUser->oxuser__oxustid = clone $this->oxorder__oxbillustid;
1502 $this->_oUser->oxuser__oxcity = clone $this->oxorder__oxbillcity;
1503 $this->_oUser->oxuser__oxcountryid = clone $this->oxorder__oxbillcountryid;
1504 $this->_oUser->oxuser__oxstateid = clone $this->oxorder__oxbillstateid;
1505 $this->_oUser->oxuser__oxzip = clone $this->oxorder__oxbillzip;
1506 $this->_oUser->oxuser__oxfon = clone $this->oxorder__oxbillfon;
1507 $this->_oUser->oxuser__oxfax = clone $this->oxorder__oxbillfax;
1508 $this->_oUser->oxuser__oxsal = clone $this->oxorder__oxbillsal;
1548 public function genPdf($sFilename, $iSelLang = 0)
1559 $sQ =
'select max(oxorder.oxinvoicenr) from oxorder where oxorder.oxshopid = "' . $this->
getConfig()->getShopId() .
'" ';
1561 return ((
int )
oxDb::getDb()->getOne($sQ,
false) + 1);
1571 $sQ =
'select max(cast(oxorder.oxbillnr as unsigned)) from oxorder where oxorder.oxshopid = "' . $this->
getConfig()->getShopId() .
'" ';
1573 return ((
int )
oxDb::getDb()->getOne($sQ,
false) + 1);
1584 if (!($sShipId = $this->oxorder__oxdelcountryid->value)) {
1585 $sShipId = $this->oxorder__oxbillcountryid->value;
1592 foreach ($oOrderArticles as $sItemId => $oItem) {
1593 if ($oItem->isBundle()) {
1594 $oOrderArticles->offsetUnset($sItemId);
1602 $oBasket->calculateBasket(
true);
1605 $oDeliveryList =
oxNew(
"oxDeliveryList",
"core");
1606 $oDeliveryList->setCollectFittingDeliveriesSets(
true);
1608 return $oDeliveryList->getDeliveryList($oBasket, $this->
getOrderUser(), $sShipId);
1619 $aVouchers = array();
1620 $sSelect =
"select oxvouchernr from oxvouchers where oxorderid = " . $oDb->quote($this->oxorder__oxid->value);
1621 $rs = $oDb->select($sSelect);
1622 if ($rs !=
false && $rs->recordCount() > 0) {
1624 $aVouchers[] = $rs->fields[
'oxvouchernr'];
1641 $sSelect =
'select sum(oxtotalordersum / oxcurrate) from oxorder where ';
1642 $sSelect .=
'oxshopid = "' . $this->
getConfig()->getShopId() .
'" and oxorder.oxstorno != "1" ';
1645 $sSelect .=
'and oxorderdate like "' . date(
'Y-m-d') .
'%" ';
1648 return (
double )
oxDb::getDb()->getOne($sSelect,
false,
false);
1660 $sSelect =
'select count(*) from oxorder where ';
1661 $sSelect .=
'oxshopid = "' . $this->
getConfig()->getShopId() .
'" and oxorder.oxstorno != "1" ';
1664 $sSelect .=
'and oxorderdate like "' . date(
'Y-m-d') .
'%" ';
1667 return (
int )
oxDb::getDb()->getOne($sSelect,
false,
false);
1685 if ($oDb->getOne(
'select oxid from oxorder where oxid = ' . $oDb->quote($sOxId),
false,
false)) {
1706 $this->_oUser = $oUser;
1707 $this->_oBasket = $oBasket;
1708 $this->_oPayment = $oPayment;
1710 $oxEmail =
oxNew(
'oxemail');
1713 if ($oxEmail->sendOrderEMailToUser($this)) {
1719 $oxEmail->sendOrderEMailToOwner($this);
1761 if ($this->_oDelSet == null) {
1763 $this->_oDelSet =
oxNew(
'oxdeliveryset');
1764 $this->_oDelSet->load($this->oxorder__oxdeltype->value);
1777 if ($this->oxorder__oxpaymentid->value && $this->_oPaymentType === null) {
1778 $this->_oPaymentType =
false;
1779 $oPaymentType =
oxNew(
'oxuserpayment');
1780 if ($oPaymentType->load($this->oxorder__oxpaymentid->value)) {
1781 $this->_oPaymentType = $oPaymentType;
1795 if ($this->oxorder__oxcardid->value && $this->_oGiftCard == null) {
1796 $this->_oGiftCard =
oxNew(
'oxwrapping');
1797 $this->_oGiftCard->load($this->oxorder__oxcardid->value);
1810 $this->_blSeparateNumbering = $blSeparateNumbering;
1823 $sQ =
'select oxorder.oxpaymenttype from oxorder where oxorder.oxshopid="' . $this->
getConfig()->getShopId() .
'" and oxorder.oxuserid=' . $oDb->quote($sUserId) .
' order by oxorder.oxorderdate desc ';
1824 $sLastPaymentId = $oDb->getOne($sQ,
false,
false);
1826 return $sLastPaymentId;
1838 if (count($aOrderArticles) > 0) {
1841 foreach ($aOrderArticles as $oOrderArticle) {
1842 $oBasket->addOrderArticleToBasket($oOrderArticle);
1856 if (count($aArticles) > 0) {
1859 foreach ($aArticles as $oArticle) {
1860 $aSel = isset($oArticle->oxorderarticles__oxselvariant) ? $oArticle->oxorderarticles__oxselvariant->value : null;
1861 $aPersParam = isset($oArticle->oxorderarticles__oxpersparam) ? $oArticle->getPersParams() : null;
1862 $oBasket->addToBasket(
1863 $oArticle->oxorderarticles__oxartid->value,
1864 $oArticle->oxorderarticles__oxamount->value,
1878 $oCur = $this->
getConfig()->getActShopCurrencyObject();
1880 return number_format((
double) $this->oxorder__oxtotalordersum->value, $oCur->decimal,
'.',
'');
1893 if ($this->oxorder__oxartvat1->value) {
1894 $aVats[$this->oxorder__oxartvat1->value] = $this->oxorder__oxartvatprice1->value;
1896 if ($this->oxorder__oxartvat2->value) {
1897 $aVats[$this->oxorder__oxartvat2->value] = $this->oxorder__oxartvatprice2->value;
1900 if ($blFormatCurrency) {
1902 $oCur = $this->
getConfig()->getActShopCurrencyObject();
1903 foreach ($aVats as $sKey => $dVat) {
1904 $aVats[$sKey] = $oLang->formatCurrency($dVat, $oCur);
1918 if (!$this->oxorder__oxbillcountry->value) {
1922 return $this->oxorder__oxbillcountry;
1932 if (!$this->oxorder__oxdelcountry->value) {
1936 return $this->oxorder__oxdelcountry;
1946 $this->_blReloadDelivery = $blReload;
1956 $this->_blReloadDiscount = $blReload;
1964 $this->oxorder__oxstorno =
new oxField(1);
1965 if ($this->
save()) {
1972 $oOrderArticle->cancelOrderArticle();
1985 if ($this->_oOrderCurrency === null) {
1988 $aCurrencies = $this->
getConfig()->getCurrencyArray();
1989 $this->_oOrderCurrency = current($aCurrencies);
1991 foreach ($aCurrencies as $oCurr) {
1992 if ($oCurr->name == $this->oxorder__oxcurrency->value) {
1993 $this->_oOrderCurrency = $oCurr;
2014 $iValidState = $this->validateStock($oBasket);
2016 if (!$iValidState) {
2021 if (!$iValidState) {
2026 if (!$iValidState) {
2028 $iValidState = $this->validateDeliveryAddress($oUser);
2031 if (!$iValidState) {
2036 return $iValidState;
2048 return $oBasket->isBelowMinOrderPrice() ? self::ORDER_STATE_BELOWMINPRICE : null;
2059 public function validateDeliveryAddress($oUser)
2061 $sDelAddressMD5 = $this->
getConfig()->getRequestParameter(
'sDeliveryAddressMD5');
2063 $sDeliveryAddress = $oUser->getEncodedDeliveryAddress();
2066 $oRequiredAddressFields =
oxNew(
'oxRequiredAddressFields');
2069 $oFieldsValidator =
oxNew(
'oxRequiredFieldsValidator');
2070 $oFieldsValidator->setRequiredFields($oRequiredAddressFields->getBillingFields());
2071 $blFieldsValid = $oFieldsValidator->validateFields($oUser);
2075 if ($blFieldsValid && $oDeliveryAddress) {
2076 $sDeliveryAddress .= $oDeliveryAddress->getEncodedDeliveryAddress();
2078 $oFieldsValidator->setRequiredFields($oRequiredAddressFields->getDeliveryFields());
2079 $blFieldsValid = $oFieldsValidator->validateFields($oDeliveryAddress);
2083 if ($sDelAddressMD5 != $sDeliveryAddress || !$blFieldsValid) {
2103 if ($oBasket->getPaymentId() ==
'oxempty') {
2108 $oDelSet =
oxNew(
"oxdeliveryset");
2109 $sTable = $oDelSet->getViewName();
2111 $sQ =
"select 1 from {$sTable} where {$sTable}.oxid=" .
2112 $oDb->quote($oBasket->getShippingId()) .
" and " . $oDelSet->getSqlActiveSnippet();
2114 if (!$oDb->getOne($sQ,
false,
false)) {
2132 $oPayment =
oxNew(
"oxpayment");
2133 $sTable = $oPayment->getViewName();
2135 $sQ =
"select 1 from {$sTable} where {$sTable}.oxid=" .
2136 $oDb->quote($oBasket->getPaymentId()) .
" and " . $oPayment->getSqlActiveSnippet();
2138 if (!$oDb->getOne($sQ,
false,
false)) {
2151 if (($oTsProtectionCost = $oBasket->
getCosts(
'oxtsprotection'))) {
2152 $this->oxorder__oxtsprotectcosts =
new oxField($oTsProtectionCost->getBruttoPrice(),
oxField::T_RAW);
2166 protected function _executeTsProtection(
oxBasket $oBasket)
2168 $aValues[
'tsProductId'] = $this->oxorder__oxtsprotectid->value;
2170 $oCur = $this->
getConfig()->getActShopCurrencyObject();
2171 $aValues[
'currency'] = $oCur->name;
2172 $aValues[
'buyerEmail'] = $this->oxorder__oxbillemail->value;
2173 $aValues[
'shopCustomerID'] = $this->oxorder__oxuserid->value;
2174 $aValues[
'shopOrderID'] = $this->oxorder__oxordernr->value;
2175 $aValues[
'orderDate'] = $this->oxorder__oxorderdate->value;
2179 $oTsProtection =
oxNew(
'oxtsprotection');
2180 $oTsProtection->requestForTsProtection($aValues, $sPaymentId);
2192 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxtotalnetsum->value, $this->getOrderCurrency());
2202 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxtotalbrutsum->value, $this->getOrderCurrency());
2212 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxdelcost->value, $this->getOrderCurrency());
2234 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxpaycost->value, $this->getOrderCurrency());
2244 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxwrapcost->value, $this->getOrderCurrency());
2254 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxgiftcardcost->value, $this->getOrderCurrency());
2264 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxvoucherdiscount->value, $this->getOrderCurrency());
2274 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxdiscount->value, $this->getOrderCurrency());
2284 return oxRegistry::getLang()->formatCurrency($this->oxorder__oxtotalordersum->value, $this->getOrderCurrency());
2294 return $this->oxorder__oxtrackcode->value;
2305 if ($this->_sShipTrackUrl === null) {
2306 $sParcelService = $oConfig->getConfigParam(
'sParcelService');
2308 if ($sParcelService && $sTrackingCode) {
2309 $this->_sShipTrackUrl = str_replace(
"##ID##", $sTrackingCode, $sParcelService);