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 $dVatPart = ($dPrice - $dVoucherdiscount) / $dPrice * 100;
1093 if (!$this->_aDiscountedVats) {
1100 foreach ($this->_aDiscountedVats as $sKey => $dVat) {
1106 $this->_oVoucherDiscount->add($dVoucherdiscount);
1109 $oStdVoucher->fVoucherdiscount = $oLang->formatCurrency($dVoucherdiscount, $this->
getBasketCurrency());
1110 $oStdVoucher->dVoucherdiscount = $dVoucherdiscount;
1113 $dPrice = $dPrice - $dVoucherdiscount;
1119 $oVoucher->unMarkAsReserved();
1120 unset($this->_aVouchers[$sVoucherId]);
1140 foreach ($this->_aDiscountedVats as $dVat) {
1141 $dVatSum += $oUtils->fRound($dVat, $this->_oCurrency);
1149 $this->
setBruttoSum($oNotDiscounted->getSum(
false) + $dDiscountedSum + $dVatSum);
1152 $this->
setNettoSum($oNotDiscounted->getSum() + $dDiscountedSum - $dVatSum);
1164 $blResult = (bool) $this->
getConfig()->getConfigParam(
'blShowNetPrice');
1167 $blResult = $oUser->isPriceViewModeNetto();
1180 $oPrice =
oxNew(
'oxPrice');
1183 $oPrice->setNettoPriceMode();
1185 $oPrice->setBruttoPriceMode();
1197 $this->_aDiscounts = array();
1203 if ($this->_oTotalDiscount !== null && isset($this->_isForOrderRecalculation) && $this->_isForOrderRecalculation) {
1206 $oDiscount =
oxNew(
'oxDiscount');
1207 $oDiscount->oxdiscount__oxaddsum =
new oxField($oTotalPrice->getPrice());
1208 $oDiscount->oxdiscount__oxaddsumtype =
new oxField(
'abs');
1209 $aDiscounts[] = $oDiscount;
1219 foreach ($aDiscounts as $oDiscount) {
1222 $oStdDiscount = $oDiscount->getSimpleDiscount();
1225 if ($oDiscount->oxdiscount__oxaddsumtype->value ==
'itm') {
1230 $oStdDiscount->dDiscount = $oDiscount->getAbsValue($dOldPrice);
1232 $dVatPart = 100 - $oDiscount->getPercentage($dOldPrice);
1235 if ($dOldPrice < $oStdDiscount->dDiscount) {
1236 $oStdDiscount->dDiscount = $dOldPrice;
1241 foreach ($this->_aDiscountedVats as $sKey => $dVat) {
1246 if ($oStdDiscount->dDiscount != 0) {
1247 $this->_aDiscounts[$oDiscount->getId()] = $oStdDiscount;
1249 $dOldPrice = $dOldPrice - $oStdDiscount->dDiscount;
1259 if ($this->_oTotalDiscount === null || (!$this->
isAdmin())) {
1263 if (is_array($this->_aDiscounts)) {
1264 foreach ($this->_aDiscounts as $oDiscount) {
1267 if ($oDiscount->sType ==
'itm') {
1272 $this->_oTotalDiscount->add($oDiscount->dDiscount);
1288 $oWrappingPrices =
oxNew(
'oxPriceList');
1290 foreach ($this->_aBasketContents as $oBasketItem) {
1292 if (($oWrapping = $oBasketItem->getWrapping())) {
1294 $oWrappingPrice = $oWrapping->getWrappingPrice($oBasketItem->getAmount());
1295 $oWrappingPrice->setVat($oBasketItem->getPrice()->getVat());
1297 $oWrappingPrices->addToPriceList($oWrappingPrice);
1301 if ($oWrappingPrices->getCount()) {
1302 $oWrappingCost =
oxNew(
'oxPrice');
1303 $oWrappingCost = $oWrappingPrices->calculateToPrice();
1306 return $oWrappingCost;
1319 $oGiftCardPrice =
oxNew(
'oxPrice');
1321 if ($this->
getConfig()->getConfigParam(
'blWrappingVatOnTop')) {
1322 $oGiftCardPrice->setNettoPriceMode();
1324 $oGiftCardPrice->setBruttoPriceMode();
1329 $oGiftCardPrice->setVat($dVATPercent);
1332 if (($oCard = $this->
getCard())) {
1333 if ($dVATPercent !== null) {
1334 $oCard->setWrappingVat($dVATPercent);
1336 $oGiftCardPrice->addPrice($oCard->getWrappingPrice());
1339 return $oGiftCardPrice;
1351 $oPaymentPrice =
oxNew(
'oxPrice');
1356 $oPayment =
oxNew(
'oxPayment');
1357 $oPayment->load($this->_sPaymentId);
1359 $oPayment->calculate($this);
1360 $oPaymentPrice = $oPayment->getPrice();
1363 return $oPaymentPrice;
1375 $oTsProtection =
oxNew(
'oxtsprotection');
1376 $oTsProduct = $oTsProtection->getTsProduct($this->
getTsProductId());
1377 $oProtectionPrice = $oTsProduct->getPrice();
1380 $oProtectionPrice =
oxNew(
'oxPrice');
1383 return $oProtectionPrice;
1392 public function setCost($sCostName, $oPrice = null)
1394 $this->_aCosts[$sCostName] = $oPrice;
1424 if ($blForceUpdate) {
1428 if (!($this->_blUpdateNeeded || $blForceUpdate)) {
1432 $this->_aCosts = array();
1444 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled')) {
1445 $this->
getSession()->getBasketReservations()->reserveBasket($this);
1493 $this->_blUpdateNeeded =
true;
1501 $this->_blUpdateNeeded =
false;
1513 if ($this->_blUpdateNeeded || $this->_aBasketSummary === null) {
1514 $this->_aBasketSummary =
new stdclass();
1515 $this->_aBasketSummary->aArticles = array();
1516 $this->_aBasketSummary->aCategories = array();
1517 $this->_aBasketSummary->iArticleCount = 0;
1518 $this->_aBasketSummary->dArticlePrice = 0;
1519 $this->_aBasketSummary->dArticleDiscountablePrice = 0;
1527 foreach ($this->_aBasketContents as $oBasketItem) {
1528 if (!$oBasketItem->isBundle() && $oArticle = $oBasketItem->getArticle(
false)) {
1529 $aCatIds = $oArticle->getCategoryIds();
1532 $dDiscountablePrice = 0;
1533 if (($oPrice = $oArticle->getBasketPrice($oBasketItem->getAmount(), $oBasketItem->getSelList(), $this))) {
1534 $dPrice = $oPrice->getPrice();
1535 if (!$oArticle->skipDiscounts()) {
1536 $dDiscountablePrice = $dPrice;
1540 foreach ($aCatIds as $sCatId) {
1541 if (!isset($this->_aBasketSummary->aCategories[$sCatId])) {
1542 $this->_aBasketSummary->aCategories[$sCatId] =
new stdClass();
1545 $this->_aBasketSummary->aCategories[$sCatId]->dPrice += $dPrice * $oBasketItem->getAmount();
1546 $this->_aBasketSummary->aCategories[$sCatId]->dDiscountablePrice += $dDiscountablePrice * $oBasketItem->getAmount();
1547 $this->_aBasketSummary->aCategories[$sCatId]->dAmount += $oBasketItem->getAmount();
1548 $this->_aBasketSummary->aCategories[$sCatId]->iCount++;
1552 if (($sParentId = $oArticle->getParentId()) &&
$myConfig->getConfigParam(
'blVariantParentBuyable')) {
1553 if (!isset($this->_aBasketSummary->aArticles[$sParentId])) {
1554 $this->_aBasketSummary->aArticles[$sParentId] = 0;
1556 $this->_aBasketSummary->aArticles[$sParentId] += $oBasketItem->getAmount();
1559 if (!isset($this->_aBasketSummary->aArticles[$oBasketItem->getProductId()])) {
1560 $this->_aBasketSummary->aArticles[$oBasketItem->getProductId()] = 0;
1563 $this->_aBasketSummary->aArticles[$oBasketItem->getProductId()] += $oBasketItem->getAmount();
1564 $this->_aBasketSummary->iArticleCount += $oBasketItem->getAmount();
1565 $this->_aBasketSummary->dArticlePrice += $dPrice * $oBasketItem->getAmount();
1566 $this->_aBasketSummary->dArticleDiscountablePrice += $dDiscountablePrice * $oBasketItem->getAmount();
1587 if ($this->_oDiscountProductsPriceList) {
1593 $oVoucher =
oxNew(
'oxvoucher');
1595 if (!$this->_blSkipVouchersAvailabilityChecking) {
1596 $oVoucher->getVoucherByNr($sVoucherId, $this->_aVouchers,
true);
1597 $oVoucher->checkVoucherAvailability($this->_aVouchers, $dPrice);
1599 $oVoucher->markAsReserved();
1601 $oVoucher->load($sVoucherId);
1605 $this->_aVouchers[$oVoucher->oxvouchers__oxid->value] = $oVoucher->getSimpleVoucher();
1623 if (isset($this->_aVouchers[$sVoucherId])) {
1625 $oVoucher =
oxNew(
'oxVoucher');
1626 $oVoucher->load($sVoucherId);
1628 $oVoucher->unMarkAsReserved();
1631 unset($this->_aVouchers[$sVoucherId]);
1654 if (count($this->aDiscounts) > 0) {
1656 foreach ($this->aDiscounts as $oDiscount) {
1657 $oDiscount->fDiscount = $oLang->formatCurrency($oDiscount->dDiscount, $this->getBasketCurrency());
1686 $oBasket = $oUser->getBasket(
'savedbasket');
1689 $aSavedItems = $oBasket->getItems();
1690 foreach ($aSavedItems as $oItem) {
1692 $oSelList = $oItem->getSelList();
1694 $this->
addToBasket($oItem->oxuserbasketitems__oxartid->value, $oItem->oxuserbasketitems__oxamount->value, $oSelList, $oItem->getPersParams(),
true);
1711 $oSavedBasket = $oUser->getBasket(
'savedbasket');
1712 $oSavedBasket->delete();
1715 foreach ($this->_aBasketContents as $oBasketItem) {
1717 if (!$oBasketItem->isBundle() && !$oBasketItem->isDiscountArticle()) {
1718 $oSavedBasket->addItemToBasket($oBasketItem->getProductId(), $oBasketItem->getAmount(), $oBasketItem->getSelList(),
true, $oBasketItem->getPersParams());
1734 $oUser->getBasket(
'savedbasket')->delete();
1738 if ($this->
getConfig()->getConfigParam(
'blBasketExcludeEnabled')) {
1753 $sDeliveryCountry = null;
1757 $aHomeCountry =
$myConfig->getConfigParam(
'aHomeCountry');
1758 if (
$myConfig->getConfigParam(
'blCalculateDelCostIfNotLoggedIn') && is_array($aHomeCountry)) {
1759 $sDeliveryCountry = current($aHomeCountry);
1764 if ($sCountryId =
$myConfig->getGlobalParameter(
'delcountryid')) {
1765 $sDeliveryCountry = $sCountryId;
1768 $oDeliveryAddress =
oxNew(
'oxAddress');
1769 if ($oDeliveryAddress->load($sAddressId)) {
1770 $sDeliveryCountry = $oDeliveryAddress->oxaddress__oxcountryid->value;
1775 if (!$sDeliveryCountry) {
1776 $sDeliveryCountry = $oUser->oxuser__oxcountryid->value;
1780 return $sDeliveryCountry;
1788 $this->_aBasketContents = array();
1791 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled')) {
1792 $this->
getSession()->getBasketReservations()->discardReservations();
1806 $this->_sPaymentId = $sPaymentId;
1816 if (!$this->_sPaymentId) {
1830 $this->_sShippingSetId = $sShippingSetId;
1841 $this->_oDeliveryPrice = $oShippingPrice;
1851 if (!$this->_sShippingSetId) {
1857 if (!$this->_sShippingSetId && $sActPaymentId !=
'oxempty') {
1861 list(, $sActShipSet) =
oxRegistry::get(
"oxDeliverySetList")->getDeliverySetData(null, $oUser, $this);
1863 $this->_sShippingSetId = $sActShipSet ? $sActShipSet : ($oUser ? null :
'oxidstandard');
1864 } elseif (!$this->
isAdmin() && $sActPaymentId ==
'oxempty') {
1866 $this->_sShippingSetId = null;
1879 $aBasketArticles = array();
1881 foreach ($this->_aBasketContents as $sItemKey => $oBasketItem) {
1883 $oProduct = $oBasketItem->getArticle(
true);
1885 if ($this->
getConfig()->getConfigParam(
'bl_perfLoadSelectLists')) {
1887 $aSelList = $oBasketItem->getSelList();
1888 if (is_array($aSelList) && ($aSelectlist = $oProduct->getSelectLists($sItemKey))) {
1890 while (list($conkey, $iSel) = each($aSelList)) {
1891 $aSelectlist[$conkey][$iSel] = $aSelectlist[$conkey][$iSel];
1892 $aSelectlist[$conkey][$iSel]->selected = 1;
1894 $oProduct->setSelectlist($aSelectlist);
1909 $aBasketArticles[$sItemKey] = $oProduct;
1912 return $aBasketArticles;
1932 if (is_null($this->_oProductsPriceList)) {
1933 $this->_oProductsPriceList =
oxNew(
'oxPriceList');
1946 if (is_null($this->_oPrice)) {
1960 $this->_oPrice = $oPrice;
1982 $this->_sOrderId = $sId;
1997 return isset($this->_aCosts[$sId]) ? $this->_aCosts[$sId] : null;
2062 if (!$this->_oNotDiscountedProductsPriceList) {
2069 foreach ($this->_aDiscountedVats as $sKey => $dVat) {
2070 if (!isset($aVats[$sKey])) {
2074 $aVats[$sKey] += $oUtils->fRound($dVat, $this->_oCurrency);
2077 if ($blFormatCurrency) {
2079 foreach ($aVats as $sKey => $dVat) {
2094 $this->_sCardMessage = $sMessage;
2104 return $this->_sCardMessage;
2114 $this->_sCardId = $sCardId;
2124 return $this->_sCardId;
2136 $oCard =
oxNew(
'oxWrapping');
2137 $oCard->load($sCardId);
2165 return array_merge($this->_aItemDiscounts, $this->_aDiscounts);
2175 if ($this->
getConfig()->getConfigParam(
'bl_showVouchers')) {
2189 $this->_oCurrency = $oCurrency;
2199 if ($this->_oCurrency === null) {
2200 $this->_oCurrency = $this->
getConfig()->getActShopCurrencyObject();
2213 $this->_blSkipVouchersAvailabilityChecking = $blSkipChecking;
2233 $this->_blSkipDiscounts = $blSkip;
2269 return $this->
getCosts(
'oxdelivery')->getVat();
2281 $dDelVAT = $this->
getCosts(
'oxdelivery')->getVatValue();
2284 if ($dDelVAT > 0 && $this->
getConfig()->getConfigParam(
'blShowVATForDelivery')) {
2303 if ($oConfig->getConfigParam(
'blShowVATForDelivery') && ($this->
getBasketUser() || $oConfig->getConfigParam(
'blCalculateDelCostIfNotLoggedIn'))) {
2304 $dNetPrice = $this->
getCosts(
'oxdelivery')->getNettoPrice();
2305 if ($dNetPrice > 0) {
2322 return $this->
getCosts(
'oxpayment')->getVat();
2334 $dPayVAT = $this->
getCosts(
'oxpayment')->getVatValue();
2337 if ($dPayVAT > 0 && $this->
getConfig()->getConfigParam(
'blShowVATForPayCharge')) {
2354 if ($this->
getConfig()->getConfigParam(
'blShowVATForPayCharge')) {
2355 $oPaymentCost = $this->
getCosts(
'oxpayment');
2356 if ($oPaymentCost && $oPaymentCost->getNettoPrice()) {
2373 $oPaymentCost = $this->
getCosts(
'oxpayment');
2374 if ($oPaymentCost && $oPaymentCost->getBruttoPrice()) {
2375 return $oPaymentCost->getBruttoPrice();
2386 return $this->
getCosts(
'oxpayment');
2398 $oPaymentCost = $this->
getCosts(
'oxpayment');
2399 if ($oPaymentCost && $oPaymentCost->getBruttoPrice()) {
2430 if ($oVoucherDiscount->getBruttoPrice()) {
2448 return $this->
getCosts(
'oxwrapping')->getVat();
2461 return $this->
getCosts(
'oxgiftcard')->getVat();
2474 if ($this->
getConfig()->getConfigParam(
'blShowVATForWrapping')) {
2475 $oPrice = $this->
getCosts(
'oxwrapping');
2477 if ($oPrice && $oPrice->getVatValue() > 0) {
2495 if ($this->
getConfig()->getConfigParam(
'blShowVATForWrapping')) {
2496 $oPrice = $this->
getCosts(
'oxwrapping');
2498 if ($oPrice && $oPrice->getNettoPrice() > 0) {
2515 $oPrice = $this->
getCosts(
'oxwrapping');
2517 if ($oPrice && $oPrice->getBruttoPrice()) {
2531 return $this->
getCosts(
'oxwrapping');
2544 if ($this->
getConfig()->getConfigParam(
'blShowVATForWrapping')) {
2545 $oPrice = $this->
getCosts(
'oxgiftcard');
2547 if ($oPrice && $oPrice->getVatValue() > 0) {
2566 if ($this->
getConfig()->getConfigParam(
'blShowVATForWrapping')) {
2567 $oPrice = $this->
getCosts(
'oxgiftcard');
2569 if ($oPrice && $oPrice->getNettoPrice() > 0) {
2586 $oPrice = $this->
getCosts(
'oxgiftcard');
2588 if ($oPrice && $oPrice->getBruttoPrice()) {
2602 return $this->
getCosts(
'oxgiftcard');
2626 $oPrice = $this->
getCosts(
'oxdelivery');
2628 if ($oPrice && ($this->
getBasketUser() || $this->
getConfig()->getConfigParam(
'blCalculateDelCostIfNotLoggedIn'))) {
2644 if ($oDeliveryCost = $this->
getCosts(
'oxdelivery')) {
2645 return $oDeliveryCost->getBruttoPrice();
2658 return $this->
getCosts(
'oxdelivery');
2668 $this->_oTotalDiscount =
oxNew(
'oxPrice');
2669 $this->_oTotalDiscount->setBruttoPriceMode();
2670 $this->_oTotalDiscount->add($dDiscount);
2684 $dPrice += $oPriceList->getBruttoSum();
2688 if ($oDeliveryPrice = $this->_aCosts[
'oxdelivery']) {
2689 $dPrice += $oDeliveryPrice->getBruttoPrice();
2709 $dPrice -= $oPrice->getPrice();
2713 $dPrice -= $oVoucherPrice->getPrice();
2729 $dPrice += $oPrice->getPrice();
2733 $dPrice += $oVoucherPrice->getPrice();
2747 $dPrice = $oProductsPrice->getBruttoSum();
2752 $dPrice -= $oPrice->getBruttoPrice();
2756 $dPrice -= $oVoucherPrice->getBruttoPrice();
2769 $blIsBelowMinOrderPrice =
false;
2770 $sConfValue = $this->
getConfig()->getConfigParam(
'iMinOrderPrice');
2773 $dNotDiscountedProductPrice = 0;
2775 $dNotDiscountedProductPrice = $oPrice->getBruttoSum();
2780 return $blIsBelowMinOrderPrice;
2795 foreach ($this->_aBasketContents as $sItemKey => $oOrderArticle) {
2796 if ($oOrderArticle && ($sExpiredArtId == null || $sExpiredArtId != $sItemKey)) {
2797 if ($oOrderArticle->getArticle(
true)->getId() == $sArtId) {
2798 $dArtStock += $oOrderArticle->getAmount();
2818 if ($this->_sBasketCategoryId === null) {
2822 if ($oView = $this->
getConfig()->getActiveView()) {
2823 if ($oCat = $oView->getActiveCategory()) {
2834 $oProduct =
oxNew(
"oxArticle");
2835 if ($oProduct->load($sProductId)) {
2836 $oCat = $oProduct->getCategory();
2847 if ($blCanAdd === null) {
2864 $sO2CTable = getViewName(
'oxobject2category');
2865 $sCatTable = getViewName(
'oxcategories');
2868 $sParentId = $oDb->getOne(
"select oxparentid from oxarticles where oxid = " . $oDb->quote($sProductId));
2869 $sProductId = $sParentId ? $sParentId : $sProductId;
2871 $sQ =
"select 1 from {$sO2CTable}
2872 left join {$sCatTable} on {$sCatTable}.oxid = {$sO2CTable}.oxcatnid
2873 where {$sO2CTable}.oxobjectid = " . $oDb->quote($sProductId) .
" and
2874 {$sCatTable}.oxrootid = " . $oDb->quote($sRootCatId);
2876 return (
bool) $oDb->getOne($sQ);
2886 $this->_sBasketCategoryId = $sRoot;
2906 $this->_blShowCatChangeWarning = $blShow;
2926 $this->_sTsProductId = $sProductId;
2948 $oProtectionCost = $this->
getCosts(
'oxtsprotection');
2949 if ($oProtectionCost && $oProtectionCost->getBruttoPrice()) {
2965 return $this->
getCosts(
'oxtsprotection')->getVat();
2977 $dProtectionVAT = $this->
getCosts(
'oxtsprotection')->getVatValue();
2979 if ($dProtectionVAT > 0 && $this->
getConfig()->getConfigParam(
'blShowVATForPayCharge')) {
2996 if ($this->
getConfig()->getConfigParam(
'blShowVATForPayCharge')) {
3012 $oProtection = $this->
getCosts(
'oxtsprotection');
3014 return $oProtection->getBruttoPrice();
3027 return $this->
getCosts(
'oxtsprotection');
3052 protected function _addedNewItem($sProductID, $dAmount, $aSel, $aPersParam, $blOverride, $blBundle, $sOldBasketItemId)
3055 $this->_blNewITemAdded = null;
3065 $this->_blNewITemAdded = null;
3066 $this->_isCalculationModeNetto = null;
3076 if ($this->_blNewITemAdded == null) {
3091 $this->_blDownloadableProducts =
false;
3093 foreach ($this->_aBasketContents as $oBasketItem) {
3094 if ($oBasketItem->getArticle(
false) && $oBasketItem->getArticle(
false)->isDownloadable()) {
3095 $this->_blDownloadableProducts =
true;
3110 $blHasArticlesWithIntangibleAgreement =
false;
3113 foreach ($this->_aBasketContents as $oBasketItem) {
3114 if ($oBasketItem->getArticle(
false) && $oBasketItem->getArticle(
false)->hasIntangibleAgreement()) {
3115 $blHasArticlesWithIntangibleAgreement =
true;
3120 return $blHasArticlesWithIntangibleAgreement;
3130 $blHasArticlesWithIntangibleAgreement =
false;
3133 foreach ($this->_aBasketContents as $oBasketItem) {
3134 if ($oBasketItem->getArticle(
false) && $oBasketItem->getArticle(
false)->hasDownloadableAgreement()) {
3135 $blHasArticlesWithIntangibleAgreement =
true;
3140 return $blHasArticlesWithIntangibleAgreement;
3160 return $this->
getPrice()->getBruttoPrice() - $this->
getCosts(
'oxtsprotection')->getBruttoPrice();