267 if ( $this->_isCalculationModeNetto === null ) {
283 $this->_isCalculationModeNetto = (bool) $blNettoMode;
315 $this->_dNettoSum = $dNettoSum;
327 $this->_dBruttoSum = $dBruttoSum;
351 reset($this->_aBasketContents);
353 while (key($this->_aBasketContents) != $sOldKey && next($this->_aBasketContents)) {
356 $aNewCopy = array_merge(
357 array_slice($this->_aBasketContents, 0, $iOldKeyPlace,
true),
358 array($sNewKey => $value),
359 array_slice($this->_aBasketContents, $iOldKeyPlace+1, count($this->_aBasketContents)-$iOldKeyPlace,
true)
361 $this->_aBasketContents = $aNewCopy;
379 public function addToBasket( $sProductID, $dAmount, $aSel = null, $aPersParam = null, $blOverride =
false, $blBundle =
false, $sOldBasketItemId = null )
386 if ( $this->
getConfig()->getConfigParam(
'blBasketExcludeEnabled' ) ) {
395 $sItemId = $this->
getItemKey( $sProductID, $aSel, $aPersParam, $blBundle );
396 if ( $sOldBasketItemId && ( strcmp( $sOldBasketItemId, $sItemId ) != 0 ) ) {
397 if ( isset( $this->_aBasketContents[$sItemId] ) ) {
399 unset( $this->_aBasketContents[$sOldBasketItemId] );
409 $blRemoveItem =
false;
414 if ( isset( $this->_aBasketContents[$sItemId] ) ) {
419 $this->_aBasketContents[$sItemId]->setStockCheckStatus( $this->
getStockCheckMode() );
422 $this->_aBasketContents[$sItemId]->setAmount( $dAmount, $blOverride, $sItemId );
429 $oBasketItem =
oxNew(
'oxbasketitem' );
432 $oBasketItem->init( $sProductID, $dAmount, $aSel, $aPersParam, $blBundle );
436 $blRemoveItem =
true;
442 $blRemoveItem =
true;
445 $this->_aBasketContents[$sItemId] = $oBasketItem;
449 if ( $this->_aBasketContents[$sItemId]->getAmount() == 0 || $blRemoveItem ) {
451 } elseif ( $blBundle ) {
453 $this->_aBasketContents[$sItemId]->setBundle(
true );
465 $this->
_addedNewItem( $sProductID, $dAmount, $aSel, $aPersParam, $blOverride, $blBundle, $sOldBasketItemId );
469 return $this->_aBasketContents[$sItemId];
482 if ( $oOrderArticle->oxorderarticles__oxamount->value > 0 && !$oOrderArticle->isBundle() ) {
484 $this->_isForOrderRecalculation =
true;
485 $sItemId = $oOrderArticle->getId();
488 $this->_aBasketContents[$sItemId] =
oxNew(
'oxbasketitem' );
489 $this->_aBasketContents[$sItemId]->initFromOrderArticle( $oOrderArticle );
490 $this->_aBasketContents[$sItemId]->setWrapping( $oOrderArticle->oxorderarticles__oxwrapid->value );
491 $this->_aBasketContents[$sItemId]->setBundle( $oOrderArticle->isBundle() );
496 return $this->_aBasketContents[$sItemId];
497 } elseif ( $oOrderArticle->isBundle() ) {
499 $oOrderArticle->delete();
514 $this->_blCheckStock = $blCheck;
539 public function getItemKey( $sProductId, $aSel = null, $aPersParam = null, $blBundle =
false, $sAdditionalParam =
'' )
541 $aSel = ( $aSel != null) ? $aSel : array (0=>
'0');
543 $sItemKey = md5( $sProductId.
'|'.serialize( $aSel ).
'|'.serialize( $aPersParam ).
'|'.(
int ) $blBundle .
'|' . serialize( $sAdditionalParam ) );
558 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled' )) {
559 if (isset($this->_aBasketContents[$sItemKey])) {
560 $sArticleId = $this->_aBasketContents[$sItemKey]->getProductId();
563 ->getBasketReservations()
564 ->discardArticleReservation($sArticleId);
568 unset( $this->_aBasketContents[$sItemKey] );
571 if ( !count($this->_aBasketContents) && $this->
getConfig()->getConfigParam(
'blBasketExcludeEnabled' ) ) {
583 reset( $this->_aBasketContents );
584 while ( list( $sItemKey, $oBasketItem ) = each( $this->_aBasketContents ) ) {
585 if ( $oBasketItem->isBundle() ) {
602 if ( $oBasketItem->isBundle() ) {
606 $oArticle = $oBasketItem->getArticle(
true );
607 if ( $oArticle && $oArticle->oxarticles__oxbundleid->value ) {
608 $aBundles[$oArticle->oxarticles__oxbundleid->value] = 1;
624 if ( $oBasketItem->isBundle() ) {
629 if ( $oArticle = $oBasketItem->getArticle() ) {
632 foreach ( $aDiscounts as $oDiscount ) {
634 $iAmnt = $oDiscount->getBundleAmount( $oBasketItem->getAmount() );
637 if ( !isset( $aBundles[$oDiscount->oxdiscount__oxitmartid->value] ) ) {
638 $aBundles[$oDiscount->oxdiscount__oxitmartid->value] = 0;
641 if ($oDiscount->oxdiscount__oxitmmultiple->value) {
642 $aBundles[$oDiscount->oxdiscount__oxitmartid->value] += $iAmnt;
644 $aBundles[$oDiscount->oxdiscount__oxitmartid->value] = $iAmnt;
666 foreach ( $this->_aBasketContents as $oBasketItem ) {
667 if ( !( $oBasketItem->isBundle() || $oBasketItem->isDiscountArticle() ) ) {
668 $dAmount += $oBasketItem->getAmount();
672 foreach ( $aDiscounts as $oDiscount ) {
673 if ($oDiscount->oxdiscount__oxitmartid->value) {
674 if ( !isset( $aBundles[$oDiscount->oxdiscount__oxitmartid->value] ) ) {
675 $aBundles[$oDiscount->oxdiscount__oxitmartid->value] = 0;
678 $aBundles[$oDiscount->oxdiscount__oxitmartid->value] += $oDiscount->getBundleAmount( $dAmount );
695 foreach ( $this->_aBasketContents as $key => $oBasketItem ) {
698 if ( !$oBasketItem->isDiscountArticle() && !$oBasketItem->isBundle() ) {
736 foreach ( $aBundles as $sBundleId => $dAmount ) {
739 if ( $oBundleItem = $this->
addToBasket( $sBundleId, $dAmount, null, null,
false,
true ) ) {
740 $oBundleItem->setAsDiscountArticle(
true );
759 $this->_iProductsCnt = 0;
760 $this->_dItemsCnt = 0;
763 $this->_oProductsPriceList =
oxNew(
'oxpricelist' );
764 $this->_oDiscountProductsPriceList =
oxNew(
'oxpricelist' );
765 $this->_oNotDiscountedProductsPriceList =
oxNew(
'oxpricelist' );
769 foreach ( $this->_aBasketContents as $oBasketItem ) {
770 $this->_iProductsCnt++;
771 $this->_dItemsCnt += $oBasketItem->getAmount();
772 $this->_dWeight += $oBasketItem->getWeight();
774 if ( !$oBasketItem->isDiscountArticle() && ( $oArticle = $oBasketItem->getArticle(
true ) ) ) {
776 $oBasketPrice = $oArticle->getBasketPrice( $oBasketItem->getAmount(), $oBasketItem->getSelList(), $this );
777 $oBasketItem->setRegularUnitPrice( clone $oBasketPrice );
781 $aDiscounts = $oDiscountList->getBasketItemDiscounts( $oArticle, $this, $this->
getBasketUser() );
782 reset( $aDiscounts );
783 foreach ( $aDiscounts as $oDiscount ) {
784 $oBasketPrice->setDiscount($oDiscount->getAddSum(), $oDiscount->getAddSumType());
786 $oBasketPrice->calculateDiscount();
788 $oBasketItem->setSkipDiscounts(
true );
792 $oBasketItem->setPrice( $oBasketPrice );
793 $this->_oProductsPriceList->addToPriceList( $oBasketItem->getPrice() );
796 if ( !$oArticle->skipDiscounts() ) {
798 $this->_oDiscountProductsPriceList->addToPriceList( $oBasketItem->getPrice() );
800 $this->_oNotDiscountedProductsPriceList->addToPriceList( $oBasketItem->getPrice() );
801 $oBasketItem->setSkipDiscounts(
true );
804 } elseif ( $oBasketItem->isBundle() ) {
806 $oPrice =
oxNew(
"oxprice");
807 $oBasketItem->setPrice( $oPrice );
821 $this->_blCalcDiscounts = $blCalcDiscounts;
845 foreach ( $aItemDiscounts as $sKey => $oDiscount ) {
847 if ( array_key_exists ($sKey, $aDiscounts) ) {
848 $aDiscounts[$sKey]->dDiscount += $oDiscount->dDiscount;
850 $aDiscounts[$sKey] = $oDiscount;
863 if ( $this->_oDeliveryPrice !== null ) {
867 $oDeliveryPrice =
oxNew(
'oxprice' );
869 if ( $this->
getConfig()->getConfigParam(
'blDeliveryVatOnTop' ) ) {
870 $oDeliveryPrice->setNettoPriceMode();
872 $oDeliveryPrice->setBruttoPriceMode();
878 if ( !$oUser && !
$myConfig->getConfigParam(
'blCalculateDelCostIfNotLoggedIn' ) ) {
879 return $oDeliveryPrice;
886 $oDeliveryPrice->setVat( $fDelVATPercent );
889 if (
$myConfig->getConfigParam(
'bl_perfLoadDelivery') ) {
890 $aDeliveryList =
oxRegistry::get(
"oxDeliveryList")->getDeliveryList( $this,
896 if ( count( $aDeliveryList ) > 0 ) {
897 foreach ( $aDeliveryList as $oDelivery ) {
899 if (
$myConfig->getConfigParam(
'iDebug' ) == 5 ) {
900 echo(
"DelCost : ".$oDelivery->oxdelivery__oxtitle->value.
"<br>" );
902 $oDeliveryPrice->addPrice( $oDelivery->getDeliveryPrice( $fDelVATPercent ) );
907 return $oDeliveryPrice;
917 if ( $this->_oUser == null ) {
933 $this->_oUser = $oUser;
944 if ( $this->_oProductsPriceList ) {
945 return $this->_oProductsPriceList->getMostUsedVatPercent();
958 if ( $this->_oProductsPriceList ) {
959 if ( $this->
getConfig()->getConfigParam(
'sAdditionalServVATCalcMethod') ==
'proportional') {
960 return $this->_oProductsPriceList->getProportionalVatPercent();
962 return $this->_oProductsPriceList->getMostUsedVatPercent();
976 if ( $this->
getConfig()->getConfigParam(
'sAdditionalServVATCalcMethod') ==
'proportional' ) {
994 $this->_oPrice =
oxNew(
'oxPrice' );
995 $this->_oPrice->setBruttoPriceMode();
996 $this->_oPrice->setPrice( $dprice );
1012 $this->_oPrice->subtract( $this->_oTotalDiscount->getBruttoPrice() );
1016 $this->_oPrice->subtract( $oVoucherDisc->getBruttoPrice() );
1021 if ( isset( $this->_aCosts[
'oxdelivery'] ) ) {
1022 $this->_oPrice->add( $this->_aCosts[
'oxdelivery']->getBruttoPrice() );
1026 if ( isset( $this->_aCosts[
'oxwrapping'] ) ) {
1027 $this->_oPrice->add( $this->_aCosts[
'oxwrapping']->getBruttoPrice() );
1029 if ( isset( $this->_aCosts[
'oxgiftcard'] ) ) {
1030 $this->_oPrice->add( $this->_aCosts[
'oxgiftcard']->getBruttoPrice() );
1034 if ( isset( $this->_aCosts[
'oxpayment'] ) ) {
1035 $this->_oPrice->add( $this->_aCosts[
'oxpayment']->getBruttoPrice() );
1039 if ( isset( $this->_aCosts[
'oxtsprotection'] ) ) {
1040 $this->_oPrice->add( $this->_aCosts[
'oxtsprotection']->getBruttoPrice() );
1054 $this->_oVoucherDiscount =
oxNew(
'oxPrice' );
1055 $this->_oVoucherDiscount->setBruttoPriceMode();
1056 $this->_oVoucherDiscount->add( $dDiscount );
1066 if ( $this->
getConfig()->getConfigParam(
'bl_showVouchers' ) && ($this->_oVoucherDiscount === null || ( $this->_blUpdateNeeded && !$this->
isAdmin() ) ) ) {
1071 $dPrice = $this->_oDiscountProductsPriceList->getSum( $this->
isCalculationModeNetto() ) - $this->_oTotalDiscount->getPrice();
1074 if ( count( $this->_aVouchers ) ) {
1076 foreach ( $this->_aVouchers as $sVoucherId => $oStdVoucher ) {
1077 $oVoucher =
oxNew(
'oxvoucher' );
1079 $oVoucher->load( $oStdVoucher->sVoucherId );
1081 if ( !$this->_blSkipVouchersAvailabilityChecking ) {
1082 $oVoucher->checkBasketVoucherAvailability( $this->_aVouchers, $dPrice );
1087 $dVoucherdiscount = $oVoucher->getDiscountValue( $dPrice );
1089 if ( $dVoucherdiscount > 0 ) {
1091 if ( $oVoucher->getDiscountType() ==
'absolute' ) {
1092 $dVatPart = ( $dPrice - $dVoucherdiscount ) / $dPrice * 100;
1094 $dVatPart = 100 - $oVoucher->getDiscount();
1097 if ( !$this->_aDiscountedVats ) {
1104 foreach ( $this->_aDiscountedVats as $sKey => $dVat ) {
1110 $this->_oVoucherDiscount->add( $dVoucherdiscount );
1113 $oStdVoucher->fVoucherdiscount = $oLang->formatCurrency( $dVoucherdiscount, $this->
getBasketCurrency() );
1114 $oStdVoucher->dVoucherdiscount = $dVoucherdiscount;
1117 $dPrice = $dPrice - $dVoucherdiscount;
1124 $oVoucher->unMarkAsReserved();
1125 unset( $this->_aVouchers[$sVoucherId] );
1152 foreach ( $this->_aDiscountedVats as $dVat ) {
1153 $dVatSum += $oUtils->fRound( $dVat, $this->_oCurrency);
1161 $this->
setBruttoSum($oNotDiscounted->getSum(
false) + $dDiscountedBruttoPrice + $dVatSum);
1164 $this->
setNettoSum( $oNotDiscounted->getSum() + $dDiscountedBruttoPrice - $dVatSum );
1175 $blResult = (bool) $this->
getConfig()->getConfigParam(
'blShowNetPrice');
1178 $blResult = $oUser->isPriceViewModeNetto();
1191 $oPrice =
oxNew(
'oxPrice' );
1194 $oPrice->setNettoPriceMode();
1196 $oPrice->setBruttoPriceMode();
1210 $this->_aDiscounts = array();
1216 if ( $this->_oTotalDiscount !== null && isset($this->_isForOrderRecalculation) && $this->_isForOrderRecalculation ) {
1219 $oDiscount =
oxNew(
'oxDiscount');
1220 $oDiscount->oxdiscount__oxaddsum =
new oxField( $oTotalPrice->getPrice() );
1221 $oDiscount->oxdiscount__oxaddsumtype =
new oxField(
'abs' );
1222 $aDiscounts[] = $oDiscount;
1232 foreach ( $aDiscounts as $oDiscount ) {
1235 $oStdDiscount = $oDiscount->getSimpleDiscount();
1238 if ( $oDiscount->oxdiscount__oxaddsumtype->value ==
'itm' ) {
1243 $oStdDiscount->dDiscount = $oDiscount->getAbsValue( $dOldprice );
1247 $dVatPart = 100 - $oDiscount->getPercentage( $dOldprice );
1250 if ( $dOldprice < $oStdDiscount->dDiscount ) {
1251 $oStdDiscount->dDiscount = $dOldprice;
1256 foreach ( $this->_aDiscountedVats as $sKey => $dVat ) {
1261 if ($oStdDiscount->dDiscount != 0) {
1262 $this->_aDiscounts[$oDiscount->getId()] = $oStdDiscount;
1264 $dOldprice = $dOldprice - $oStdDiscount->dDiscount;
1276 if ( $this->_oTotalDiscount === null || ( !$this->
isAdmin() ) ) {
1280 if ( is_array($this->_aDiscounts) ) {
1281 foreach ( $this->_aDiscounts as $oDiscount ) {
1284 if ( $oDiscount->sType ==
'itm' ) {
1289 $this->_oTotalDiscount->add( $oDiscount->dDiscount );
1305 $oWrappingPrices =
oxNew(
'oxPriceList' );
1307 foreach ( $this->_aBasketContents as $oBasketItem ) {
1309 if ( ( $oWrapping = $oBasketItem->getWrapping() ) ) {
1311 $oWrappingPrice = $oWrapping->getWrappingPrice( $oBasketItem->getAmount() );
1312 $oWrappingPrice->setVat( $oBasketItem->getPrice()->getVat() );
1314 $oWrappingPrices->addToPriceList( $oWrappingPrice );
1318 if ( $oWrappingPrices->getCount() ) {
1319 $oWrappingCost =
oxNew(
'oxPrice' );
1320 $oWrappingCost = $oWrappingPrices->calculateToPrice();
1323 return $oWrappingCost;
1336 $oGiftCardPrice =
oxNew(
'oxPrice' );
1338 if ( $this->
getConfig()->getConfigParam(
'blWrappingVatOnTop' ) ) {
1339 $oGiftCardPrice->setNettoPriceMode();
1341 $oGiftCardPrice->setBruttoPriceMode();
1346 $oGiftCardPrice->setVat( $dVATPercent );
1349 if ( ( $oCard = $this->
getCard() ) ) {
1350 if ($dVATPercent !== null) {
1351 $oCard->setWrappingVat($dVATPercent);
1353 $oGiftCardPrice->addPrice( $oCard->getWrappingPrice() );
1356 return $oGiftCardPrice;
1368 $oPaymentPrice =
oxNew(
'oxPrice' );
1371 if ( ( $this->_sPaymentId = $this->
getPaymentId() ) ) {
1373 $oPayment =
oxNew(
'oxpayment' );
1374 $oPayment->load( $this->_sPaymentId );
1376 $oPayment->calculate( $this );
1377 $oPaymentPrice = $oPayment->getPrice();
1380 return $oPaymentPrice;
1392 $oTsProtection =
oxNew(
'oxtsprotection');
1393 $oTsProduct = $oTsProtection->getTsProduct( $this->
getTsProductId() );
1394 $oProtectionPrice = $oTsProduct->getPrice();
1397 $oProtectionPrice =
oxNew(
'oxPrice' );
1400 return $oProtectionPrice;
1411 public function setCost( $sCostName, $oPrice = null )
1413 $this->_aCosts[$sCostName] = $oPrice;
1443 if ( $blForceUpdate ) {
1447 if ( !($this->_blUpdateNeeded || $blForceUpdate) ) {
1451 $this->_aCosts = array();
1463 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled' )) {
1464 $this->
getSession()->getBasketReservations()->reserveBasket($this);
1514 $this->_blUpdateNeeded =
true;
1524 $this->_blUpdateNeeded =
false;
1536 if ( $this->_blUpdateNeeded || $this->_aBasketSummary === null ) {
1537 $this->_aBasketSummary =
new stdclass();
1538 $this->_aBasketSummary->aArticles = array();
1539 $this->_aBasketSummary->aCategories = array();
1540 $this->_aBasketSummary->iArticleCount = 0;
1541 $this->_aBasketSummary->dArticlePrice = 0;
1542 $this->_aBasketSummary->dArticleDiscountablePrice = 0;
1550 foreach ( $this->_aBasketContents as $oBasketItem ) {
1551 if ( !$oBasketItem->isBundle() && $oArticle = $oBasketItem->getArticle(
false) ) {
1552 $aCatIds = $oArticle->getCategoryIds();
1555 $dDiscountablePrice = 0;
1556 if ( ( $oPrice = $oArticle->getBasketPrice( $oBasketItem->getAmount(), $oBasketItem->getSelList(), $this ) ) ) {
1557 $dPrice = $oPrice->getPrice();
1558 if ( !$oArticle->skipDiscounts() ) {
1559 $dDiscountablePrice = $dPrice;
1563 foreach ( $aCatIds as $sCatId ) {
1564 if ( !isset( $this->_aBasketSummary->aCategories[$sCatId] ) ) {
1565 $this->_aBasketSummary->aCategories[$sCatId] =
new stdClass();
1568 $this->_aBasketSummary->aCategories[$sCatId]->dPrice += $dPrice * $oBasketItem->getAmount();
1569 $this->_aBasketSummary->aCategories[$sCatId]->dDiscountablePrice += $dDiscountablePrice * $oBasketItem->getAmount();
1570 $this->_aBasketSummary->aCategories[$sCatId]->dAmount += $oBasketItem->getAmount();
1571 $this->_aBasketSummary->aCategories[$sCatId]->iCount++;
1575 if ( ($sParentId = $oArticle->getProductParentId()) &&
$myConfig->getConfigParam(
'blVariantParentBuyable' ) ) {
1576 if ( !isset( $this->_aBasketSummary->aArticles[$sParentId] ) ) {
1577 $this->_aBasketSummary->aArticles[$sParentId] = 0;
1579 $this->_aBasketSummary->aArticles[$sParentId] += $oBasketItem->getAmount();
1582 if ( !isset( $this->_aBasketSummary->aArticles[$oBasketItem->getProductId()] ) ) {
1583 $this->_aBasketSummary->aArticles[$oBasketItem->getProductId()] = 0;
1586 $this->_aBasketSummary->aArticles[$oBasketItem->getProductId()] += $oBasketItem->getAmount();
1587 $this->_aBasketSummary->iArticleCount += $oBasketItem->getAmount();
1588 $this->_aBasketSummary->dArticlePrice += $dPrice * $oBasketItem->getAmount();
1589 $this->_aBasketSummary->dArticleDiscountablePrice += $dDiscountablePrice * $oBasketItem->getAmount();
1611 if ( $this->_oDiscountProductsPriceList ) {
1617 $oVoucher =
oxNew(
'oxvoucher' );
1619 if ( !$this->_blSkipVouchersAvailabilityChecking ) {
1620 $oVoucher->getVoucherByNr( $sVoucherId, $this->_aVouchers,
true );
1621 $oVoucher->checkVoucherAvailability( $this->_aVouchers, $dPrice );
1623 $oVoucher->markAsReserved();
1625 $oVoucher->load( $sVoucherId );
1629 $this->_aVouchers[$oVoucher->oxvouchers__oxid->value] = $oVoucher->getSimpleVoucher();
1633 oxRegistry::get(
"oxUtilsView")->addErrorToDisplay( $oEx,
false,
true );
1649 if ( isset( $this->_aVouchers[$sVoucherId] ) ) {
1651 $oVoucher =
oxNew(
'oxvoucher' );
1652 $oVoucher->load( $sVoucherId );
1654 $oVoucher->unMarkAsReserved();
1657 unset( $this->_aVouchers[$sVoucherId] );
1684 if ( count($this->aDiscounts) > 0 ) {
1686 foreach ($this->aDiscounts as $oDiscount) {
1687 $oDiscount->fDiscount = $oLang->formatCurrency( $oDiscount->dDiscount, $this->getBasketCurrency() );
1700 $blCanSave = !$this->
getConfig()->getConfigParam(
'blPerfNoBasketSaving' );
1716 $oBasket = $oUser->getBasket(
'savedbasket' );
1719 $aSavedItems = $oBasket->getItems();
1720 foreach ( $aSavedItems as $oItem ) {
1722 $oSelList = $oItem->getSelList();
1724 $this->
addToBasket( $oItem->oxuserbasketitems__oxartid->value, $oItem->oxuserbasketitems__oxamount->value, $oSelList, $oItem->getPersParams(), true );
1743 $oSavedBasket = $oUser->getBasket(
'savedbasket' );
1744 $oSavedBasket->delete();
1747 foreach ( $this->_aBasketContents as $oBasketItem ) {
1749 if ( !$oBasketItem->isBundle() && !$oBasketItem->isDiscountArticle() ) {
1750 $oSavedBasket->addItemToBasket( $oBasketItem->getProductId(), $oBasketItem->getAmount(), $oBasketItem->getSelList(),
true, $oBasketItem->getPersParams() );
1768 $oUser->getBasket(
'savedbasket' )->delete();
1772 if ( $this->
getConfig()->getConfigParam(
'blBasketExcludeEnabled' )) {
1787 $sDelivCountry = null;
1791 $aHomeCountry =
$myConfig->getConfigParam(
'aHomeCountry' );
1792 if (
$myConfig->getConfigParam(
'blCalculateDelCostIfNotLoggedIn' ) && is_array( $aHomeCountry ) ) {
1793 $sDelivCountry = current( $aHomeCountry );
1798 if ( $sCountryId =
$myConfig->getGlobalParameter(
'delcountryid' ) ) {
1799 $sDelivCountry = $sCountryId;
1802 $oDelAdress =
oxNew(
'oxaddress' );
1803 if ( $oDelAdress->load( $sAddressId ) ) {
1804 $sDelivCountry = $oDelAdress->oxaddress__oxcountryid->value;
1809 if ( !$sDelivCountry ) {
1810 $sDelivCountry = $oUser->oxuser__oxcountryid->value;
1814 return $sDelivCountry;
1824 $this->_aBasketContents = array();
1827 if ($this->
getConfig()->getConfigParam(
'blPsBasketReservationEnabled' )) {
1828 $this->
getSession()->getBasketReservations()->discardReservations();
1844 $this->_sPaymentId = $sPaymentId;
1854 if ( !$this->_sPaymentId ) {
1869 $this->_sShippingSetId = $sShippingSetId;
1882 $this->_oDeliveryPrice = $oShippingPrice;
1892 if ( !$this->_sShippingSetId ) {
1898 if ( !$this->_sShippingSetId && $sActPaymentId !=
'oxempty' ) {
1902 list( , $sActShipSet ) =
oxRegistry::get(
"oxDeliverySetList")->getDeliverySetData( null, $oUser, $this );
1904 $this->_sShippingSetId = $sActShipSet ? $sActShipSet : ( $oUser ? null :
'oxidstandard' );
1905 } elseif ( !$this->
isAdmin() && $sActPaymentId ==
'oxempty' ) {
1907 $this->_sShippingSetId = null;
1920 $aBasketArticles = array();
1922 foreach ( $this->_aBasketContents as $sItemKey => $oBasketItem ) {
1924 $oProduct = $oBasketItem->getArticle(
true );
1926 if ( $this->
getConfig()->getConfigParam(
'bl_perfLoadSelectLists' ) ) {
1928 $aSelList = $oBasketItem->getSelList();
1929 if ( is_array( $aSelList ) && ( $aSelectlist = $oProduct->getSelectLists( $sItemKey ) ) ) {
1931 while ( list( $conkey, $iSel ) = each( $aSelList ) ) {
1932 $aSelectlist[$conkey][$iSel]->selected = 1;
1934 $oProduct->setSelectlist( $aSelectlist );
1949 $aBasketArticles[$sItemKey] = $oProduct;
1951 return $aBasketArticles;
1971 if ( is_null($this->_oProductsPriceList) ) {
1972 $this->_oProductsPriceList =
oxNew(
'oxPriceList' );
1985 if ( is_null($this->_oPrice) ) {
1986 $this->_oPrice =
oxNew(
'oxprice' );
2012 $this->_sOrderId = $sId;
2027 return isset( $this->_aCosts[$sId] )?$this->_aCosts[$sId]:null;
2091 if ( !$this->_oNotDiscountedProductsPriceList ) {
2098 foreach ( $this->_aDiscountedVats as $sKey => $dVat ) {
2099 if ( !isset( $aVats[$sKey] ) ) {
2103 $aVats[$sKey] += $oUtils->fRound( $dVat, $this->_oCurrency );
2106 if ( $blFormatCurrency ) {
2108 foreach ( $aVats as $sKey => $dVat ) {
2125 if ( $this->_oNotDiscountedProductsPriceList ) {
2126 return $this->_dDiscountedProductNettoPrice + $this->_oNotDiscountedProductsPriceList->getNettoSum();
2140 $this->_sCardMessage = $sMessage;
2150 return $this->_sCardMessage;
2162 $this->_sCardId = $sCardId;
2172 return $this->_sCardId;
2184 $oCard =
oxNew(
'oxwrapping' );
2185 $oCard->load( $sCardId );
2212 return array_merge($this->_aItemDiscounts, $this->_aDiscounts);
2222 if ($this->
getConfig()->getConfigParam(
'bl_showVouchers' )) {
2237 $this->_oCurrency = $oCurrency;
2247 if ( $this->_oCurrency === null ) {
2248 $this->_oCurrency = $this->
getConfig()->getActShopCurrencyObject();
2263 $this->_blSkipVouchersAvailabilityChecking = $blSkipChecking;
2285 $this->_blSkipDiscounts = $blSkip;
2321 return $this->
getCosts(
'oxdelivery' )->getVat();
2333 $dDelVAT = $this->
getCosts(
'oxdelivery' )->getVatValue();
2336 if ( $dDelVAT > 0 && $this->
getConfig()->getConfigParam(
'blShowVATForDelivery' )) {
2354 if ( $oConfig->getConfigParam(
'blShowVATForDelivery' ) && ( $this->
getBasketUser() || $oConfig->getConfigParam(
'blCalculateDelCostIfNotLoggedIn' ) ) ) {
2355 $dNetPrice = $this->
getCosts(
'oxdelivery' )->getNettoPrice();
2356 if ( $dNetPrice > 0 ) {
2372 return $this->
getCosts(
'oxpayment' )->getVat();
2384 $dPayVAT = $this->
getCosts(
'oxpayment' )->getVatValue();
2387 if ( $dPayVAT > 0 && $this->
getConfig()->getConfigParam(
'blShowVATForPayCharge' ) ) {
2403 if ( $this->
getConfig()->getConfigParam(
'blShowVATForPayCharge' ) ) {
2404 $oPaymentCost = $this->
getCosts(
'oxpayment' );
2405 if ( $oPaymentCost && $oPaymentCost->getNettoPrice() ) {
2421 $oPaymentCost = $this->
getCosts(
'oxpayment' );
2422 if ( $oPaymentCost && $oPaymentCost->getBruttoPrice() ) {
2423 return $oPaymentCost->getBruttoPrice();
2434 return $this->
getCosts(
'oxpayment' );
2446 $oPaymentCost = $this->
getCosts(
'oxpayment' );
2447 if ( $oPaymentCost && $oPaymentCost->getBruttoPrice() ) {
2476 if ( $oVoucherDiscount->getBruttoPrice() ) {
2493 return $this->
getCosts(
'oxwrapping' )->getVat();
2506 return $this->
getCosts(
'oxgiftcard' )->getVat();
2519 if ( $this->
getConfig()->getConfigParam(
'blShowVATForWrapping' ) ) {
2520 $oPrice = $this->
getCosts(
'oxwrapping' );
2522 if ( $oPrice && $oPrice->getVatValue() > 0 ) {
2540 if ( $this->
getConfig()->getConfigParam(
'blShowVATForWrapping' ) ) {
2541 $oPrice = $this->
getCosts(
'oxwrapping' );
2543 if ( $oPrice && $oPrice->getNettoPrice() > 0 ) {
2560 $oPrice = $this->
getCosts(
'oxwrapping' );
2562 if ( $oPrice && $oPrice->getBruttoPrice() ) {
2576 return $this->
getCosts(
'oxwrapping' );
2589 if ( $this->
getConfig()->getConfigParam(
'blShowVATForWrapping' ) ) {
2590 $oPrice = $this->
getCosts(
'oxgiftcard' );
2592 if ( $oPrice && $oPrice->getVatValue() > 0 ) {
2611 if ( $this->
getConfig()->getConfigParam(
'blShowVATForWrapping' ) ) {
2612 $oPrice = $this->
getCosts(
'oxgiftcard' );
2614 if ( $oPrice && $oPrice->getNettoPrice() > 0 ) {
2631 $oPrice = $this->
getCosts(
'oxgiftcard' );
2633 if ( $oPrice && $oPrice->getBruttoPrice() ) {
2646 return $this->
getCosts(
'oxgiftcard' );
2670 $oPrice = $this->
getCosts(
'oxdelivery' );
2672 if ( $oPrice && ( $this->
getBasketUser() || $this->
getConfig()->getConfigParam(
'blCalculateDelCostIfNotLoggedIn' ) ) ) {
2687 if ( $oDeliveryCost = $this->
getCosts(
'oxdelivery' ) ) {
2688 return $oDeliveryCost->getBruttoPrice();
2700 return $this->
getCosts(
'oxdelivery' );
2712 $this->_oTotalDiscount =
oxNew(
'oxPrice' );
2713 $this->_oTotalDiscount->setBruttoPriceMode();
2714 $this->_oTotalDiscount->add( $dDiscount );
2728 $dPrice += $oPriceList->getBruttoSum();
2732 if ( $oDeliveryPrice = $this->_aCosts[
'oxdelivery'] ) {
2733 $dPrice += $oDeliveryPrice->getBruttoPrice();
2753 $dPrice -= $oPrice->getPrice();
2757 $dPrice -= $oVoucherPrice->getPrice();
2771 $dPrice = $oProductsPrice->getBruttoSum();
2776 $dPrice -= $oPrice->getBruttoPrice();
2780 $dPrice -= $oVoucherPrice->getBruttoPrice();
2793 $blIsBelowMinOrderPrice =
false;
2794 $sConfValue = $this->
getConfig()->getConfigParam(
'iMinOrderPrice' );
2797 $dNotDiscountedProductPrice = 0;
2799 $dNotDiscountedProductPrice = $oPrice->getBruttoSum();
2804 return $blIsBelowMinOrderPrice;
2819 foreach ( $this->_aBasketContents as $sItemKey => $oOrderArticle ) {
2820 if ( $oOrderArticle && ( $sExpiredArtId == null || $sExpiredArtId != $sItemKey ) ) {
2821 if ( $oOrderArticle->getArticle(
true )->getId() == $sArtId ) {
2822 $dArtStock += $oOrderArticle->getAmount();
2842 if ( $this->_sBasketCategoryId === null ) {
2846 if ( $oView = $this->
getConfig()->getActiveView() ) {
2847 if ( $oCat = $oView->getActiveCategory() ) {
2858 $oProduct =
oxNew(
"oxarticle" );
2859 if ( $oProduct->load( $sProductId ) ) {
2860 $oCat = $oProduct->getCategory();
2871 if ( $blCanAdd === null ) {
2888 $sO2CTable = getViewName(
'oxobject2category' );
2889 $sCatTable = getViewName(
'oxcategories' );
2892 $sParentId = $oDb->getOne(
"select oxparentid from oxarticles where oxid = ".$oDb->quote( $sProductId ) );
2893 $sProductId = $sParentId ? $sParentId : $sProductId;
2895 $sQ =
"select 1 from {$sO2CTable}
2896 left join {$sCatTable} on {$sCatTable}.oxid = {$sO2CTable}.oxcatnid
2897 where {$sO2CTable}.oxobjectid = ".$oDb->quote( $sProductId ).
" and
2898 {$sCatTable}.oxrootid = ".$oDb->quote( $sRootCatId );
2900 return (
bool) $oDb->getOne( $sQ );
2912 $this->_sBasketCategoryId = $sRoot;
2934 $this->_blShowCatChangeWarning = $blShow;
2956 $this->_sTsProductId = $sProductId;
2978 $oProtectionCost = $this->
getCosts(
'oxtsprotection' );
2979 if ( $oProtectionCost && $oProtectionCost->getBruttoPrice() ) {
2994 return $this->
getCosts(
'oxtsprotection' )->getVat();
3006 $dProtectionVAT = $this->
getCosts(
'oxtsprotection' )->getVatValue();
3008 if ( $dProtectionVAT > 0 && $this->
getConfig()->getConfigParam(
'blShowVATForPayCharge' ) ) {
3024 if ( $this->
getConfig()->getConfigParam(
'blShowVATForPayCharge' ) ) {
3039 $oProtection = $this->
getCosts(
'oxtsprotection' );
3040 if ( $oProtection ) {
3041 return $oProtection->getBruttoPrice();
3053 return $this->
getCosts(
'oxtsprotection' );
3080 protected function _addedNewItem( $sProductID, $dAmount, $aSel, $aPersParam, $blOverride, $blBundle, $sOldBasketItemId )
3082 if ( !$blOverride ) {
3083 $this->_blNewITemAdded = null;
3095 $this->_blNewITemAdded = null;
3096 $this->_isCalculationModeNetto = null;
3106 if ( $this->_blNewITemAdded == null ) {
3120 $this->_blDownloadableProducts =
false;
3122 foreach ( $this->_aBasketContents as $oBasketItem ) {
3123 if ( $oBasketItem->getArticle(
false) && $oBasketItem->getArticle(
false)->isDownloadable() ) {
3124 $this->_blDownloadableProducts =
true;
3139 $blHasArticlesWithIntangibleAgreement =
false;
3142 foreach ($this->_aBasketContents as $oBasketItem) {
3143 if ($oBasketItem->getArticle(
false) && $oBasketItem->getArticle(
false)->hasIntangibleAgreement()) {
3144 $blHasArticlesWithIntangibleAgreement =
true;
3149 return $blHasArticlesWithIntangibleAgreement;
3159 $blHasArticlesWithIntangibleAgreement =
false;
3162 foreach ($this->_aBasketContents as $oBasketItem) {
3163 if ($oBasketItem->getArticle(
false) && $oBasketItem->getArticle(
false)->hasDownloadableAgreement()) {
3164 $blHasArticlesWithIntangibleAgreement =
true;
3169 return $blHasArticlesWithIntangibleAgreement;