55 if ($oConfig->getConfigParam(
'blPsBasketReservationEnabled')) {
56 if ($oReservations = $this->
getSession()->getBasketReservations()) {
57 if (!$oReservations->getTimeLeft()) {
59 if ($oBasket && $oBasket->getProductsCount()) {
60 $oBasket->deleteBasket();
63 $iLimit = (int) $oConfig->getConfigParam(
'iBasketReservationCleanPerRequest');
67 $oReservations->discardUnusedReservations($iLimit);
74 if ($this->
getConfig()->getConfigParam(
'blBasketExcludeEnabled')) {
75 if ($oBasket = $this->
getSession()->getBasket()) {
90 if ($oBasket = $this->
getSession()->getBasket()) {
91 $oBasket->calculateBasket(
false);
114 public function tobasket($sProductId = null, $dAmount = null, $aSel = null, $aPersParam = null, $blOverride =
false)
123 if ($aProducts = $this->
_getItems($sProductId, $dAmount, $aSel, $aPersParam, $blOverride)) {
128 $database->startTransaction();
130 $oBasketItem = $this->
_addItems($aProducts);
137 $database->rollbackTransaction();
141 $database->commitTransaction();
144 if ($oBasketItem &&
$myConfig->getConfigParam(
'iNewBasketItemMessage') != 0) {
145 $oNewItem =
new stdClass();
146 $oNewItem->sTitle = $oBasketItem->getTitle();
147 $oNewItem->sId = $oBasketItem->getProductId();
148 $oNewItem->dAmount = $oBasketItem->getAmount();
149 $oNewItem->dBundledAmount = $oBasketItem->getdBundledAmount();
192 if ($sBasketItemId) {
195 $aBasketContents = $oBasket->getContents();
196 $oItem = $aBasketContents[$sBasketItemId];
198 $sProductId = isset($oItem) ? $oItem->getProductId() : null;
210 if ($aProducts = $this->
_getItems($sProductId, $dAmount, $aSel, $aPersParam, $blOverride)) {
214 $oBasket->onUpdate();
219 $database->startTransaction();
221 $oBasketItem = $this->
_addItems($aProducts);
227 $database->rollbackTransaction();
231 $database->commitTransaction();
247 $sClass = $sClass ? $sClass .
'?' :
'start?';
251 foreach ($this->aRedirectParams as $sParamName) {
253 $sPosition .= $sParamVal ? $sParamName .
'=' . $sParamVal .
'&' :
'';
259 $sPosition .= $sParam ?
'searchparam=' . $sParam .
'&' :
'';
263 $sPosition .= ($iPageNr > 0) ?
'pgNr=' . $iPageNr .
'&' :
'';
266 if ($this->
getConfig()->getConfigParam(
'iNewBasketItemMessage') == 3) {
275 return $sClass . $sPosition;
311 if (empty($aPersParam)) {
313 if (!is_array($aPersParam) || empty($aPersParam[
'details'])) {
320 $aProducts[$sProductId] = array(
'am' => $dAmount,
322 'persparam' => $aPersParam,
323 'override' => $blOverride,
324 'basketitemid' => $sBasketItemId
328 if (is_array($aProducts) && count($aProducts)) {
332 foreach ($aProducts as $sProductId => $aProduct) {
333 if (isset($aProduct[
'remove']) && $aProduct[
'remove']) {
334 $aProducts[$sProductId][
'am'] = 0;
336 unset ($aProducts[$sProductId]);
357 $oActView = $this->
getConfig()->getActiveView();
358 $sErrorDest = $oActView->getErrorDestination();
361 $oBasketInfo = $oBasket->getBasketSummary();
363 $basketItemAmounts = array();
365 foreach ($aProducts as $sAddProductId => $aProductInfo) {
367 $sProductId = isset($aProductInfo[
'aid']) ? $aProductInfo[
'aid'] : $sAddProductId;
370 $oProduct = $oBasketInfo->aArticles[$sProductId];
371 $aProducts[$sAddProductId][
'oldam'] = isset($oProduct) ? $oProduct : 0;
373 $dAmount = isset($aProductInfo[
'am']) ? $aProductInfo[
'am'] : 0;
374 $aSelList = isset($aProductInfo[
'sel']) ? $aProductInfo[
'sel'] : null;
375 $aParams = $aProductInfo[
'persparam'];
376 $aPersParam = (isset($aParams) && is_array($aParams) && strlen($aParams[
'details'])) ? $aParams : null;
377 $blOverride = isset($aProductInfo[
'override']) ? $aProductInfo[
'override'] : null;
378 $blIsBundle = isset($aProductInfo[
'bundle']) ?
true :
false;
379 $sOldBasketItemId = isset($aProductInfo[
'basketitemid']) ? $aProductInfo[
'basketitemid'] : null;
385 if (isset($basketItemAmounts[$sOldBasketItemId])) {
386 $dAmount = $dAmount + $basketItemAmounts[$sOldBasketItemId];
389 $oBasketItem = $oBasket->addToBasket(
399 if (is_a($oBasketItem,
'oxBasketItem')) {
400 $basketItemId = $oBasketItem->getBasketItemKey();
402 if (!empty($basketItemId)) {
403 $basketItemAmounts[$basketItemId] += $dAmount;
409 if (!$sErrorDest && $this->
getConfig()->getConfigParam(
'iNewBasketItemMessage') == 2) {
410 $sErrorDest =
'popup';
412 oxRegistry::get(
"oxUtilsView")->addErrorToDisplay($oEx,
false, (
bool) $sErrorDest, $sErrorDest);
416 oxRegistry::get(
"oxUtilsView")->addErrorToDisplay($oEx,
false, (
bool) $sErrorDest, $sErrorDest);
421 $oInfo = $oBasket->getBasketSummary();
422 $oProduct = $oInfo->aArticles[$sProductId];
423 $aProducts[$sAddProductId][
'am'] = isset($oProduct) ? $oProduct : 0;
428 if ($oBasket->getProductsCount() == 0) {
429 $oBasket->setCardId(null);
445 protected function _setLastCall($sCallName, $aProductInfo, $aBasketInfo)
457 $this->_sLastCallFnc = $sCallName;
479 if ($oBasket->showCatChangeWarning()) {
480 $oBasket->setCatChangeWarningState(
false);
488 $oActCat = oxnew(
'oxcategory');
489 if ($sActCat && $sActCat != $sDefCat && $oActCat->load($sActCat)) {
490 $sActRoot = $oActCat->oxcategories__oxrootid->value;
491 if ($oBasket->getBasketRootCatId() && $sActRoot != $oBasket->getBasketRootCatId()) {
515 $this->
getSession()->getBasket()->deleteBasket();
516 $this->
getParent()->setRootCatChanged(
false);