00001 <?php
00002
00009 class Basket extends oxUBase
00010 {
00016 protected $_sThisTemplate = 'basket.tpl';
00017
00023 protected $_sThisAltTemplate = 'impressum.tpl';
00024
00030 protected $_blIsOrderStep = true;
00031
00037 protected $_oBasketArticles = null;
00038
00044 protected $_oSimilarList = null;
00045
00051 protected $_oRecommList = null;
00052
00059 protected $_oFirstBasketProduct = null;
00060
00067 protected $_iViewIndexState = 1;
00068
00079 public function render()
00080 {
00081
00082 if ( oxUtils::getInstance()->isSearchEngine() ) {
00083 return $this->_sThisTemplate = $this->_sThisAltTemplate;
00084 }
00085
00086 parent::render();
00087
00088
00089 $this->_aViewData['basketitemlist'] = $this->getBasketArticles();
00090 $this->_aViewData['basketsimilarlist'] = $this->getBasketSimilarList();
00091 $this->_aViewData['similarrecommlist'] = $this->getSimilarRecommLists();
00092 $this->_aViewData['showbacktoshop'] = $this->showBackToShop();
00093
00094
00095 return $this->_sThisTemplate;
00096 }
00097
00103 public function getBasketArticles()
00104 {
00105 if ( $this->_oBasketArticles === null) {
00106 $this->_oBasketArticles = false;
00107
00108
00109 if ( $oBasket = $this->getSession()->getBasket() ) {
00110 $this->_oBasketArticles = $oBasket->getBasketArticles();
00111 }
00112 }
00113 return $this->_oBasketArticles;
00114 }
00115
00121 public function getFirstBasketProduct()
00122 {
00123 if ( $this->_oFirstBasketProduct === null ) {
00124 $this->_oFirstBasketProduct = false;
00125
00126 $aBasketArticles = $this->getBasketArticles();
00127 if ( is_array( $aBasketArticles ) && $oProduct = reset( $aBasketArticles ) ) {
00128 $this->_oFirstBasketProduct = $oProduct;
00129 }
00130 }
00131 return $this->_oFirstBasketProduct;
00132 }
00133
00139 public function getBasketSimilarList()
00140 {
00141 if ( $this->_oSimilarList === null) {
00142 $this->_oSimilarList = false;
00143
00144
00145 if ( $oProduct = $this->getFirstBasketProduct() ) {
00146 $this->_oSimilarList = $oProduct->getSimilarProducts();
00147 }
00148 }
00149 return $this->_oSimilarList;
00150 }
00151
00157 public function getSimilarRecommLists()
00158 {
00159 if ( $this->_oRecommList === null) {
00160 $this->_oRecommList = false;
00161
00162 if ( $oProduct = $this->getFirstBasketProduct() ) {
00163 $oRecommList = oxNew('oxrecommlist');
00164 $this->_oRecommList = $oRecommList->getRecommListsByIds( array( $oProduct->getId() ) );
00165 }
00166 }
00167 return $this->_oRecommList;
00168 }
00169
00175 public function showBackToShop()
00176 {
00177 return ( $this->getConfig()->getConfigParam( 'iNewBasketItemMessage' ) == 3 && oxSession::hasVar( '_backtoshop' ) );
00178 }
00179
00185 public function addVoucher()
00186 {
00187 $oBasket = $this->getSession()->getBasket();
00188 $oBasket->addVoucher( oxConfig::getParameter( 'voucherNr' ) );
00189 }
00190
00196 public function removeVoucher()
00197 {
00198 $oBasket = $this->getSession()->getBasket();
00199 $oBasket->removeVoucher( oxConfig::getParameter( 'voucherId' ) );
00200 }
00201
00209 public function backToShop()
00210 {
00211 if ( $this->getConfig()->getConfigParam( 'iNewBasketItemMessage' ) == 3 ) {
00212 if ( $sBackLink = oxSession::getVar( '_backtoshop' ) ) {
00213 oxSession::deleteVar( '_backtoshop' );
00214 return $sBackLink;
00215 }
00216 }
00217 }
00218 }