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();
1446 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled')) {
1447 $this->
getSession()->getBasketReservations()->reserveBasket($this);
1495 $this->_blUpdateNeeded =
true;
1503 $this->_blUpdateNeeded =
false;
1515 if ($this->_blUpdateNeeded || $this->_aBasketSummary === null) {
1516 $this->_aBasketSummary =
new stdclass();
1517 $this->_aBasketSummary->aArticles = array();
1518 $this->_aBasketSummary->aCategories = array();
1519 $this->_aBasketSummary->iArticleCount = 0;
1520 $this->_aBasketSummary->dArticlePrice = 0;
1521 $this->_aBasketSummary->dArticleDiscountablePrice = 0;
1529 foreach ($this->_aBasketContents as $oBasketItem) {
1530 if (!$oBasketItem->isBundle() && $oArticle = $oBasketItem->getArticle(
false)) {
1531 $aCatIds = $oArticle->getCategoryIds();
1534 $dDiscountablePrice = 0;
1535 if (($oPrice = $oArticle->getBasketPrice($oBasketItem->getAmount(), $oBasketItem->getSelList(), $this))) {
1536 $dPrice = $oPrice->getPrice();
1537 if (!$oArticle->skipDiscounts()) {
1538 $dDiscountablePrice = $dPrice;
1542 foreach ($aCatIds as $sCatId) {
1543 if (!isset($this->_aBasketSummary->aCategories[$sCatId])) {
1544 $this->_aBasketSummary->aCategories[$sCatId] =
new stdClass();
1547 $this->_aBasketSummary->aCategories[$sCatId]->dPrice += $dPrice * $oBasketItem->getAmount();
1548 $this->_aBasketSummary->aCategories[$sCatId]->dDiscountablePrice += $dDiscountablePrice * $oBasketItem->getAmount();
1549 $this->_aBasketSummary->aCategories[$sCatId]->dAmount += $oBasketItem->getAmount();
1550 $this->_aBasketSummary->aCategories[$sCatId]->iCount++;
1554 if (($sParentId = $oArticle->getParentId()) &&
$myConfig->getConfigParam(
'blVariantParentBuyable')) {
1555 if (!isset($this->_aBasketSummary->aArticles[$sParentId])) {
1556 $this->_aBasketSummary->aArticles[$sParentId] = 0;
1558 $this->_aBasketSummary->aArticles[$sParentId] += $oBasketItem->getAmount();
1561 if (!isset($this->_aBasketSummary->aArticles[$oBasketItem->getProductId()])) {
1562 $this->_aBasketSummary->aArticles[$oBasketItem->getProductId()] = 0;
1565 $this->_aBasketSummary->aArticles[$oBasketItem->getProductId()] += $oBasketItem->getAmount();
1566 $this->_aBasketSummary->iArticleCount += $oBasketItem->getAmount();
1567 $this->_aBasketSummary->dArticlePrice += $dPrice * $oBasketItem->getAmount();
1568 $this->_aBasketSummary->dArticleDiscountablePrice += $dDiscountablePrice * $oBasketItem->getAmount();
1589 if ($this->_oDiscountProductsPriceList) {
1595 $oVoucher =
oxNew(
'oxvoucher');
1597 if (!$this->_blSkipVouchersAvailabilityChecking) {
1598 $oVoucher->getVoucherByNr($sVoucherId, $this->_aVouchers,
true);
1599 $oVoucher->checkVoucherAvailability($this->_aVouchers, $dPrice);
1601 $oVoucher->markAsReserved();
1603 $oVoucher->load($sVoucherId);
1607 $this->_aVouchers[$oVoucher->oxvouchers__oxid->value] = $oVoucher->getSimpleVoucher();
1625 if (isset($this->_aVouchers[$sVoucherId])) {
1627 $oVoucher =
oxNew(
'oxVoucher');
1628 $oVoucher->load($sVoucherId);
1630 $oVoucher->unMarkAsReserved();
1633 unset($this->_aVouchers[$sVoucherId]);
1656 if (count($this->aDiscounts) > 0) {
1658 foreach ($this->aDiscounts as $oDiscount) {
1659 $oDiscount->fDiscount = $oLang->formatCurrency($oDiscount->dDiscount, $this->getBasketCurrency());
1688 $oBasket = $oUser->getBasket(
'savedbasket');
1691 $aSavedItems = $oBasket->getItems();
1692 foreach ($aSavedItems as $oItem) {
1694 $oSelList = $oItem->getSelList();
1696 $this->
addToBasket($oItem->oxuserbasketitems__oxartid->value, $oItem->oxuserbasketitems__oxamount->value, $oSelList, $oItem->getPersParams(),
true);
1713 $oSavedBasket = $oUser->getBasket(
'savedbasket');
1714 $oSavedBasket->delete();
1717 foreach ($this->_aBasketContents as $oBasketItem) {
1719 if (!$oBasketItem->isBundle() && !$oBasketItem->isDiscountArticle()) {
1720 $oSavedBasket->addItemToBasket($oBasketItem->getProductId(), $oBasketItem->getAmount(), $oBasketItem->getSelList(),
true, $oBasketItem->getPersParams());
1736 $oUser->getBasket(
'savedbasket')->delete();
1740 if ($this->
getConfig()->getConfigParam(
'blBasketExcludeEnabled')) {
1755 $sDeliveryCountry = null;
1759 $aHomeCountry =
$myConfig->getConfigParam(
'aHomeCountry');
1760 if (
$myConfig->getConfigParam(
'blCalculateDelCostIfNotLoggedIn') && is_array($aHomeCountry)) {
1761 $sDeliveryCountry = current($aHomeCountry);
1766 if ($sCountryId =
$myConfig->getGlobalParameter(
'delcountryid')) {
1767 $sDeliveryCountry = $sCountryId;
1770 $oDeliveryAddress =
oxNew(
'oxAddress');
1771 if ($oDeliveryAddress->load($sAddressId)) {
1772 $sDeliveryCountry = $oDeliveryAddress->oxaddress__oxcountryid->value;
1777 if (!$sDeliveryCountry) {
1778 $sDeliveryCountry = $oUser->oxuser__oxcountryid->value;
1782 return $sDeliveryCountry;
1790 $this->_aBasketContents = array();
1793 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled')) {
1794 $this->
getSession()->getBasketReservations()->discardReservations();
1808 $this->_sPaymentId = $sPaymentId;
1818 if (!$this->_sPaymentId) {
1832 $this->_sShippingSetId = $sShippingSetId;
1843 $this->_oDeliveryPrice = $oShippingPrice;
1853 if (!$this->_sShippingSetId) {
1859 if (!$this->_sShippingSetId && $sActPaymentId !=
'oxempty') {
1863 list(, $sActShipSet) =
oxRegistry::get(
"oxDeliverySetList")->getDeliverySetData(null, $oUser, $this);
1865 $this->_sShippingSetId = $sActShipSet ? $sActShipSet : ($oUser ? null :
'oxidstandard');
1866 } elseif (!$this->
isAdmin() && $sActPaymentId ==
'oxempty') {
1868 $this->_sShippingSetId = null;
1881 $aBasketArticles = array();
1883 foreach ($this->_aBasketContents as $sItemKey => $oBasketItem) {
1885 $oProduct = $oBasketItem->getArticle(
true);
1887 if ($this->
getConfig()->getConfigParam(
'bl_perfLoadSelectLists')) {
1889 $aSelList = $oBasketItem->getSelList();
1890 if (is_array($aSelList) && ($aSelectlist = $oProduct->getSelectLists($sItemKey))) {
1892 while (list($conkey, $iSel) = each($aSelList)) {
1893 $aSelectlist[$conkey][$iSel] = $aSelectlist[$conkey][$iSel];
1894 $aSelectlist[$conkey][$iSel]->selected = 1;
1896 $oProduct->setSelectlist($aSelectlist);
1911 $aBasketArticles[$sItemKey] = $oProduct;
1914 return $aBasketArticles;
1934 if (is_null($this->_oProductsPriceList)) {
1935 $this->_oProductsPriceList =
oxNew(
'oxPriceList');
1948 if (is_null($this->_oPrice)) {
1962 $this->_oPrice = $oPrice;
1984 $this->_sOrderId = $sId;
1999 return isset($this->_aCosts[$sId]) ? $this->_aCosts[$sId] : null;
2064 if (!$this->_oNotDiscountedProductsPriceList) {
2071 foreach ((array)$this->_aDiscountedVats as $sKey => $dVat) {
2072 if (!isset($aVats[$sKey])) {
2076 $aVats[$sKey] += $oUtils->fRound($dVat, $this->_oCurrency);
2079 if ($blFormatCurrency) {
2081 foreach ($aVats as $sKey => $dVat) {
2096 $this->_sCardMessage = $sMessage;
2106 return $this->_sCardMessage;
2116 $this->_sCardId = $sCardId;
2126 return $this->_sCardId;
2138 $oCard =
oxNew(
'oxWrapping');
2139 $oCard->load($sCardId);
2167 return array_merge($this->_aItemDiscounts, $this->_aDiscounts);
2177 if ($this->
getConfig()->getConfigParam(
'bl_showVouchers')) {
2191 $this->_oCurrency = $oCurrency;
2201 if ($this->_oCurrency === null) {
2202 $this->_oCurrency = $this->
getConfig()->getActShopCurrencyObject();
2215 $this->_blSkipVouchersAvailabilityChecking = $blSkipChecking;
2235 $this->_blSkipDiscounts = $blSkip;
2271 return $this->
getCosts(
'oxdelivery')->getVat();
2283 $dDelVAT = $this->
getCosts(
'oxdelivery')->getVatValue();
2286 if ($dDelVAT > 0 && $this->
getConfig()->getConfigParam(
'blShowVATForDelivery')) {
2305 if ($oConfig->getConfigParam(
'blShowVATForDelivery') && ($this->
getBasketUser() || $oConfig->getConfigParam(
'blCalculateDelCostIfNotLoggedIn'))) {
2306 $dNetPrice = $this->
getCosts(
'oxdelivery')->getNettoPrice();
2307 if ($dNetPrice > 0) {
2324 return $this->
getCosts(
'oxpayment')->getVat();
2336 $dPayVAT = $this->
getCosts(
'oxpayment')->getVatValue();
2339 if ($dPayVAT > 0 && $this->
getConfig()->getConfigParam(
'blShowVATForPayCharge')) {
2356 if ($this->
getConfig()->getConfigParam(
'blShowVATForPayCharge')) {
2357 $oPaymentCost = $this->
getCosts(
'oxpayment');
2358 if ($oPaymentCost && $oPaymentCost->getNettoPrice()) {
2375 $oPaymentCost = $this->
getCosts(
'oxpayment');
2376 if ($oPaymentCost && $oPaymentCost->getBruttoPrice()) {
2377 return $oPaymentCost->getBruttoPrice();
2388 return $this->
getCosts(
'oxpayment');
2400 $oPaymentCost = $this->
getCosts(
'oxpayment');
2401 if ($oPaymentCost && $oPaymentCost->getBruttoPrice()) {
2432 if ($oVoucherDiscount->getBruttoPrice()) {
2450 return $this->
getCosts(
'oxwrapping')->getVat();
2463 return $this->
getCosts(
'oxgiftcard')->getVat();
2476 if ($this->
getConfig()->getConfigParam(
'blShowVATForWrapping')) {
2477 $oPrice = $this->
getCosts(
'oxwrapping');
2479 if ($oPrice && $oPrice->getVatValue() > 0) {
2497 if ($this->
getConfig()->getConfigParam(
'blShowVATForWrapping')) {
2498 $oPrice = $this->
getCosts(
'oxwrapping');
2500 if ($oPrice && $oPrice->getNettoPrice() > 0) {
2517 $oPrice = $this->
getCosts(
'oxwrapping');
2519 if ($oPrice && $oPrice->getBruttoPrice()) {
2533 return $this->
getCosts(
'oxwrapping');
2546 if ($this->
getConfig()->getConfigParam(
'blShowVATForWrapping')) {
2547 $oPrice = $this->
getCosts(
'oxgiftcard');
2549 if ($oPrice && $oPrice->getVatValue() > 0) {
2568 if ($this->
getConfig()->getConfigParam(
'blShowVATForWrapping')) {
2569 $oPrice = $this->
getCosts(
'oxgiftcard');
2571 if ($oPrice && $oPrice->getNettoPrice() > 0) {
2588 $oPrice = $this->
getCosts(
'oxgiftcard');
2590 if ($oPrice && $oPrice->getBruttoPrice()) {
2604 return $this->
getCosts(
'oxgiftcard');
2628 $oPrice = $this->
getCosts(
'oxdelivery');
2630 if ($oPrice && ($this->
getBasketUser() || $this->
getConfig()->getConfigParam(
'blCalculateDelCostIfNotLoggedIn'))) {
2646 if ($oDeliveryCost = $this->
getCosts(
'oxdelivery')) {
2647 return $oDeliveryCost->getBruttoPrice();
2660 return $this->
getCosts(
'oxdelivery');
2670 $this->_oTotalDiscount =
oxNew(
'oxPrice');
2671 $this->_oTotalDiscount->setBruttoPriceMode();
2672 $this->_oTotalDiscount->add($dDiscount);
2686 $dPrice += $oPriceList->getBruttoSum();
2690 if ($oDeliveryPrice = $this->_aCosts[
'oxdelivery']) {
2691 $dPrice += $oDeliveryPrice->getBruttoPrice();
2711 $dPrice -= $oPrice->getPrice();
2715 $dPrice -= $oVoucherPrice->getPrice();
2731 $dPrice += $oPrice->getPrice();
2735 $dPrice += $oVoucherPrice->getPrice();
2749 $dPrice = $oProductsPrice->getBruttoSum();
2754 $dPrice -= $oPrice->getBruttoPrice();
2758 $dPrice -= $oVoucherPrice->getBruttoPrice();
2771 $blIsBelowMinOrderPrice =
false;
2772 $sConfValue = $this->
getConfig()->getConfigParam(
'iMinOrderPrice');
2775 $dNotDiscountedProductPrice = 0;
2777 $dNotDiscountedProductPrice = $oPrice->getBruttoSum();
2782 return $blIsBelowMinOrderPrice;
2797 foreach ($this->_aBasketContents as $sItemKey => $oOrderArticle) {
2798 if ($oOrderArticle && ($sExpiredArtId == null || $sExpiredArtId != $sItemKey)) {
2799 if ($oOrderArticle->getArticle(
true)->getId() == $sArtId) {
2800 $dArtStock += $oOrderArticle->getAmount();
2820 if ($this->_sBasketCategoryId === null) {
2824 if ($oView = $this->
getConfig()->getActiveView()) {
2825 if ($oCat = $oView->getActiveCategory()) {
2836 $oProduct =
oxNew(
"oxArticle");
2837 if ($oProduct->load($sProductId)) {
2838 $oCat = $oProduct->getCategory();
2849 if ($blCanAdd === null) {
2866 $sO2CTable = getViewName(
'oxobject2category');
2867 $sCatTable = getViewName(
'oxcategories');
2870 $sParentId = $oDb->getOne(
"select oxparentid from oxarticles where oxid = " . $oDb->quote($sProductId));
2871 $sProductId = $sParentId ? $sParentId : $sProductId;
2873 $sQ =
"select 1 from {$sO2CTable}
2874 left join {$sCatTable} on {$sCatTable}.oxid = {$sO2CTable}.oxcatnid
2875 where {$sO2CTable}.oxobjectid = " . $oDb->quote($sProductId) .
" and
2876 {$sCatTable}.oxrootid = " . $oDb->quote($sRootCatId);
2878 return (
bool) $oDb->getOne($sQ);
2888 $this->_sBasketCategoryId = $sRoot;
2908 $this->_blShowCatChangeWarning = $blShow;
2930 $this->_sTsProductId = $sProductId;
2954 $oProtectionCost = $this->
getCosts(
'oxtsprotection');
2955 if ($oProtectionCost && $oProtectionCost->getBruttoPrice()) {
2971 return $this->
getCosts(
'oxtsprotection')->getVat();
2983 $dProtectionVAT = $this->
getCosts(
'oxtsprotection')->getVatValue();
2985 if ($dProtectionVAT > 0 && $this->
getConfig()->getConfigParam(
'blShowVATForPayCharge')) {
3002 if ($this->
getConfig()->getConfigParam(
'blShowVATForPayCharge')) {
3018 $oProtection = $this->
getCosts(
'oxtsprotection');
3020 return $oProtection->getBruttoPrice();
3035 return $this->
getCosts(
'oxtsprotection');
3060 protected function _addedNewItem($sProductID, $dAmount, $aSel, $aPersParam, $blOverride, $blBundle, $sOldBasketItemId)
3063 $this->_blNewITemAdded = null;
3073 $this->_blNewITemAdded = null;
3074 $this->_isCalculationModeNetto = null;
3084 if ($this->_blNewITemAdded == null) {
3099 $this->_blDownloadableProducts =
false;
3101 foreach ($this->_aBasketContents as $oBasketItem) {
3102 if ($oBasketItem->getArticle(
false) && $oBasketItem->getArticle(
false)->isDownloadable()) {
3103 $this->_blDownloadableProducts =
true;
3118 $blHasArticlesWithIntangibleAgreement =
false;
3121 foreach ($this->_aBasketContents as $oBasketItem) {
3122 if ($oBasketItem->getArticle(
false) && $oBasketItem->getArticle(
false)->hasIntangibleAgreement()) {
3123 $blHasArticlesWithIntangibleAgreement =
true;
3128 return $blHasArticlesWithIntangibleAgreement;
3138 $blHasArticlesWithIntangibleAgreement =
false;
3141 foreach ($this->_aBasketContents as $oBasketItem) {
3142 if ($oBasketItem->getArticle(
false) && $oBasketItem->getArticle(
false)->hasDownloadableAgreement()) {
3143 $blHasArticlesWithIntangibleAgreement =
true;
3148 return $blHasArticlesWithIntangibleAgreement;
3170 return $this->
getPrice()->getBruttoPrice() - $this->
getCosts(
'oxtsprotection')->getBruttoPrice();