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 return $this->_aBasketContents[$sItemId];
511 if ($oOrderArticle->oxorderarticles__oxamount->value > 0 && !$oOrderArticle->isBundle()) {
513 $this->_isForOrderRecalculation =
true;
514 $sItemId = $oOrderArticle->getId();
517 $this->_aBasketContents[$sItemId] =
oxNew(
'oxbasketitem');
518 $this->_aBasketContents[$sItemId]->initFromOrderArticle($oOrderArticle);
519 $this->_aBasketContents[$sItemId]->setWrapping($oOrderArticle->oxorderarticles__oxwrapid->value);
520 $this->_aBasketContents[$sItemId]->setBundle($oOrderArticle->isBundle());
525 return $this->_aBasketContents[$sItemId];
526 } elseif ($oOrderArticle->isBundle()) {
528 $oOrderArticle->delete();
539 $this->_blCheckStock = $blCheck;
564 public function getItemKey($sProductId, $aSel = null, $aPersParam = null, $blBundle =
false, $sAdditionalParam =
'')
566 $aSel = ($aSel != null) ? $aSel : array(0 =>
'0');
568 $sItemKey = md5($sProductId .
'|' . serialize($aSel) .
'|' . serialize($aPersParam) .
'|' . (
int ) $blBundle .
'|' . serialize($sAdditionalParam));
581 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled')) {
582 if (isset($this->_aBasketContents[$sItemKey])) {
583 $sArticleId = $this->_aBasketContents[$sItemKey]->getProductId();
586 ->getBasketReservations()
587 ->discardArticleReservation($sArticleId);
591 unset($this->_aBasketContents[$sItemKey]);
594 if (!count($this->_aBasketContents) && $this->
getConfig()->getConfigParam(
'blBasketExcludeEnabled')) {
604 reset($this->_aBasketContents);
605 while (list($sItemKey, $oBasketItem) = each($this->_aBasketContents)) {
606 if ($oBasketItem->isBundle()) {
623 if ($oBasketItem->isBundle()) {
627 $oArticle = $oBasketItem->getArticle(
true);
628 if ($oArticle && $oArticle->oxarticles__oxbundleid->value) {
629 $aBundles[$oArticle->oxarticles__oxbundleid->value] = 1;
646 if ($oBasketItem->isBundle()) {
651 if ($oArticle = $oBasketItem->getArticle()) {
654 foreach ($aDiscounts as $oDiscount) {
656 $iAmnt = $oDiscount->getBundleAmount($oBasketItem->getAmount());
659 if (!isset($aBundles[$oDiscount->oxdiscount__oxitmartid->value])) {
660 $aBundles[$oDiscount->oxdiscount__oxitmartid->value] = 0;
663 if ($oDiscount->oxdiscount__oxitmmultiple->value) {
664 $aBundles[$oDiscount->oxdiscount__oxitmartid->value] += $iAmnt;
666 $aBundles[$oDiscount->oxdiscount__oxitmartid->value] = $iAmnt;
688 foreach ($this->_aBasketContents as $oBasketItem) {
689 if (!($oBasketItem->isBundle() || $oBasketItem->isDiscountArticle())) {
690 $dAmount += $oBasketItem->getAmount();
694 foreach ($aDiscounts as $oDiscount) {
695 if ($oDiscount->oxdiscount__oxitmartid->value) {
696 if (!isset($aBundles[$oDiscount->oxdiscount__oxitmartid->value])) {
697 $aBundles[$oDiscount->oxdiscount__oxitmartid->value] = 0;
700 $aBundles[$oDiscount->oxdiscount__oxitmartid->value] += $oDiscount->getBundleAmount($dAmount);
715 foreach ($this->_aBasketContents as $key => $oBasketItem) {
718 if (!$oBasketItem->isDiscountArticle() && !$oBasketItem->isBundle()) {
754 foreach ($aBundles as $sBundleId => $dAmount) {
757 if ($oBundleItem = $this->
addToBasket($sBundleId, $dAmount, null, null,
false,
true)) {
758 $oBundleItem->setAsDiscountArticle(
true);
763 $sItemId = $this->
getItemKey($sBundleId, null, null,
true);
764 $this->_aBasketContents[$sItemId]->setAsDiscountArticle(
true );
779 $this->_iProductsCnt = 0;
780 $this->_dItemsCnt = 0;
783 $this->_oProductsPriceList =
oxNew(
'oxpricelist');
784 $this->_oDiscountProductsPriceList =
oxNew(
'oxpricelist');
785 $this->_oNotDiscountedProductsPriceList =
oxNew(
'oxpricelist');
789 foreach ($this->_aBasketContents as $oBasketItem) {
790 $this->_iProductsCnt++;
791 $this->_dItemsCnt += $oBasketItem->getAmount();
792 $this->_dWeight += $oBasketItem->getWeight();
794 if (!$oBasketItem->isDiscountArticle() && ($oArticle = $oBasketItem->getArticle(
true))) {
796 $oBasketPrice = $oArticle->getBasketPrice($oBasketItem->getAmount(), $oBasketItem->getSelList(), $this);
797 $oBasketItem->setRegularUnitPrice(clone $oBasketPrice);
801 $aDiscounts = $oDiscountList->getBasketItemDiscounts($oArticle, $this, $this->
getBasketUser());
803 foreach ($aDiscounts as $oDiscount) {
804 $oBasketPrice->setDiscount($oDiscount->getAddSum(), $oDiscount->getAddSumType());
806 $oBasketPrice->calculateDiscount();
808 $oBasketItem->setSkipDiscounts(
true);
812 $oBasketItem->setPrice($oBasketPrice);
813 $this->_oProductsPriceList->addToPriceList($oBasketItem->getPrice());
816 if (!$oArticle->skipDiscounts()) {
818 $this->_oDiscountProductsPriceList->addToPriceList($oBasketItem->getPrice());
820 $this->_oNotDiscountedProductsPriceList->addToPriceList($oBasketItem->getPrice());
821 $oBasketItem->setSkipDiscounts(
true);
824 } elseif ($oBasketItem->isBundle()) {
826 $oPrice =
oxNew(
"oxprice");
827 $oBasketItem->setPrice($oPrice);
839 $this->_blCalcDiscounts = $blCalcDiscounts;
863 foreach ($aItemDiscounts as $sKey => $oDiscount) {
865 if (array_key_exists($sKey, $aDiscounts)) {
866 $aDiscounts[$sKey]->dDiscount += $oDiscount->dDiscount;
868 $aDiscounts[$sKey] = $oDiscount;
882 if ($this->_oDeliveryPrice !== null) {
886 $oDeliveryPrice =
oxNew(
'oxprice');
888 if ($this->
getConfig()->getConfigParam(
'blDeliveryVatOnTop')) {
889 $oDeliveryPrice->setNettoPriceMode();
891 $oDeliveryPrice->setBruttoPriceMode();
897 if (!$oUser && !
$myConfig->getConfigParam(
'blCalculateDelCostIfNotLoggedIn')) {
898 return $oDeliveryPrice;
902 $oDeliveryPrice->setVat($fDelVATPercent);
905 if (
$myConfig->getConfigParam(
'bl_perfLoadDelivery')) {
913 if (count($aDeliveryList) > 0) {
914 foreach ($aDeliveryList as $oDelivery) {
916 if (
$myConfig->getConfigParam(
'iDebug') == 5) {
917 echo(
"DelCost : " . $oDelivery->oxdelivery__oxtitle->value .
"<br>");
919 $oDeliveryPrice->addPrice($oDelivery->getDeliveryPrice($fDelVATPercent));
924 return $oDeliveryPrice;
934 if ($this->_oUser == null) {
948 $this->_oUser = $oUser;
959 if ($this->_oProductsPriceList) {
960 return $this->_oProductsPriceList->getMostUsedVatPercent();
971 if ($this->_oProductsPriceList) {
972 if ($this->
getConfig()->getConfigParam(
'sAdditionalServVATCalcMethod') ==
'proportional') {
973 return $this->_oProductsPriceList->getProportionalVatPercent();
975 return $this->_oProductsPriceList->getMostUsedVatPercent();
987 if ($this->
getConfig()->getConfigParam(
'sAdditionalServVATCalcMethod') ==
'proportional') {
1004 $oTotalPrice =
oxNew(
'oxPrice');
1005 $oTotalPrice->setBruttoPriceMode();
1006 $oTotalPrice->setPrice($dPrice);
1012 $oTotalPrice->subtract($this->_oTotalDiscount->getBruttoPrice());
1016 $oTotalPrice->subtract($oVoucherDisc->getBruttoPrice());
1021 if (isset($this->_aCosts[
'oxdelivery'])) {
1022 $oTotalPrice->add($this->_aCosts[
'oxdelivery']->getBruttoPrice());
1026 if (isset($this->_aCosts[
'oxwrapping'])) {
1027 $oTotalPrice->add($this->_aCosts[
'oxwrapping']->getBruttoPrice());
1029 if (isset($this->_aCosts[
'oxgiftcard'])) {
1030 $oTotalPrice->add($this->_aCosts[
'oxgiftcard']->getBruttoPrice());
1034 if (isset($this->_aCosts[
'oxpayment'])) {
1035 $oTotalPrice->add($this->_aCosts[
'oxpayment']->getBruttoPrice());
1039 if (isset($this->_aCosts[
'oxtsprotection'])) {
1040 $oTotalPrice->add($this->_aCosts[
'oxtsprotection']->getBruttoPrice());
1053 $this->_oVoucherDiscount =
oxNew(
'oxPrice');
1054 $this->_oVoucherDiscount->setBruttoPriceMode();
1055 $this->_oVoucherDiscount->add($dDiscount);
1063 if ($this->
getConfig()->getConfigParam(
'bl_showVouchers') && ($this->_oVoucherDiscount === null || ($this->_blUpdateNeeded && !$this->
isAdmin()))) {
1068 $dPrice = $this->_oDiscountProductsPriceList->getSum($this->
isCalculationModeNetto()) - $this->_oTotalDiscount->getPrice();
1071 if (count($this->_aVouchers)) {
1073 foreach ($this->_aVouchers as $sVoucherId => $oStdVoucher) {
1074 $oVoucher =
oxNew(
'oxvoucher');
1076 $oVoucher->load($oStdVoucher->sVoucherId);
1078 if (!$this->_blSkipVouchersAvailabilityChecking) {
1079 $oVoucher->checkBasketVoucherAvailability($this->_aVouchers, $dPrice);
1084 $dVoucherdiscount = $oVoucher->getDiscountValue($dPrice);
1086 if ($dVoucherdiscount > 0) {
1088 if ($oVoucher->getDiscountType() ==
'absolute') {
1089 $dVatPart = ($dPrice - $dVoucherdiscount) / $dPrice * 100;
1091 $dVatPart = 100 - $oVoucher->getDiscount();
1094 if (!$this->_aDiscountedVats) {
1101 foreach ($this->_aDiscountedVats as $sKey => $dVat) {
1107 $this->_oVoucherDiscount->add($dVoucherdiscount);
1110 $oStdVoucher->fVoucherdiscount = $oLang->formatCurrency($dVoucherdiscount, $this->
getBasketCurrency());
1111 $oStdVoucher->dVoucherdiscount = $dVoucherdiscount;
1114 $dPrice = $dPrice - $dVoucherdiscount;
1120 $oVoucher->unMarkAsReserved();
1121 unset($this->_aVouchers[$sVoucherId]);
1141 foreach ($this->_aDiscountedVats as $dVat) {
1142 $dVatSum += $oUtils->fRound($dVat, $this->_oCurrency);
1150 $this->
setBruttoSum($oNotDiscounted->getSum(
false) + $dDiscountedSum + $dVatSum);
1153 $this->
setNettoSum($oNotDiscounted->getSum() + $dDiscountedSum - $dVatSum);
1165 $blResult = (bool) $this->
getConfig()->getConfigParam(
'blShowNetPrice');
1168 $blResult = $oUser->isPriceViewModeNetto();
1181 $oPrice =
oxNew(
'oxPrice');
1184 $oPrice->setNettoPriceMode();
1186 $oPrice->setBruttoPriceMode();
1198 $this->_aDiscounts = array();
1204 if ($this->_oTotalDiscount !== null && isset($this->_isForOrderRecalculation) && $this->_isForOrderRecalculation) {
1207 $oDiscount =
oxNew(
'oxDiscount');
1208 $oDiscount->oxdiscount__oxaddsum =
new oxField($oTotalPrice->getPrice());
1209 $oDiscount->oxdiscount__oxaddsumtype =
new oxField(
'abs');
1210 $aDiscounts[] = $oDiscount;
1220 foreach ($aDiscounts as $oDiscount) {
1223 $oStdDiscount = $oDiscount->getSimpleDiscount();
1226 if ($oDiscount->oxdiscount__oxaddsumtype->value ==
'itm') {
1231 $oStdDiscount->dDiscount = $oDiscount->getAbsValue($dOldPrice);
1233 $dVatPart = 100 - $oDiscount->getPercentage($dOldPrice);
1236 if ($dOldPrice < $oStdDiscount->dDiscount) {
1237 $oStdDiscount->dDiscount = $dOldPrice;
1242 foreach ($this->_aDiscountedVats as $sKey => $dVat) {
1247 if ($oStdDiscount->dDiscount != 0) {
1248 $this->_aDiscounts[$oDiscount->getId()] = $oStdDiscount;
1250 $dOldPrice = $dOldPrice - $oStdDiscount->dDiscount;
1260 if ($this->_oTotalDiscount === null || (!$this->
isAdmin())) {
1264 if (is_array($this->_aDiscounts)) {
1265 foreach ($this->_aDiscounts as $oDiscount) {
1268 if ($oDiscount->sType ==
'itm') {
1273 $this->_oTotalDiscount->add($oDiscount->dDiscount);
1289 $oWrappingPrices =
oxNew(
'oxPriceList');
1291 foreach ($this->_aBasketContents as $oBasketItem) {
1293 if (($oWrapping = $oBasketItem->getWrapping())) {
1295 $oWrappingPrice = $oWrapping->getWrappingPrice($oBasketItem->getAmount());
1296 $oWrappingPrice->setVat($oBasketItem->getPrice()->getVat());
1298 $oWrappingPrices->addToPriceList($oWrappingPrice);
1302 if ($oWrappingPrices->getCount()) {
1303 $oWrappingCost =
oxNew(
'oxPrice');
1304 $oWrappingCost = $oWrappingPrices->calculateToPrice();
1307 return $oWrappingCost;
1320 $oGiftCardPrice =
oxNew(
'oxPrice');
1322 if ($this->
getConfig()->getConfigParam(
'blWrappingVatOnTop')) {
1323 $oGiftCardPrice->setNettoPriceMode();
1325 $oGiftCardPrice->setBruttoPriceMode();
1330 $oGiftCardPrice->setVat($dVATPercent);
1333 if (($oCard = $this->
getCard())) {
1334 if ($dVATPercent !== null) {
1335 $oCard->setWrappingVat($dVATPercent);
1337 $oGiftCardPrice->addPrice($oCard->getWrappingPrice());
1340 return $oGiftCardPrice;
1352 $oPaymentPrice =
oxNew(
'oxPrice');
1357 $oPayment =
oxNew(
'oxPayment');
1358 $oPayment->load($this->_sPaymentId);
1360 $oPayment->calculate($this);
1361 $oPaymentPrice = $oPayment->getPrice();
1364 return $oPaymentPrice;
1376 $oTsProtection =
oxNew(
'oxtsprotection');
1377 $oTsProduct = $oTsProtection->getTsProduct($this->
getTsProductId());
1378 $oProtectionPrice = $oTsProduct->getPrice();
1381 $oProtectionPrice =
oxNew(
'oxPrice');
1384 return $oProtectionPrice;
1393 public function setCost($sCostName, $oPrice = null)
1395 $this->_aCosts[$sCostName] = $oPrice;
1425 if ($blForceUpdate) {
1429 if (!($this->_blUpdateNeeded || $blForceUpdate)) {
1433 $this->_aCosts = array();
1445 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled')) {
1446 $this->
getSession()->getBasketReservations()->reserveBasket($this);
1494 $this->_blUpdateNeeded =
true;
1502 $this->_blUpdateNeeded =
false;
1514 if ($this->_blUpdateNeeded || $this->_aBasketSummary === null) {
1515 $this->_aBasketSummary =
new stdclass();
1516 $this->_aBasketSummary->aArticles = array();
1517 $this->_aBasketSummary->aCategories = array();
1518 $this->_aBasketSummary->iArticleCount = 0;
1519 $this->_aBasketSummary->dArticlePrice = 0;
1520 $this->_aBasketSummary->dArticleDiscountablePrice = 0;
1528 foreach ($this->_aBasketContents as $oBasketItem) {
1529 if (!$oBasketItem->isBundle() && $oArticle = $oBasketItem->getArticle(
false)) {
1530 $aCatIds = $oArticle->getCategoryIds();
1533 $dDiscountablePrice = 0;
1534 if (($oPrice = $oArticle->getBasketPrice($oBasketItem->getAmount(), $oBasketItem->getSelList(), $this))) {
1535 $dPrice = $oPrice->getPrice();
1536 if (!$oArticle->skipDiscounts()) {
1537 $dDiscountablePrice = $dPrice;
1541 foreach ($aCatIds as $sCatId) {
1542 if (!isset($this->_aBasketSummary->aCategories[$sCatId])) {
1543 $this->_aBasketSummary->aCategories[$sCatId] =
new stdClass();
1546 $this->_aBasketSummary->aCategories[$sCatId]->dPrice += $dPrice * $oBasketItem->getAmount();
1547 $this->_aBasketSummary->aCategories[$sCatId]->dDiscountablePrice += $dDiscountablePrice * $oBasketItem->getAmount();
1548 $this->_aBasketSummary->aCategories[$sCatId]->dAmount += $oBasketItem->getAmount();
1549 $this->_aBasketSummary->aCategories[$sCatId]->iCount++;
1553 if (($sParentId = $oArticle->getParentId()) &&
$myConfig->getConfigParam(
'blVariantParentBuyable')) {
1554 if (!isset($this->_aBasketSummary->aArticles[$sParentId])) {
1555 $this->_aBasketSummary->aArticles[$sParentId] = 0;
1557 $this->_aBasketSummary->aArticles[$sParentId] += $oBasketItem->getAmount();
1560 if (!isset($this->_aBasketSummary->aArticles[$oBasketItem->getProductId()])) {
1561 $this->_aBasketSummary->aArticles[$oBasketItem->getProductId()] = 0;
1564 $this->_aBasketSummary->aArticles[$oBasketItem->getProductId()] += $oBasketItem->getAmount();
1565 $this->_aBasketSummary->iArticleCount += $oBasketItem->getAmount();
1566 $this->_aBasketSummary->dArticlePrice += $dPrice * $oBasketItem->getAmount();
1567 $this->_aBasketSummary->dArticleDiscountablePrice += $dDiscountablePrice * $oBasketItem->getAmount();
1588 if ($this->_oDiscountProductsPriceList) {
1594 $oVoucher =
oxNew(
'oxvoucher');
1596 if (!$this->_blSkipVouchersAvailabilityChecking) {
1597 $oVoucher->getVoucherByNr($sVoucherId, $this->_aVouchers,
true);
1598 $oVoucher->checkVoucherAvailability($this->_aVouchers, $dPrice);
1600 $oVoucher->markAsReserved();
1602 $oVoucher->load($sVoucherId);
1606 $this->_aVouchers[$oVoucher->oxvouchers__oxid->value] = $oVoucher->getSimpleVoucher();
1624 if (isset($this->_aVouchers[$sVoucherId])) {
1626 $oVoucher =
oxNew(
'oxVoucher');
1627 $oVoucher->load($sVoucherId);
1629 $oVoucher->unMarkAsReserved();
1632 unset($this->_aVouchers[$sVoucherId]);
1655 if (count($this->aDiscounts) > 0) {
1657 foreach ($this->aDiscounts as $oDiscount) {
1658 $oDiscount->fDiscount = $oLang->formatCurrency($oDiscount->dDiscount, $this->getBasketCurrency());
1687 $oBasket = $oUser->getBasket(
'savedbasket');
1690 $aSavedItems = $oBasket->getItems();
1691 foreach ($aSavedItems as $oItem) {
1693 $oSelList = $oItem->getSelList();
1695 $this->
addToBasket($oItem->oxuserbasketitems__oxartid->value, $oItem->oxuserbasketitems__oxamount->value, $oSelList, $oItem->getPersParams(),
true);
1712 $oSavedBasket = $oUser->getBasket(
'savedbasket');
1713 $oSavedBasket->delete();
1716 foreach ($this->_aBasketContents as $oBasketItem) {
1718 if (!$oBasketItem->isBundle() && !$oBasketItem->isDiscountArticle()) {
1719 $oSavedBasket->addItemToBasket($oBasketItem->getProductId(), $oBasketItem->getAmount(), $oBasketItem->getSelList(),
true, $oBasketItem->getPersParams());
1735 $oUser->getBasket(
'savedbasket')->delete();
1739 if ($this->
getConfig()->getConfigParam(
'blBasketExcludeEnabled')) {
1754 $sDeliveryCountry = null;
1758 $aHomeCountry =
$myConfig->getConfigParam(
'aHomeCountry');
1759 if (
$myConfig->getConfigParam(
'blCalculateDelCostIfNotLoggedIn') && is_array($aHomeCountry)) {
1760 $sDeliveryCountry = current($aHomeCountry);
1765 if ($sCountryId =
$myConfig->getGlobalParameter(
'delcountryid')) {
1766 $sDeliveryCountry = $sCountryId;
1769 $oDeliveryAddress =
oxNew(
'oxAddress');
1770 if ($oDeliveryAddress->load($sAddressId)) {
1771 $sDeliveryCountry = $oDeliveryAddress->oxaddress__oxcountryid->value;
1776 if (!$sDeliveryCountry) {
1777 $sDeliveryCountry = $oUser->oxuser__oxcountryid->value;
1781 return $sDeliveryCountry;
1789 $this->_aBasketContents = array();
1792 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled')) {
1793 $this->
getSession()->getBasketReservations()->discardReservations();
1807 $this->_sPaymentId = $sPaymentId;
1817 if (!$this->_sPaymentId) {
1831 $this->_sShippingSetId = $sShippingSetId;
1842 $this->_oDeliveryPrice = $oShippingPrice;
1852 if (!$this->_sShippingSetId) {
1858 if (!$this->_sShippingSetId && $sActPaymentId !=
'oxempty') {
1862 list(, $sActShipSet) =
oxRegistry::get(
"oxDeliverySetList")->getDeliverySetData(null, $oUser, $this);
1864 $this->_sShippingSetId = $sActShipSet ? $sActShipSet : ($oUser ? null :
'oxidstandard');
1865 } elseif (!$this->
isAdmin() && $sActPaymentId ==
'oxempty') {
1867 $this->_sShippingSetId = null;
1880 $aBasketArticles = array();
1882 foreach ($this->_aBasketContents as $sItemKey => $oBasketItem) {
1884 $oProduct = $oBasketItem->getArticle(
true);
1886 if ($this->
getConfig()->getConfigParam(
'bl_perfLoadSelectLists')) {
1888 $aSelList = $oBasketItem->getSelList();
1889 if (is_array($aSelList) && ($aSelectlist = $oProduct->getSelectLists($sItemKey))) {
1891 while (list($conkey, $iSel) = each($aSelList)) {
1892 $aSelectlist[$conkey][$iSel] = $aSelectlist[$conkey][$iSel];
1893 $aSelectlist[$conkey][$iSel]->selected = 1;
1895 $oProduct->setSelectlist($aSelectlist);
1910 $aBasketArticles[$sItemKey] = $oProduct;
1913 return $aBasketArticles;
1933 if (is_null($this->_oProductsPriceList)) {
1934 $this->_oProductsPriceList =
oxNew(
'oxPriceList');
1947 if (is_null($this->_oPrice)) {
1961 $this->_oPrice = $oPrice;
1983 $this->_sOrderId = $sId;
1998 return isset($this->_aCosts[$sId]) ? $this->_aCosts[$sId] : null;
2063 if (!$this->_oNotDiscountedProductsPriceList) {
2070 foreach ($this->_aDiscountedVats as $sKey => $dVat) {
2071 if (!isset($aVats[$sKey])) {
2075 $aVats[$sKey] += $oUtils->fRound($dVat, $this->_oCurrency);
2078 if ($blFormatCurrency) {
2080 foreach ($aVats as $sKey => $dVat) {
2095 $this->_sCardMessage = $sMessage;
2105 return $this->_sCardMessage;
2115 $this->_sCardId = $sCardId;
2125 return $this->_sCardId;
2137 $oCard =
oxNew(
'oxWrapping');
2138 $oCard->load($sCardId);
2166 return array_merge($this->_aItemDiscounts, $this->_aDiscounts);
2176 if ($this->
getConfig()->getConfigParam(
'bl_showVouchers')) {
2190 $this->_oCurrency = $oCurrency;
2200 if ($this->_oCurrency === null) {
2201 $this->_oCurrency = $this->
getConfig()->getActShopCurrencyObject();
2214 $this->_blSkipVouchersAvailabilityChecking = $blSkipChecking;
2234 $this->_blSkipDiscounts = $blSkip;
2270 return $this->
getCosts(
'oxdelivery')->getVat();
2282 $dDelVAT = $this->
getCosts(
'oxdelivery')->getVatValue();
2285 if ($dDelVAT > 0 && $this->
getConfig()->getConfigParam(
'blShowVATForDelivery')) {
2304 if ($oConfig->getConfigParam(
'blShowVATForDelivery') && ($this->
getBasketUser() || $oConfig->getConfigParam(
'blCalculateDelCostIfNotLoggedIn'))) {
2305 $dNetPrice = $this->
getCosts(
'oxdelivery')->getNettoPrice();
2306 if ($dNetPrice > 0) {
2323 return $this->
getCosts(
'oxpayment')->getVat();
2335 $dPayVAT = $this->
getCosts(
'oxpayment')->getVatValue();
2338 if ($dPayVAT > 0 && $this->
getConfig()->getConfigParam(
'blShowVATForPayCharge')) {
2355 if ($this->
getConfig()->getConfigParam(
'blShowVATForPayCharge')) {
2356 $oPaymentCost = $this->
getCosts(
'oxpayment');
2357 if ($oPaymentCost && $oPaymentCost->getNettoPrice()) {
2374 $oPaymentCost = $this->
getCosts(
'oxpayment');
2375 if ($oPaymentCost && $oPaymentCost->getBruttoPrice()) {
2376 return $oPaymentCost->getBruttoPrice();
2387 return $this->
getCosts(
'oxpayment');
2399 $oPaymentCost = $this->
getCosts(
'oxpayment');
2400 if ($oPaymentCost && $oPaymentCost->getBruttoPrice()) {
2431 if ($oVoucherDiscount->getBruttoPrice()) {
2449 return $this->
getCosts(
'oxwrapping')->getVat();
2462 return $this->
getCosts(
'oxgiftcard')->getVat();
2475 if ($this->
getConfig()->getConfigParam(
'blShowVATForWrapping')) {
2476 $oPrice = $this->
getCosts(
'oxwrapping');
2478 if ($oPrice && $oPrice->getVatValue() > 0) {
2496 if ($this->
getConfig()->getConfigParam(
'blShowVATForWrapping')) {
2497 $oPrice = $this->
getCosts(
'oxwrapping');
2499 if ($oPrice && $oPrice->getNettoPrice() > 0) {
2516 $oPrice = $this->
getCosts(
'oxwrapping');
2518 if ($oPrice && $oPrice->getBruttoPrice()) {
2532 return $this->
getCosts(
'oxwrapping');
2545 if ($this->
getConfig()->getConfigParam(
'blShowVATForWrapping')) {
2546 $oPrice = $this->
getCosts(
'oxgiftcard');
2548 if ($oPrice && $oPrice->getVatValue() > 0) {
2567 if ($this->
getConfig()->getConfigParam(
'blShowVATForWrapping')) {
2568 $oPrice = $this->
getCosts(
'oxgiftcard');
2570 if ($oPrice && $oPrice->getNettoPrice() > 0) {
2587 $oPrice = $this->
getCosts(
'oxgiftcard');
2589 if ($oPrice && $oPrice->getBruttoPrice()) {
2603 return $this->
getCosts(
'oxgiftcard');
2627 $oPrice = $this->
getCosts(
'oxdelivery');
2629 if ($oPrice && ($this->
getBasketUser() || $this->
getConfig()->getConfigParam(
'blCalculateDelCostIfNotLoggedIn'))) {
2645 if ($oDeliveryCost = $this->
getCosts(
'oxdelivery')) {
2646 return $oDeliveryCost->getBruttoPrice();
2659 return $this->
getCosts(
'oxdelivery');
2669 $this->_oTotalDiscount =
oxNew(
'oxPrice');
2670 $this->_oTotalDiscount->setBruttoPriceMode();
2671 $this->_oTotalDiscount->add($dDiscount);
2685 $dPrice += $oPriceList->getBruttoSum();
2689 if ($oDeliveryPrice = $this->_aCosts[
'oxdelivery']) {
2690 $dPrice += $oDeliveryPrice->getBruttoPrice();
2710 $dPrice -= $oPrice->getPrice();
2714 $dPrice -= $oVoucherPrice->getPrice();
2730 $dPrice += $oPrice->getPrice();
2734 $dPrice += $oVoucherPrice->getPrice();
2748 $dPrice = $oProductsPrice->getBruttoSum();
2753 $dPrice -= $oPrice->getBruttoPrice();
2757 $dPrice -= $oVoucherPrice->getBruttoPrice();
2770 $blIsBelowMinOrderPrice =
false;
2771 $sConfValue = $this->
getConfig()->getConfigParam(
'iMinOrderPrice');
2774 $dNotDiscountedProductPrice = 0;
2776 $dNotDiscountedProductPrice = $oPrice->getBruttoSum();
2781 return $blIsBelowMinOrderPrice;
2796 foreach ($this->_aBasketContents as $sItemKey => $oOrderArticle) {
2797 if ($oOrderArticle && ($sExpiredArtId == null || $sExpiredArtId != $sItemKey)) {
2798 if ($oOrderArticle->getArticle(
true)->getId() == $sArtId) {
2799 $dArtStock += $oOrderArticle->getAmount();
2819 if ($this->_sBasketCategoryId === null) {
2823 if ($oView = $this->
getConfig()->getActiveView()) {
2824 if ($oCat = $oView->getActiveCategory()) {
2835 $oProduct =
oxNew(
"oxArticle");
2836 if ($oProduct->load($sProductId)) {
2837 $oCat = $oProduct->getCategory();
2848 if ($blCanAdd === null) {
2865 $sO2CTable = getViewName(
'oxobject2category');
2866 $sCatTable = getViewName(
'oxcategories');
2869 $sParentId = $oDb->getOne(
"select oxparentid from oxarticles where oxid = " . $oDb->quote($sProductId));
2870 $sProductId = $sParentId ? $sParentId : $sProductId;
2872 $sQ =
"select 1 from {$sO2CTable}
2873 left join {$sCatTable} on {$sCatTable}.oxid = {$sO2CTable}.oxcatnid
2874 where {$sO2CTable}.oxobjectid = " . $oDb->quote($sProductId) .
" and
2875 {$sCatTable}.oxrootid = " . $oDb->quote($sRootCatId);
2877 return (
bool) $oDb->getOne($sQ);
2887 $this->_sBasketCategoryId = $sRoot;
2907 $this->_blShowCatChangeWarning = $blShow;
2927 $this->_sTsProductId = $sProductId;
2949 $oProtectionCost = $this->
getCosts(
'oxtsprotection');
2950 if ($oProtectionCost && $oProtectionCost->getBruttoPrice()) {
2966 return $this->
getCosts(
'oxtsprotection')->getVat();
2978 $dProtectionVAT = $this->
getCosts(
'oxtsprotection')->getVatValue();
2980 if ($dProtectionVAT > 0 && $this->
getConfig()->getConfigParam(
'blShowVATForPayCharge')) {
2997 if ($this->
getConfig()->getConfigParam(
'blShowVATForPayCharge')) {
3013 $oProtection = $this->
getCosts(
'oxtsprotection');
3015 return $oProtection->getBruttoPrice();
3028 return $this->
getCosts(
'oxtsprotection');
3053 protected function _addedNewItem($sProductID, $dAmount, $aSel, $aPersParam, $blOverride, $blBundle, $sOldBasketItemId)
3056 $this->_blNewITemAdded = null;
3066 $this->_blNewITemAdded = null;
3067 $this->_isCalculationModeNetto = null;
3077 if ($this->_blNewITemAdded == null) {
3090 public function hasDownloadableProducts()
3092 $this->_blDownloadableProducts =
false;
3094 foreach ($this->_aBasketContents as $oBasketItem) {
3095 if ($oBasketItem->getArticle(
false) && $oBasketItem->getArticle(
false)->isDownloadable()) {
3096 $this->_blDownloadableProducts =
true;
3109 public function hasArticlesWithIntangibleAgreement()
3111 $blHasArticlesWithIntangibleAgreement =
false;
3114 foreach ($this->_aBasketContents as $oBasketItem) {
3115 if ($oBasketItem->getArticle(
false) && $oBasketItem->getArticle(
false)->hasIntangibleAgreement()) {
3116 $blHasArticlesWithIntangibleAgreement =
true;
3121 return $blHasArticlesWithIntangibleAgreement;
3129 public function hasArticlesWithDownloadableAgreement()
3131 $blHasArticlesWithIntangibleAgreement =
false;
3134 foreach ($this->_aBasketContents as $oBasketItem) {
3135 if ($oBasketItem->getArticle(
false) && $oBasketItem->getArticle(
false)->hasDownloadableAgreement()) {
3136 $blHasArticlesWithIntangibleAgreement =
true;
3141 return $blHasArticlesWithIntangibleAgreement;
3161 return $this->
getPrice()->getBruttoPrice() - $this->
getCosts(
'oxtsprotection')->getBruttoPrice();