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->getViewConfig()->getShowListmania()) {
00159             return false;
00160         }
00161 
00162         if ( $this->_oRecommList === null) {
00163             $this->_oRecommList = false;
00164 
00165             if ( $oProduct = $this->getFirstBasketProduct() ) {
00166                 $oRecommList = oxNew('oxrecommlist');
00167                 $this->_oRecommList = $oRecommList->getRecommListsByIds( array( $oProduct->getId() ) );
00168             }
00169         }
00170         return $this->_oRecommList;
00171     }
00172 
00178     public function showBackToShop()
00179     {
00180         return ( $this->getConfig()->getConfigParam( 'iNewBasketItemMessage' ) == 3 && oxSession::hasVar( '_backtoshop' ) );
00181     }
00182 
00188     public function addVoucher()
00189     {
00190         if (!$this->getViewConfig()->getShowVouchers()) {
00191             return;
00192         }
00193 
00194         $oBasket = $this->getSession()->getBasket();
00195         $oBasket->addVoucher( oxConfig::getParameter( 'voucherNr' ) );
00196     }
00197 
00203     public function removeVoucher()
00204     {
00205         if (!$this->getViewConfig()->getShowVouchers()) {
00206             return;
00207         }
00208 
00209         $oBasket = $this->getSession()->getBasket();
00210         $oBasket->removeVoucher( oxConfig::getParameter( 'voucherId' ) );
00211     }
00212 
00220     public function backToShop()
00221     {
00222         if ( $this->getConfig()->getConfigParam( 'iNewBasketItemMessage' ) == 3 ) {
00223             if ( $sBackLink = oxSession::getVar( '_backtoshop' ) ) {
00224                 oxSession::deleteVar( '_backtoshop' );
00225                 return $sBackLink;
00226             }
00227         }
00228     }
00229 
00235     public function getErrorDestination()
00236     {
00237         return 'basket';
00238     }
00239 }

Generated by  doxygen 1.6.2