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
00093
00094 return $this->_sThisTemplate;
00095 }
00096
00102 public function getBasketArticles()
00103 {
00104 if ( $this->_oBasketArticles === null) {
00105 $this->_oBasketArticles = false;
00106
00107
00108 if ( $oBasket = $this->getSession()->getBasket() ) {
00109 $this->_oBasketArticles = $oBasket->getBasketArticles();
00110 }
00111 }
00112 return $this->_oBasketArticles;
00113 }
00114
00120 public function getFirstBasketProduct()
00121 {
00122 if ( $this->_oFirstBasketProduct === null ) {
00123 $this->_oFirstBasketProduct = false;
00124
00125 $aBasketArticles = $this->getBasketArticles();
00126 if ( is_array( $aBasketArticles ) && $oProduct = reset( $aBasketArticles ) ) {
00127 $this->_oFirstBasketProduct = $oProduct;
00128 }
00129 }
00130 return $this->_oFirstBasketProduct;
00131 }
00132
00138 public function getBasketSimilarList()
00139 {
00140 if ( $this->_oSimilarList === null) {
00141 $this->_oSimilarList = false;
00142
00143
00144 if ( $oProduct = $this->getFirstBasketProduct() ) {
00145 $this->_oSimilarList = $oProduct->getSimilarProducts();
00146 }
00147 }
00148 return $this->_oSimilarList;
00149 }
00150
00156 public function getSimilarRecommLists()
00157 {
00158 if ( $this->_oRecommList === null) {
00159 $this->_oRecommList = false;
00160
00161 if ( $oProduct = $this->getFirstBasketProduct() ) {
00162 $oRecommList = oxNew('oxrecommlist');
00163 $this->_oRecommList = $oRecommList->getRecommListsByIds( array( $oProduct->getId() ) );
00164 }
00165 }
00166 return $this->_oRecommList;
00167 }
00168
00169
00175 public function addVoucher()
00176 {
00177 $oBasket = $this->getSession()->getBasket();
00178 $oBasket->addVoucher( oxConfig::getParameter( 'voucherNr' ) );
00179 }
00180
00186 public function removeVoucher()
00187 {
00188 $oBasket = $this->getSession()->getBasket();
00189 $oBasket->removeVoucher( oxConfig::getParameter( 'voucherId' ) );
00190 }
00191
00192 }