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;
1377 $oTsProtection =
oxNew(
'oxtsprotection');
1378 $oTsProduct = $oTsProtection->getTsProduct($this->
getTsProductId());
1379 $oProtectionPrice = $oTsProduct->getPrice();
1382 $oProtectionPrice =
oxNew(
'oxPrice');
1385 return $oProtectionPrice;
1394 public function setCost($sCostName, $oPrice = null)
1396 $this->_aCosts[$sCostName] = $oPrice;
1426 if ($blForceUpdate) {
1430 if (!($this->_blUpdateNeeded || $blForceUpdate)) {
1434 $this->_aCosts = array();
1490 $this->_blUpdateNeeded =
true;
1498 $this->_blUpdateNeeded =
false;
1510 if ($this->_blUpdateNeeded || $this->_aBasketSummary === null) {
1511 $this->_aBasketSummary =
new stdclass();
1512 $this->_aBasketSummary->aArticles = array();
1513 $this->_aBasketSummary->aCategories = array();
1514 $this->_aBasketSummary->iArticleCount = 0;
1515 $this->_aBasketSummary->dArticlePrice = 0;
1516 $this->_aBasketSummary->dArticleDiscountablePrice = 0;
1524 foreach ($this->_aBasketContents as $oBasketItem) {
1525 if (!$oBasketItem->isBundle() && $oArticle = $oBasketItem->getArticle(
false)) {
1526 $aCatIds = $oArticle->getCategoryIds();
1529 $dDiscountablePrice = 0;
1530 if (($oPrice = $oArticle->getBasketPrice($oBasketItem->getAmount(), $oBasketItem->getSelList(), $this))) {
1531 $dPrice = $oPrice->getPrice();
1532 if (!$oArticle->skipDiscounts()) {
1533 $dDiscountablePrice = $dPrice;
1537 foreach ($aCatIds as $sCatId) {
1538 if (!isset($this->_aBasketSummary->aCategories[$sCatId])) {
1539 $this->_aBasketSummary->aCategories[$sCatId] =
new stdClass();
1542 $this->_aBasketSummary->aCategories[$sCatId]->dPrice += $dPrice * $oBasketItem->getAmount();
1543 $this->_aBasketSummary->aCategories[$sCatId]->dDiscountablePrice += $dDiscountablePrice * $oBasketItem->getAmount();
1544 $this->_aBasketSummary->aCategories[$sCatId]->dAmount += $oBasketItem->getAmount();
1545 $this->_aBasketSummary->aCategories[$sCatId]->iCount++;
1549 if (($sParentId = $oArticle->getParentId()) &&
$myConfig->getConfigParam(
'blVariantParentBuyable')) {
1550 if (!isset($this->_aBasketSummary->aArticles[$sParentId])) {
1551 $this->_aBasketSummary->aArticles[$sParentId] = 0;
1553 $this->_aBasketSummary->aArticles[$sParentId] += $oBasketItem->getAmount();
1556 if (!isset($this->_aBasketSummary->aArticles[$oBasketItem->getProductId()])) {
1557 $this->_aBasketSummary->aArticles[$oBasketItem->getProductId()] = 0;
1560 $this->_aBasketSummary->aArticles[$oBasketItem->getProductId()] += $oBasketItem->getAmount();
1561 $this->_aBasketSummary->iArticleCount += $oBasketItem->getAmount();
1562 $this->_aBasketSummary->dArticlePrice += $dPrice * $oBasketItem->getAmount();
1563 $this->_aBasketSummary->dArticleDiscountablePrice += $dDiscountablePrice * $oBasketItem->getAmount();
1584 if ($this->_oDiscountProductsPriceList) {
1590 $oVoucher =
oxNew(
'oxvoucher');
1592 if (!$this->_blSkipVouchersAvailabilityChecking) {
1593 $oVoucher->getVoucherByNr($sVoucherId, $this->_aVouchers,
true);
1594 $oVoucher->checkVoucherAvailability($this->_aVouchers, $dPrice);
1596 $oVoucher->markAsReserved();
1598 $oVoucher->load($sVoucherId);
1602 $this->_aVouchers[$oVoucher->oxvouchers__oxid->value] = $oVoucher->getSimpleVoucher();
1620 if (isset($this->_aVouchers[$sVoucherId])) {
1622 $oVoucher =
oxNew(
'oxVoucher');
1623 $oVoucher->load($sVoucherId);
1625 $oVoucher->unMarkAsReserved();
1628 unset($this->_aVouchers[$sVoucherId]);
1651 if (count($this->aDiscounts) > 0) {
1653 foreach ($this->aDiscounts as $oDiscount) {
1654 $oDiscount->fDiscount = $oLang->formatCurrency($oDiscount->dDiscount, $this->getBasketCurrency());
1683 $oBasket = $oUser->getBasket(
'savedbasket');
1686 $aSavedItems = $oBasket->getItems();
1687 foreach ($aSavedItems as $oItem) {
1689 $oSelList = $oItem->getSelList();
1691 $this->
addToBasket($oItem->oxuserbasketitems__oxartid->value, $oItem->oxuserbasketitems__oxamount->value, $oSelList, $oItem->getPersParams(),
true);
1708 $oSavedBasket = $oUser->getBasket(
'savedbasket');
1709 $oSavedBasket->delete();
1712 foreach ($this->_aBasketContents as $oBasketItem) {
1714 if (!$oBasketItem->isBundle() && !$oBasketItem->isDiscountArticle()) {
1715 $oSavedBasket->addItemToBasket($oBasketItem->getProductId(), $oBasketItem->getAmount(), $oBasketItem->getSelList(),
true, $oBasketItem->getPersParams());
1731 $oUser->getBasket(
'savedbasket')->delete();
1735 if ($this->
getConfig()->getConfigParam(
'blBasketExcludeEnabled')) {
1750 $sDeliveryCountry = null;
1754 $aHomeCountry =
$myConfig->getConfigParam(
'aHomeCountry');
1755 if (
$myConfig->getConfigParam(
'blCalculateDelCostIfNotLoggedIn') && is_array($aHomeCountry)) {
1756 $sDeliveryCountry = current($aHomeCountry);
1761 if ($sCountryId =
$myConfig->getGlobalParameter(
'delcountryid')) {
1762 $sDeliveryCountry = $sCountryId;
1765 $oDeliveryAddress =
oxNew(
'oxAddress');
1766 if ($oDeliveryAddress->load($sAddressId)) {
1767 $sDeliveryCountry = $oDeliveryAddress->oxaddress__oxcountryid->value;
1772 if (!$sDeliveryCountry) {
1773 $sDeliveryCountry = $oUser->oxuser__oxcountryid->value;
1777 return $sDeliveryCountry;
1785 $this->_aBasketContents = array();
1788 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled')) {
1789 $this->
getSession()->getBasketReservations()->discardReservations();
1803 $this->_sPaymentId = $sPaymentId;
1813 if (!$this->_sPaymentId) {
1827 $this->_sShippingSetId = $sShippingSetId;
1838 $this->_oDeliveryPrice = $oShippingPrice;
1848 if (!$this->_sShippingSetId) {
1854 if (!$this->_sShippingSetId && $sActPaymentId !=
'oxempty') {
1858 list(, $sActShipSet) =
oxRegistry::get(
"oxDeliverySetList")->getDeliverySetData(null, $oUser, $this);
1860 $this->_sShippingSetId = $sActShipSet ? $sActShipSet : ($oUser ? null :
'oxidstandard');
1861 } elseif (!$this->
isAdmin() && $sActPaymentId ==
'oxempty') {
1863 $this->_sShippingSetId = null;
1876 $aBasketArticles = array();
1878 foreach ($this->_aBasketContents as $sItemKey => $oBasketItem) {
1880 $oProduct = $oBasketItem->getArticle(
true);
1882 if ($this->
getConfig()->getConfigParam(
'bl_perfLoadSelectLists')) {
1884 $aSelList = $oBasketItem->getSelList();
1885 if (is_array($aSelList) && ($aSelectlist = $oProduct->getSelectLists($sItemKey))) {
1887 while (list($conkey, $iSel) = each($aSelList)) {
1888 $aSelectlist[$conkey][$iSel] = $aSelectlist[$conkey][$iSel];
1889 $aSelectlist[$conkey][$iSel]->selected = 1;
1891 $oProduct->setSelectlist($aSelectlist);
1906 $aBasketArticles[$sItemKey] = $oProduct;
1909 return $aBasketArticles;
1929 if (is_null($this->_oProductsPriceList)) {
1930 $this->_oProductsPriceList =
oxNew(
'oxPriceList');
1943 if (is_null($this->_oPrice)) {
1957 $this->_oPrice = $oPrice;
1979 $this->_sOrderId = $sId;
1994 return isset($this->_aCosts[$sId]) ? $this->_aCosts[$sId] : null;
2017 return count($this->_aBasketContents);
2029 foreach ($this->_aBasketContents as $oBasketItem) {
2030 $itemsCount += $oBasketItem->getAmount();
2045 foreach ($this->_aBasketContents as $oBasketItem) {
2046 $weight += $oBasketItem->getWeight();
2071 if (!$this->_oNotDiscountedProductsPriceList) {
2078 foreach ((array)$this->_aDiscountedVats as $sKey => $dVat) {
2079 if (!isset($aVats[$sKey])) {
2083 $aVats[$sKey] += $oUtils->fRound($dVat, $this->_oCurrency);
2086 if ($blFormatCurrency) {
2088 foreach ($aVats as $sKey => $dVat) {
2103 $this->_sCardMessage = $sMessage;
2113 return $this->_sCardMessage;
2123 $this->_sCardId = $sCardId;
2133 return $this->_sCardId;
2145 $oCard =
oxNew(
'oxWrapping');
2146 $oCard->load($sCardId);
2174 return array_merge($this->_aItemDiscounts, $this->_aDiscounts);
2184 if ($this->
getConfig()->getConfigParam(
'bl_showVouchers')) {
2198 $this->_oCurrency = $oCurrency;
2208 if ($this->_oCurrency === null) {
2209 $this->_oCurrency = $this->
getConfig()->getActShopCurrencyObject();
2222 $this->_blSkipVouchersAvailabilityChecking = $blSkipChecking;
2242 $this->_blSkipDiscounts = $blSkip;
2278 return $this->
getCosts(
'oxdelivery')->getVat();
2290 $dDelVAT = $this->
getCosts(
'oxdelivery')->getVatValue();
2293 if ($dDelVAT > 0 && $this->
getConfig()->getConfigParam(
'blShowVATForDelivery')) {
2312 if ($oConfig->getConfigParam(
'blShowVATForDelivery') && ($this->
getBasketUser() || $oConfig->getConfigParam(
'blCalculateDelCostIfNotLoggedIn'))) {
2313 $dNetPrice = $this->
getCosts(
'oxdelivery')->getNettoPrice();
2314 if ($dNetPrice > 0) {
2331 return $this->
getCosts(
'oxpayment')->getVat();
2343 $dPayVAT = $this->
getCosts(
'oxpayment')->getVatValue();
2346 if ($dPayVAT > 0 && $this->
getConfig()->getConfigParam(
'blShowVATForPayCharge')) {
2363 if ($this->
getConfig()->getConfigParam(
'blShowVATForPayCharge')) {
2364 $oPaymentCost = $this->
getCosts(
'oxpayment');
2365 if ($oPaymentCost && $oPaymentCost->getNettoPrice()) {
2382 $oPaymentCost = $this->
getCosts(
'oxpayment');
2383 if ($oPaymentCost && $oPaymentCost->getBruttoPrice()) {
2384 return $oPaymentCost->getBruttoPrice();
2395 return $this->
getCosts(
'oxpayment');
2407 $oPaymentCost = $this->
getCosts(
'oxpayment');
2408 if ($oPaymentCost && $oPaymentCost->getBruttoPrice()) {
2439 if ($oVoucherDiscount->getBruttoPrice()) {
2457 return $this->
getCosts(
'oxwrapping')->getVat();
2470 return $this->
getCosts(
'oxgiftcard')->getVat();
2483 if ($this->
getConfig()->getConfigParam(
'blShowVATForWrapping')) {
2484 $oPrice = $this->
getCosts(
'oxwrapping');
2486 if ($oPrice && $oPrice->getVatValue() > 0) {
2504 if ($this->
getConfig()->getConfigParam(
'blShowVATForWrapping')) {
2505 $oPrice = $this->
getCosts(
'oxwrapping');
2507 if ($oPrice && $oPrice->getNettoPrice() > 0) {
2524 $oPrice = $this->
getCosts(
'oxwrapping');
2526 if ($oPrice && $oPrice->getBruttoPrice()) {
2540 return $this->
getCosts(
'oxwrapping');
2553 if ($this->
getConfig()->getConfigParam(
'blShowVATForWrapping')) {
2554 $oPrice = $this->
getCosts(
'oxgiftcard');
2556 if ($oPrice && $oPrice->getVatValue() > 0) {
2575 if ($this->
getConfig()->getConfigParam(
'blShowVATForWrapping')) {
2576 $oPrice = $this->
getCosts(
'oxgiftcard');
2578 if ($oPrice && $oPrice->getNettoPrice() > 0) {
2595 $oPrice = $this->
getCosts(
'oxgiftcard');
2597 if ($oPrice && $oPrice->getBruttoPrice()) {
2611 return $this->
getCosts(
'oxgiftcard');
2635 $oPrice = $this->
getCosts(
'oxdelivery');
2637 if ($oPrice && ($this->
getBasketUser() || $this->
getConfig()->getConfigParam(
'blCalculateDelCostIfNotLoggedIn'))) {
2653 if ($oDeliveryCost = $this->
getCosts(
'oxdelivery')) {
2654 return $oDeliveryCost->getBruttoPrice();
2667 return $this->
getCosts(
'oxdelivery');
2677 $this->_oTotalDiscount =
oxNew(
'oxPrice');
2678 $this->_oTotalDiscount->setBruttoPriceMode();
2679 $this->_oTotalDiscount->add($dDiscount);
2693 $dPrice += $oPriceList->getBruttoSum();
2697 if ($oDeliveryPrice = $this->_aCosts[
'oxdelivery']) {
2698 $dPrice += $oDeliveryPrice->getBruttoPrice();
2718 $dPrice -= $oPrice->getPrice();
2722 $dPrice -= $oVoucherPrice->getPrice();
2738 $dPrice += $oPrice->getPrice();
2742 $dPrice += $oVoucherPrice->getPrice();
2756 $dPrice = $oProductsPrice->getBruttoSum();
2761 $dPrice -= $oPrice->getBruttoPrice();
2765 $dPrice -= $oVoucherPrice->getBruttoPrice();
2778 $blIsBelowMinOrderPrice =
false;
2779 $sConfValue = $this->
getConfig()->getConfigParam(
'iMinOrderPrice');
2782 $dNotDiscountedProductPrice = 0;
2784 $dNotDiscountedProductPrice = $oPrice->getBruttoSum();
2789 return $blIsBelowMinOrderPrice;
2804 foreach ($this->_aBasketContents as $sItemKey => $oOrderArticle) {
2805 if ($oOrderArticle && ($sExpiredArtId == null || $sExpiredArtId != $sItemKey)) {
2806 if ($oOrderArticle->getArticle(
true)->getId() == $sArtId) {
2807 $dArtStock += $oOrderArticle->getAmount();
2827 if ($this->_sBasketCategoryId === null) {
2831 if ($oView = $this->
getConfig()->getActiveView()) {
2832 if ($oCat = $oView->getActiveCategory()) {
2843 $oProduct =
oxNew(
"oxArticle");
2844 if ($oProduct->load($sProductId)) {
2845 $oCat = $oProduct->getCategory();
2856 if ($blCanAdd === null) {
2873 $sO2CTable = getViewName(
'oxobject2category');
2874 $sCatTable = getViewName(
'oxcategories');
2877 $sParentId = $oDb->getOne(
"select oxparentid from oxarticles where oxid = " . $oDb->quote($sProductId));
2878 $sProductId = $sParentId ? $sParentId : $sProductId;
2880 $sQ =
"select 1 from {$sO2CTable}
2881 left join {$sCatTable} on {$sCatTable}.oxid = {$sO2CTable}.oxcatnid
2882 where {$sO2CTable}.oxobjectid = " . $oDb->quote($sProductId) .
" and
2883 {$sCatTable}.oxrootid = " . $oDb->quote($sRootCatId);
2885 return (
bool) $oDb->getOne($sQ);
2895 $this->_sBasketCategoryId = $sRoot;
2915 $this->_blShowCatChangeWarning = $blShow;
2937 $this->_sTsProductId = $sProductId;
2961 $oProtectionCost = $this->
getCosts(
'oxtsprotection');
2962 if ($oProtectionCost && $oProtectionCost->getBruttoPrice()) {
2978 return $this->
getCosts(
'oxtsprotection')->getVat();
2990 $dProtectionVAT = $this->
getCosts(
'oxtsprotection')->getVatValue();
2992 if ($dProtectionVAT > 0 && $this->
getConfig()->getConfigParam(
'blShowVATForPayCharge')) {
3009 if ($this->
getConfig()->getConfigParam(
'blShowVATForPayCharge')) {
3025 $oProtection = $this->
getCosts(
'oxtsprotection');
3027 return $oProtection->getBruttoPrice();
3042 return $this->
getCosts(
'oxtsprotection');
3067 protected function _addedNewItem($sProductID, $dAmount, $aSel, $aPersParam, $blOverride, $blBundle, $sOldBasketItemId)
3070 $this->_blNewITemAdded = null;
3080 $this->_blNewITemAdded = null;
3081 $this->_isCalculationModeNetto = null;
3091 if ($this->_blNewITemAdded == null) {
3106 $this->_blDownloadableProducts =
false;
3108 foreach ($this->_aBasketContents as $oBasketItem) {
3109 if ($oBasketItem->getArticle(
false) && $oBasketItem->getArticle(
false)->isDownloadable()) {
3110 $this->_blDownloadableProducts =
true;
3125 $blHasArticlesWithIntangibleAgreement =
false;
3128 foreach ($this->_aBasketContents as $oBasketItem) {
3129 if ($oBasketItem->getArticle(
false) && $oBasketItem->getArticle(
false)->hasIntangibleAgreement()) {
3130 $blHasArticlesWithIntangibleAgreement =
true;
3135 return $blHasArticlesWithIntangibleAgreement;
3145 $blHasArticlesWithIntangibleAgreement =
false;
3148 foreach ($this->_aBasketContents as $oBasketItem) {
3149 if ($oBasketItem->getArticle(
false) && $oBasketItem->getArticle(
false)->hasDownloadableAgreement()) {
3150 $blHasArticlesWithIntangibleAgreement =
true;
3155 return $blHasArticlesWithIntangibleAgreement;
3177 return $this->
getPrice()->getBruttoPrice() - $this->
getCosts(
'oxtsprotection')->getBruttoPrice();