277 $this->_blSaveToDataBase = $blSave;
287 if (is_null($this->_blSaveToDataBase)) {
288 $this->_blSaveToDataBase = (bool) !$this->
getConfig()->getConfigParam(
'blPerfNoBasketSaving');
302 if ($this->_isCalculationModeNetto === null) {
316 $this->_isCalculationModeNetto = (bool) $blNettoMode;
346 $this->_dNettoSum = $dNettoSum;
356 $this->_dBruttoSum = $dBruttoSum;
378 reset($this->_aBasketContents);
380 while (key($this->_aBasketContents) != $sOldKey && next($this->_aBasketContents)) {
383 $aNewCopy = array_merge(
384 array_slice($this->_aBasketContents, 0, $iOldKeyPlace,
true),
385 array($sNewKey => $value),
386 array_slice($this->_aBasketContents, $iOldKeyPlace + 1, count($this->_aBasketContents) - $iOldKeyPlace,
true)
388 $this->_aBasketContents = $aNewCopy;
406 public function addToBasket($sProductID, $dAmount, $aSel = null, $aPersParam = null, $blOverride =
false, $blBundle =
false, $sOldBasketItemId = null)
414 if ($this->
getConfig()->getConfigParam(
'blBasketExcludeEnabled')) {
424 $sItemId = $this->
getItemKey($sProductID, $aSel, $aPersParam, $blBundle);
425 if ($sOldBasketItemId && (strcmp($sOldBasketItemId, $sItemId) != 0)) {
426 if (isset($this->_aBasketContents[$sItemId])) {
428 unset($this->_aBasketContents[$sOldBasketItemId]);
438 $blRemoveItem =
false;
443 if (isset($this->_aBasketContents[$sItemId])) {
448 $this->_aBasketContents[$sItemId]->setStockCheckStatus($this->
getStockCheckMode());
451 $this->_aBasketContents[$sItemId]->setAmount($dAmount, $blOverride, $sItemId);
458 $oBasketItem =
oxNew(
'oxbasketitem');
461 $oBasketItem->init($sProductID, $dAmount, $aSel, $aPersParam, $blBundle);
465 $blRemoveItem =
true;
471 $blRemoveItem =
true;
474 $this->_aBasketContents[$sItemId] = $oBasketItem;
478 if ($this->_aBasketContents[$sItemId]->getAmount() == 0 || $blRemoveItem) {
480 } elseif ($blBundle) {
482 $this->_aBasketContents[$sItemId]->setBundle(
true);
494 $this->
_addedNewItem($sProductID, $dAmount, $aSel, $aPersParam, $blOverride, $blBundle, $sOldBasketItemId);
498 if (is_a($this->_aBasketContents[$sItemId],
'oxBasketItem')) {
499 $this->_aBasketContents[$sItemId]->setBasketItemKey($sItemId);
501 return $this->_aBasketContents[$sItemId];
514 if ($oOrderArticle->oxorderarticles__oxamount->value > 0 && !$oOrderArticle->isBundle()) {
516 $this->_isForOrderRecalculation =
true;
517 $sItemId = $oOrderArticle->getId();
520 $this->_aBasketContents[$sItemId] =
oxNew(
'oxbasketitem');
521 $this->_aBasketContents[$sItemId]->initFromOrderArticle($oOrderArticle);
522 $this->_aBasketContents[$sItemId]->setWrapping($oOrderArticle->oxorderarticles__oxwrapid->value);
523 $this->_aBasketContents[$sItemId]->setBundle($oOrderArticle->isBundle());
528 return $this->_aBasketContents[$sItemId];
529 } elseif ($oOrderArticle->isBundle()) {
531 $oOrderArticle->delete();
542 $this->_blCheckStock = $blCheck;
567 public function getItemKey($sProductId, $aSel = null, $aPersParam = null, $blBundle =
false, $sAdditionalParam =
'')
569 $aSel = ($aSel != null) ? $aSel : array(0 =>
'0');
571 $sItemKey = md5($sProductId .
'|' . serialize($aSel) .
'|' . serialize($aPersParam) .
'|' . (
int ) $blBundle .
'|' . serialize($sAdditionalParam));
584 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled')) {
585 if (isset($this->_aBasketContents[$sItemKey])) {
586 $sArticleId = $this->_aBasketContents[$sItemKey]->getProductId();
589 ->getBasketReservations()
590 ->discardArticleReservation($sArticleId);
594 unset($this->_aBasketContents[$sItemKey]);
597 if (!count($this->_aBasketContents) && $this->
getConfig()->getConfigParam(
'blBasketExcludeEnabled')) {
607 reset($this->_aBasketContents);
608 while (list($sItemKey, $oBasketItem) = each($this->_aBasketContents)) {
609 if ($oBasketItem->isBundle()) {
626 if ($oBasketItem->isBundle()) {
630 $oArticle = $oBasketItem->getArticle(
true);
631 if ($oArticle && $oArticle->oxarticles__oxbundleid->value) {
632 $aBundles[$oArticle->oxarticles__oxbundleid->value] = 1;
649 if ($oBasketItem->isBundle()) {
654 if ($oArticle = $oBasketItem->getArticle()) {
657 foreach ($aDiscounts as $oDiscount) {
659 $iAmnt = $oDiscount->getBundleAmount($oBasketItem->getAmount());
662 if (!isset($aBundles[$oDiscount->oxdiscount__oxitmartid->value])) {
663 $aBundles[$oDiscount->oxdiscount__oxitmartid->value] = 0;
666 if ($oDiscount->oxdiscount__oxitmmultiple->value) {
667 $aBundles[$oDiscount->oxdiscount__oxitmartid->value] += $iAmnt;
669 $aBundles[$oDiscount->oxdiscount__oxitmartid->value] = $iAmnt;
691 foreach ($this->_aBasketContents as $oBasketItem) {
692 if (!($oBasketItem->isBundle() || $oBasketItem->isDiscountArticle())) {
693 $dAmount += $oBasketItem->getAmount();
697 foreach ($aDiscounts as $oDiscount) {
698 if ($oDiscount->oxdiscount__oxitmartid->value) {
699 if (!isset($aBundles[$oDiscount->oxdiscount__oxitmartid->value])) {
700 $aBundles[$oDiscount->oxdiscount__oxitmartid->value] = 0;
703 $aBundles[$oDiscount->oxdiscount__oxitmartid->value] += $oDiscount->getBundleAmount($dAmount);
718 foreach ($this->_aBasketContents as $key => $oBasketItem) {
721 if (!$oBasketItem->isDiscountArticle() && !$oBasketItem->isBundle()) {
757 foreach ($aBundles as $sBundleId => $dAmount) {
760 if ($oBundleItem = $this->
addToBasket($sBundleId, $dAmount, null, null,
false,
true)) {
761 $oBundleItem->setAsDiscountArticle(
true);
766 $sItemId = $this->
getItemKey($sBundleId, null, null,
true);
767 $this->_aBasketContents[$sItemId]->setAsDiscountArticle(
true );
782 $this->_iProductsCnt = 0;
783 $this->_dItemsCnt = 0;
786 $this->_oProductsPriceList =
oxNew(
'oxpricelist');
787 $this->_oDiscountProductsPriceList =
oxNew(
'oxpricelist');
788 $this->_oNotDiscountedProductsPriceList =
oxNew(
'oxpricelist');
792 foreach ($this->_aBasketContents as $oBasketItem) {
793 $this->_iProductsCnt++;
794 $this->_dItemsCnt += $oBasketItem->getAmount();
795 $this->_dWeight += $oBasketItem->getWeight();
797 if (!$oBasketItem->isDiscountArticle() && ($oArticle = $oBasketItem->getArticle(
true))) {
799 $oBasketPrice = $oArticle->getBasketPrice($oBasketItem->getAmount(), $oBasketItem->getSelList(), $this);
800 $oBasketItem->setRegularUnitPrice(clone $oBasketPrice);
804 $aDiscounts = $oDiscountList->getBasketItemDiscounts($oArticle, $this, $this->
getBasketUser());
806 foreach ($aDiscounts as $oDiscount) {
807 $oBasketPrice->setDiscount($oDiscount->getAddSum(), $oDiscount->getAddSumType());
809 $oBasketPrice->calculateDiscount();
811 $oBasketItem->setSkipDiscounts(
true);
815 $oBasketItem->setPrice($oBasketPrice);
816 $this->_oProductsPriceList->addToPriceList($oBasketItem->getPrice());
819 if (!$oArticle->skipDiscounts()) {
821 $this->_oDiscountProductsPriceList->addToPriceList($oBasketItem->getPrice());
823 $this->_oNotDiscountedProductsPriceList->addToPriceList($oBasketItem->getPrice());
824 $oBasketItem->setSkipDiscounts(
true);
827 } elseif ($oBasketItem->isBundle()) {
829 $oPrice =
oxNew(
"oxprice");
830 $oBasketItem->setPrice($oPrice);
842 $this->_blCalcDiscounts = $blCalcDiscounts;
866 foreach ($aItemDiscounts as $sKey => $oDiscount) {
868 if (array_key_exists($sKey, $aDiscounts)) {
869 $aDiscounts[$sKey]->dDiscount += $oDiscount->dDiscount;
871 $aDiscounts[$sKey] = $oDiscount;
885 if ($this->_oDeliveryPrice !== null) {
889 $oDeliveryPrice =
oxNew(
'oxprice');
891 if ($this->
getConfig()->getConfigParam(
'blDeliveryVatOnTop')) {
892 $oDeliveryPrice->setNettoPriceMode();
894 $oDeliveryPrice->setBruttoPriceMode();
900 if (!$oUser && !
$myConfig->getConfigParam(
'blCalculateDelCostIfNotLoggedIn')) {
901 return $oDeliveryPrice;
905 $oDeliveryPrice->setVat($fDelVATPercent);
908 if (
$myConfig->getConfigParam(
'bl_perfLoadDelivery')) {
916 if (count($aDeliveryList) > 0) {
917 foreach ($aDeliveryList as $oDelivery) {
919 if (
$myConfig->getConfigParam(
'iDebug') == 5) {
920 echo(
"DelCost : " . $oDelivery->oxdelivery__oxtitle->value .
"<br>");
922 $oDeliveryPrice->addPrice($oDelivery->getDeliveryPrice($fDelVATPercent));
927 return $oDeliveryPrice;
937 if ($this->_oUser == null) {
951 $this->_oUser = $oUser;
962 if ($this->_oProductsPriceList) {
963 return $this->_oProductsPriceList->getMostUsedVatPercent();
974 if ($this->_oProductsPriceList) {
975 if ($this->
getConfig()->getConfigParam(
'sAdditionalServVATCalcMethod') ==
'proportional') {
976 return $this->_oProductsPriceList->getProportionalVatPercent();
978 return $this->_oProductsPriceList->getMostUsedVatPercent();
990 if ($this->
getConfig()->getConfigParam(
'sAdditionalServVATCalcMethod') ==
'proportional') {
1007 $oTotalPrice =
oxNew(
'oxPrice');
1008 $oTotalPrice->setBruttoPriceMode();
1009 $oTotalPrice->setPrice($dPrice);
1015 $oTotalPrice->subtract($this->_oTotalDiscount->getBruttoPrice());
1019 $oTotalPrice->subtract($oVoucherDisc->getBruttoPrice());
1024 if (isset($this->_aCosts[
'oxdelivery'])) {
1025 $oTotalPrice->add($this->_aCosts[
'oxdelivery']->getBruttoPrice());
1029 if (isset($this->_aCosts[
'oxwrapping'])) {
1030 $oTotalPrice->add($this->_aCosts[
'oxwrapping']->getBruttoPrice());
1032 if (isset($this->_aCosts[
'oxgiftcard'])) {
1033 $oTotalPrice->add($this->_aCosts[
'oxgiftcard']->getBruttoPrice());
1037 if (isset($this->_aCosts[
'oxpayment'])) {
1038 $oTotalPrice->add($this->_aCosts[
'oxpayment']->getBruttoPrice());
1042 if (isset($this->_aCosts[
'oxtsprotection'])) {
1043 $oTotalPrice->add($this->_aCosts[
'oxtsprotection']->getBruttoPrice());
1056 $this->_oVoucherDiscount =
oxNew(
'oxPrice');
1057 $this->_oVoucherDiscount->setBruttoPriceMode();
1058 $this->_oVoucherDiscount->add($dDiscount);
1066 if ($this->
getConfig()->getConfigParam(
'bl_showVouchers') && ($this->_oVoucherDiscount === null || ($this->_blUpdateNeeded && !$this->
isAdmin()))) {
1071 $dPrice = $this->_oDiscountProductsPriceList->getSum($this->
isCalculationModeNetto()) - $this->_oTotalDiscount->getPrice();
1074 if (count($this->_aVouchers)) {
1076 foreach ($this->_aVouchers as $sVoucherId => $oStdVoucher) {
1077 $oVoucher =
oxNew(
'oxvoucher');
1079 $oVoucher->load($oStdVoucher->sVoucherId);
1081 if (!$this->_blSkipVouchersAvailabilityChecking) {
1082 $oVoucher->checkBasketVoucherAvailability($this->_aVouchers, $dPrice);
1087 $dVoucherdiscount = $oVoucher->getDiscountValue($dPrice);
1089 if ($dVoucherdiscount > 0) {
1091 if ($oVoucher->getDiscountType() ==
'absolute') {
1092 $dVatPart = ($dPrice - $dVoucherdiscount) / $dPrice * 100;
1094 $dVatPart = 100 - $oVoucher->getDiscount();
1097 if (!$this->_aDiscountedVats) {
1104 foreach ($this->_aDiscountedVats as $sKey => $dVat) {
1110 $this->_oVoucherDiscount->add($dVoucherdiscount);
1113 $oStdVoucher->fVoucherdiscount = $oLang->formatCurrency($dVoucherdiscount, $this->
getBasketCurrency());
1114 $oStdVoucher->dVoucherdiscount = $dVoucherdiscount;
1117 $dPrice = $dPrice - $dVoucherdiscount;
1123 $oVoucher->unMarkAsReserved();
1124 unset($this->_aVouchers[$sVoucherId]);
1144 foreach ($this->_aDiscountedVats as $dVat) {
1145 $dVatSum += $oUtils->fRound($dVat, $this->_oCurrency);
1153 $this->
setBruttoSum($oNotDiscounted->getSum(
false) + $dDiscountedSum + $dVatSum);
1156 $this->
setNettoSum($oNotDiscounted->getSum() + $dDiscountedSum - $dVatSum);
1168 $blResult = (bool) $this->
getConfig()->getConfigParam(
'blShowNetPrice');
1171 $blResult = $oUser->isPriceViewModeNetto();
1184 $oPrice =
oxNew(
'oxPrice');
1187 $oPrice->setNettoPriceMode();
1189 $oPrice->setBruttoPriceMode();
1201 $this->_aDiscounts = array();
1207 if ($this->_oTotalDiscount !== null && isset($this->_isForOrderRecalculation) && $this->_isForOrderRecalculation) {
1210 $oDiscount =
oxNew(
'oxDiscount');
1211 $oDiscount->oxdiscount__oxaddsum =
new oxField($oTotalPrice->getPrice());
1212 $oDiscount->oxdiscount__oxaddsumtype =
new oxField(
'abs');
1213 $aDiscounts[] = $oDiscount;
1223 foreach ($aDiscounts as $oDiscount) {
1226 $oStdDiscount = $oDiscount->getSimpleDiscount();
1229 if ($oDiscount->oxdiscount__oxaddsumtype->value ==
'itm') {
1234 $oStdDiscount->dDiscount = $oDiscount->getAbsValue($dOldPrice);
1236 $dVatPart = 100 - $oDiscount->getPercentage($dOldPrice);
1239 if ($dOldPrice < $oStdDiscount->dDiscount) {
1240 $oStdDiscount->dDiscount = $dOldPrice;
1245 foreach ($this->_aDiscountedVats as $sKey => $dVat) {
1250 if ($oStdDiscount->dDiscount != 0) {
1251 $this->_aDiscounts[$oDiscount->getId()] = $oStdDiscount;
1253 $dOldPrice = $dOldPrice - $oStdDiscount->dDiscount;
1263 if ($this->_oTotalDiscount === null || (!$this->
isAdmin())) {
1267 if (is_array($this->_aDiscounts)) {
1268 foreach ($this->_aDiscounts as $oDiscount) {
1271 if ($oDiscount->sType ==
'itm') {
1276 $this->_oTotalDiscount->add($oDiscount->dDiscount);
1292 $oWrappingPrices =
oxNew(
'oxPriceList');
1294 foreach ($this->_aBasketContents as $oBasketItem) {
1296 if (($oWrapping = $oBasketItem->getWrapping())) {
1298 $oWrappingPrice = $oWrapping->getWrappingPrice($oBasketItem->getAmount());
1299 $oWrappingPrice->setVat($oBasketItem->getPrice()->getVat());
1301 $oWrappingPrices->addToPriceList($oWrappingPrice);
1305 if ($oWrappingPrices->getCount()) {
1306 $oWrappingCost =
oxNew(
'oxPrice');
1307 $oWrappingCost = $oWrappingPrices->calculateToPrice();
1310 return $oWrappingCost;
1323 $oGiftCardPrice =
oxNew(
'oxPrice');
1325 if ($this->
getConfig()->getConfigParam(
'blWrappingVatOnTop')) {
1326 $oGiftCardPrice->setNettoPriceMode();
1328 $oGiftCardPrice->setBruttoPriceMode();
1333 $oGiftCardPrice->setVat($dVATPercent);
1336 if (($oCard = $this->
getCard())) {
1337 if ($dVATPercent !== null) {
1338 $oCard->setWrappingVat($dVATPercent);
1340 $oGiftCardPrice->addPrice($oCard->getWrappingPrice());
1343 return $oGiftCardPrice;
1355 $oPaymentPrice =
oxNew(
'oxPrice');
1360 $oPayment =
oxNew(
'oxPayment');
1361 $oPayment->load($this->_sPaymentId);
1363 $oPayment->calculate($this);
1364 $oPaymentPrice = $oPayment->getPrice();
1367 return $oPaymentPrice;
1379 $oTsProtection =
oxNew(
'oxtsprotection');
1380 $oTsProduct = $oTsProtection->getTsProduct($this->
getTsProductId());
1381 $oProtectionPrice = $oTsProduct->getPrice();
1384 $oProtectionPrice =
oxNew(
'oxPrice');
1387 return $oProtectionPrice;
1396 public function setCost($sCostName, $oPrice = null)
1398 $this->_aCosts[$sCostName] = $oPrice;
1428 if ($blForceUpdate) {
1432 if (!($this->_blUpdateNeeded || $blForceUpdate)) {
1436 $this->_aCosts = array();
1448 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled')) {
1449 $this->
getSession()->getBasketReservations()->reserveBasket($this);
1497 $this->_blUpdateNeeded =
true;
1505 $this->_blUpdateNeeded =
false;
1517 if ($this->_blUpdateNeeded || $this->_aBasketSummary === null) {
1518 $this->_aBasketSummary =
new stdclass();
1519 $this->_aBasketSummary->aArticles = array();
1520 $this->_aBasketSummary->aCategories = array();
1521 $this->_aBasketSummary->iArticleCount = 0;
1522 $this->_aBasketSummary->dArticlePrice = 0;
1523 $this->_aBasketSummary->dArticleDiscountablePrice = 0;
1531 foreach ($this->_aBasketContents as $oBasketItem) {
1532 if (!$oBasketItem->isBundle() && $oArticle = $oBasketItem->getArticle(
false)) {
1533 $aCatIds = $oArticle->getCategoryIds();
1536 $dDiscountablePrice = 0;
1537 if (($oPrice = $oArticle->getBasketPrice($oBasketItem->getAmount(), $oBasketItem->getSelList(), $this))) {
1538 $dPrice = $oPrice->getPrice();
1539 if (!$oArticle->skipDiscounts()) {
1540 $dDiscountablePrice = $dPrice;
1544 foreach ($aCatIds as $sCatId) {
1545 if (!isset($this->_aBasketSummary->aCategories[$sCatId])) {
1546 $this->_aBasketSummary->aCategories[$sCatId] =
new stdClass();
1549 $this->_aBasketSummary->aCategories[$sCatId]->dPrice += $dPrice * $oBasketItem->getAmount();
1550 $this->_aBasketSummary->aCategories[$sCatId]->dDiscountablePrice += $dDiscountablePrice * $oBasketItem->getAmount();
1551 $this->_aBasketSummary->aCategories[$sCatId]->dAmount += $oBasketItem->getAmount();
1552 $this->_aBasketSummary->aCategories[$sCatId]->iCount++;
1556 if (($sParentId = $oArticle->getParentId()) &&
$myConfig->getConfigParam(
'blVariantParentBuyable')) {
1557 if (!isset($this->_aBasketSummary->aArticles[$sParentId])) {
1558 $this->_aBasketSummary->aArticles[$sParentId] = 0;
1560 $this->_aBasketSummary->aArticles[$sParentId] += $oBasketItem->getAmount();
1563 if (!isset($this->_aBasketSummary->aArticles[$oBasketItem->getProductId()])) {
1564 $this->_aBasketSummary->aArticles[$oBasketItem->getProductId()] = 0;
1567 $this->_aBasketSummary->aArticles[$oBasketItem->getProductId()] += $oBasketItem->getAmount();
1568 $this->_aBasketSummary->iArticleCount += $oBasketItem->getAmount();
1569 $this->_aBasketSummary->dArticlePrice += $dPrice * $oBasketItem->getAmount();
1570 $this->_aBasketSummary->dArticleDiscountablePrice += $dDiscountablePrice * $oBasketItem->getAmount();
1591 if ($this->_oDiscountProductsPriceList) {
1597 $oVoucher =
oxNew(
'oxvoucher');
1599 if (!$this->_blSkipVouchersAvailabilityChecking) {
1600 $oVoucher->getVoucherByNr($sVoucherId, $this->_aVouchers,
true);
1601 $oVoucher->checkVoucherAvailability($this->_aVouchers, $dPrice);
1603 $oVoucher->markAsReserved();
1605 $oVoucher->load($sVoucherId);
1609 $this->_aVouchers[$oVoucher->oxvouchers__oxid->value] = $oVoucher->getSimpleVoucher();
1627 if (isset($this->_aVouchers[$sVoucherId])) {
1629 $oVoucher =
oxNew(
'oxVoucher');
1630 $oVoucher->load($sVoucherId);
1632 $oVoucher->unMarkAsReserved();
1635 unset($this->_aVouchers[$sVoucherId]);
1658 if (count($this->aDiscounts) > 0) {
1660 foreach ($this->aDiscounts as $oDiscount) {
1661 $oDiscount->fDiscount = $oLang->formatCurrency($oDiscount->dDiscount, $this->getBasketCurrency());
1690 $oBasket = $oUser->getBasket(
'savedbasket');
1693 $aSavedItems = $oBasket->getItems();
1694 foreach ($aSavedItems as $oItem) {
1696 $oSelList = $oItem->getSelList();
1698 $this->
addToBasket($oItem->oxuserbasketitems__oxartid->value, $oItem->oxuserbasketitems__oxamount->value, $oSelList, $oItem->getPersParams(),
true);
1715 $oSavedBasket = $oUser->getBasket(
'savedbasket');
1716 $oSavedBasket->delete();
1719 foreach ($this->_aBasketContents as $oBasketItem) {
1721 if (!$oBasketItem->isBundle() && !$oBasketItem->isDiscountArticle()) {
1722 $oSavedBasket->addItemToBasket($oBasketItem->getProductId(), $oBasketItem->getAmount(), $oBasketItem->getSelList(),
true, $oBasketItem->getPersParams());
1738 $oUser->getBasket(
'savedbasket')->delete();
1742 if ($this->
getConfig()->getConfigParam(
'blBasketExcludeEnabled')) {
1757 $sDeliveryCountry = null;
1761 $aHomeCountry =
$myConfig->getConfigParam(
'aHomeCountry');
1762 if (
$myConfig->getConfigParam(
'blCalculateDelCostIfNotLoggedIn') && is_array($aHomeCountry)) {
1763 $sDeliveryCountry = current($aHomeCountry);
1768 if ($sCountryId =
$myConfig->getGlobalParameter(
'delcountryid')) {
1769 $sDeliveryCountry = $sCountryId;
1772 $oDeliveryAddress =
oxNew(
'oxAddress');
1773 if ($oDeliveryAddress->load($sAddressId)) {
1774 $sDeliveryCountry = $oDeliveryAddress->oxaddress__oxcountryid->value;
1779 if (!$sDeliveryCountry) {
1780 $sDeliveryCountry = $oUser->oxuser__oxcountryid->value;
1784 return $sDeliveryCountry;
1792 $this->_aBasketContents = array();
1795 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled')) {
1796 $this->
getSession()->getBasketReservations()->discardReservations();
1810 $this->_sPaymentId = $sPaymentId;
1820 if (!$this->_sPaymentId) {
1834 $this->_sShippingSetId = $sShippingSetId;
1845 $this->_oDeliveryPrice = $oShippingPrice;
1855 if (!$this->_sShippingSetId) {
1861 if (!$this->_sShippingSetId && $sActPaymentId !=
'oxempty') {
1865 list(, $sActShipSet) =
oxRegistry::get(
"oxDeliverySetList")->getDeliverySetData(null, $oUser, $this);
1867 $this->_sShippingSetId = $sActShipSet ? $sActShipSet : ($oUser ? null :
'oxidstandard');
1868 } elseif (!$this->
isAdmin() && $sActPaymentId ==
'oxempty') {
1870 $this->_sShippingSetId = null;
1883 $aBasketArticles = array();
1885 foreach ($this->_aBasketContents as $sItemKey => $oBasketItem) {
1887 $oProduct = $oBasketItem->getArticle(
true);
1889 if ($this->
getConfig()->getConfigParam(
'bl_perfLoadSelectLists')) {
1891 $aSelList = $oBasketItem->getSelList();
1892 if (is_array($aSelList) && ($aSelectlist = $oProduct->getSelectLists($sItemKey))) {
1894 while (list($conkey, $iSel) = each($aSelList)) {
1895 $aSelectlist[$conkey][$iSel] = $aSelectlist[$conkey][$iSel];
1896 $aSelectlist[$conkey][$iSel]->selected = 1;
1898 $oProduct->setSelectlist($aSelectlist);
1913 $aBasketArticles[$sItemKey] = $oProduct;
1916 return $aBasketArticles;
1936 if (is_null($this->_oProductsPriceList)) {
1937 $this->_oProductsPriceList =
oxNew(
'oxPriceList');
1950 if (is_null($this->_oPrice)) {
1964 $this->_oPrice = $oPrice;
1986 $this->_sOrderId = $sId;
2001 return isset($this->_aCosts[$sId]) ? $this->_aCosts[$sId] : null;
2066 if (!$this->_oNotDiscountedProductsPriceList) {
2073 foreach ($this->_aDiscountedVats as $sKey => $dVat) {
2074 if (!isset($aVats[$sKey])) {
2078 $aVats[$sKey] += $oUtils->fRound($dVat, $this->_oCurrency);
2081 if ($blFormatCurrency) {
2083 foreach ($aVats as $sKey => $dVat) {
2098 $this->_sCardMessage = $sMessage;
2108 return $this->_sCardMessage;
2118 $this->_sCardId = $sCardId;
2128 return $this->_sCardId;
2140 $oCard =
oxNew(
'oxWrapping');
2141 $oCard->load($sCardId);
2169 return array_merge($this->_aItemDiscounts, $this->_aDiscounts);
2179 if ($this->
getConfig()->getConfigParam(
'bl_showVouchers')) {
2193 $this->_oCurrency = $oCurrency;
2203 if ($this->_oCurrency === null) {
2204 $this->_oCurrency = $this->
getConfig()->getActShopCurrencyObject();
2217 $this->_blSkipVouchersAvailabilityChecking = $blSkipChecking;
2237 $this->_blSkipDiscounts = $blSkip;
2273 return $this->
getCosts(
'oxdelivery')->getVat();
2285 $dDelVAT = $this->
getCosts(
'oxdelivery')->getVatValue();
2288 if ($dDelVAT > 0 && $this->
getConfig()->getConfigParam(
'blShowVATForDelivery')) {
2307 if ($oConfig->getConfigParam(
'blShowVATForDelivery') && ($this->
getBasketUser() || $oConfig->getConfigParam(
'blCalculateDelCostIfNotLoggedIn'))) {
2308 $dNetPrice = $this->
getCosts(
'oxdelivery')->getNettoPrice();
2309 if ($dNetPrice > 0) {
2326 return $this->
getCosts(
'oxpayment')->getVat();
2338 $dPayVAT = $this->
getCosts(
'oxpayment')->getVatValue();
2341 if ($dPayVAT > 0 && $this->
getConfig()->getConfigParam(
'blShowVATForPayCharge')) {
2358 if ($this->
getConfig()->getConfigParam(
'blShowVATForPayCharge')) {
2359 $oPaymentCost = $this->
getCosts(
'oxpayment');
2360 if ($oPaymentCost && $oPaymentCost->getNettoPrice()) {
2377 $oPaymentCost = $this->
getCosts(
'oxpayment');
2378 if ($oPaymentCost && $oPaymentCost->getBruttoPrice()) {
2379 return $oPaymentCost->getBruttoPrice();
2390 return $this->
getCosts(
'oxpayment');
2402 $oPaymentCost = $this->
getCosts(
'oxpayment');
2403 if ($oPaymentCost && $oPaymentCost->getBruttoPrice()) {
2434 if ($oVoucherDiscount->getBruttoPrice()) {
2452 return $this->
getCosts(
'oxwrapping')->getVat();
2465 return $this->
getCosts(
'oxgiftcard')->getVat();
2478 if ($this->
getConfig()->getConfigParam(
'blShowVATForWrapping')) {
2479 $oPrice = $this->
getCosts(
'oxwrapping');
2481 if ($oPrice && $oPrice->getVatValue() > 0) {
2499 if ($this->
getConfig()->getConfigParam(
'blShowVATForWrapping')) {
2500 $oPrice = $this->
getCosts(
'oxwrapping');
2502 if ($oPrice && $oPrice->getNettoPrice() > 0) {
2519 $oPrice = $this->
getCosts(
'oxwrapping');
2521 if ($oPrice && $oPrice->getBruttoPrice()) {
2535 return $this->
getCosts(
'oxwrapping');
2548 if ($this->
getConfig()->getConfigParam(
'blShowVATForWrapping')) {
2549 $oPrice = $this->
getCosts(
'oxgiftcard');
2551 if ($oPrice && $oPrice->getVatValue() > 0) {
2570 if ($this->
getConfig()->getConfigParam(
'blShowVATForWrapping')) {
2571 $oPrice = $this->
getCosts(
'oxgiftcard');
2573 if ($oPrice && $oPrice->getNettoPrice() > 0) {
2590 $oPrice = $this->
getCosts(
'oxgiftcard');
2592 if ($oPrice && $oPrice->getBruttoPrice()) {
2606 return $this->
getCosts(
'oxgiftcard');
2630 $oPrice = $this->
getCosts(
'oxdelivery');
2632 if ($oPrice && ($this->
getBasketUser() || $this->
getConfig()->getConfigParam(
'blCalculateDelCostIfNotLoggedIn'))) {
2648 if ($oDeliveryCost = $this->
getCosts(
'oxdelivery')) {
2649 return $oDeliveryCost->getBruttoPrice();
2662 return $this->
getCosts(
'oxdelivery');
2672 $this->_oTotalDiscount =
oxNew(
'oxPrice');
2673 $this->_oTotalDiscount->setBruttoPriceMode();
2674 $this->_oTotalDiscount->add($dDiscount);
2688 $dPrice += $oPriceList->getBruttoSum();
2692 if ($oDeliveryPrice = $this->_aCosts[
'oxdelivery']) {
2693 $dPrice += $oDeliveryPrice->getBruttoPrice();
2713 $dPrice -= $oPrice->getPrice();
2717 $dPrice -= $oVoucherPrice->getPrice();
2733 $dPrice += $oPrice->getPrice();
2737 $dPrice += $oVoucherPrice->getPrice();
2751 $dPrice = $oProductsPrice->getBruttoSum();
2756 $dPrice -= $oPrice->getBruttoPrice();
2760 $dPrice -= $oVoucherPrice->getBruttoPrice();
2773 $blIsBelowMinOrderPrice =
false;
2774 $sConfValue = $this->
getConfig()->getConfigParam(
'iMinOrderPrice');
2777 $dNotDiscountedProductPrice = 0;
2779 $dNotDiscountedProductPrice = $oPrice->getBruttoSum();
2784 return $blIsBelowMinOrderPrice;
2799 foreach ($this->_aBasketContents as $sItemKey => $oOrderArticle) {
2800 if ($oOrderArticle && ($sExpiredArtId == null || $sExpiredArtId != $sItemKey)) {
2801 if ($oOrderArticle->getArticle(
true)->getId() == $sArtId) {
2802 $dArtStock += $oOrderArticle->getAmount();
2822 if ($this->_sBasketCategoryId === null) {
2826 if ($oView = $this->
getConfig()->getActiveView()) {
2827 if ($oCat = $oView->getActiveCategory()) {
2838 $oProduct =
oxNew(
"oxArticle");
2839 if ($oProduct->load($sProductId)) {
2840 $oCat = $oProduct->getCategory();
2851 if ($blCanAdd === null) {
2868 $sO2CTable = getViewName(
'oxobject2category');
2869 $sCatTable = getViewName(
'oxcategories');
2872 $sParentId = $oDb->getOne(
"select oxparentid from oxarticles where oxid = " . $oDb->quote($sProductId));
2873 $sProductId = $sParentId ? $sParentId : $sProductId;
2875 $sQ =
"select 1 from {$sO2CTable}
2876 left join {$sCatTable} on {$sCatTable}.oxid = {$sO2CTable}.oxcatnid
2877 where {$sO2CTable}.oxobjectid = " . $oDb->quote($sProductId) .
" and
2878 {$sCatTable}.oxrootid = " . $oDb->quote($sRootCatId);
2880 return (
bool) $oDb->getOne($sQ);
2890 $this->_sBasketCategoryId = $sRoot;
2910 $this->_blShowCatChangeWarning = $blShow;
2930 $this->_sTsProductId = $sProductId;
2952 $oProtectionCost = $this->
getCosts(
'oxtsprotection');
2953 if ($oProtectionCost && $oProtectionCost->getBruttoPrice()) {
2969 return $this->
getCosts(
'oxtsprotection')->getVat();
2981 $dProtectionVAT = $this->
getCosts(
'oxtsprotection')->getVatValue();
2983 if ($dProtectionVAT > 0 && $this->
getConfig()->getConfigParam(
'blShowVATForPayCharge')) {
3000 if ($this->
getConfig()->getConfigParam(
'blShowVATForPayCharge')) {
3016 $oProtection = $this->
getCosts(
'oxtsprotection');
3018 return $oProtection->getBruttoPrice();
3031 return $this->
getCosts(
'oxtsprotection');
3056 protected function _addedNewItem($sProductID, $dAmount, $aSel, $aPersParam, $blOverride, $blBundle, $sOldBasketItemId)
3059 $this->_blNewITemAdded = null;
3069 $this->_blNewITemAdded = null;
3070 $this->_isCalculationModeNetto = null;
3080 if ($this->_blNewITemAdded == null) {
3095 $this->_blDownloadableProducts =
false;
3097 foreach ($this->_aBasketContents as $oBasketItem) {
3098 if ($oBasketItem->getArticle(
false) && $oBasketItem->getArticle(
false)->isDownloadable()) {
3099 $this->_blDownloadableProducts =
true;
3114 $blHasArticlesWithIntangibleAgreement =
false;
3117 foreach ($this->_aBasketContents as $oBasketItem) {
3118 if ($oBasketItem->getArticle(
false) && $oBasketItem->getArticle(
false)->hasIntangibleAgreement()) {
3119 $blHasArticlesWithIntangibleAgreement =
true;
3124 return $blHasArticlesWithIntangibleAgreement;
3134 $blHasArticlesWithIntangibleAgreement =
false;
3137 foreach ($this->_aBasketContents as $oBasketItem) {
3138 if ($oBasketItem->getArticle(
false) && $oBasketItem->getArticle(
false)->hasDownloadableAgreement()) {
3139 $blHasArticlesWithIntangibleAgreement =
true;
3144 return $blHasArticlesWithIntangibleAgreement;
3164 return $this->
getPrice()->getBruttoPrice() - $this->
getCosts(
'oxtsprotection')->getBruttoPrice();