basket.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class Basket extends oxUBase
00010 {
00016     protected $_sThisTemplate = 'basket.tpl';
00017 
00023     protected $_sThisAltTemplate = 'content.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 
00066     protected $_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
00067 
00078     public function render()
00079     {
00080         parent::render();
00081 
00082         // checks if current http client is SE and skips basket preview on success
00083         if ( oxUtils::getInstance()->isSearchEngine() ) {
00084             return $this->_sThisTemplate = $this->_sThisAltTemplate;
00085         }
00086 
00087         //for older templates
00088         $this->_aViewData['basketitemlist']    = $this->getBasketArticles();
00089         $this->_aViewData['basketsimilarlist'] = $this->getBasketSimilarList();
00090         $this->_aViewData['similarrecommlist'] = $this->getSimilarRecommLists();
00091         $this->_aViewData['showbacktoshop']    = $this->showBackToShop();
00092 
00093 
00094         return $this->_sThisTemplate;
00095     }
00096 
00102     public function getBasketArticles()
00103     {
00104         if ( $this->_oBasketArticles === null) {
00105             $this->_oBasketArticles = false;
00106 
00107             // passing basket articles
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             // similar product info
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 
00174     public function showBackToShop()
00175     {
00176         return ( $this->getConfig()->getConfigParam( 'iNewBasketItemMessage' ) == 3 && oxSession::hasVar( '_backtoshop' ) );
00177     }
00178 
00184     public function addVoucher()
00185     {
00186         $oBasket = $this->getSession()->getBasket();
00187         $oBasket->addVoucher( oxConfig::getParameter( 'voucherNr' ) );
00188     }
00189 
00195     public function removeVoucher()
00196     {
00197         $oBasket = $this->getSession()->getBasket();
00198         $oBasket->removeVoucher( oxConfig::getParameter( 'voucherId' ) );
00199     }
00200 
00208     public function backToShop()
00209     {
00210         if ( $this->getConfig()->getConfigParam( 'iNewBasketItemMessage' ) == 3 ) {
00211             if ( $sBackLink = oxSession::getVar( '_backtoshop' ) ) {
00212                 oxSession::deleteVar( '_backtoshop' );
00213                 return $sBackLink;
00214             }
00215         }
00216     }
00217 }

Generated on Wed Apr 22 12:26:31 2009 for OXID eShop CE by  doxygen 1.5.5