thankyou.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class Thankyou extends oxUBase
00008 {
00013     protected $_oBasket = null;
00014 
00019     protected $_blShowFinalStep = null;
00020 
00025     protected $_aLastProducts = null;
00026 
00031     protected $_dConvIndex = null;
00032 
00037     protected $_dIPaymentBasket = null;
00038 
00043     protected $_sIPaymentAccount = null;
00044 
00049     protected $_sIPaymentUser = null;
00050 
00055     protected $_sIPaymentPassword = null;
00056 
00061     protected $_sMailError = null;
00062 
00067     protected $_blTop5Action = true;
00068 
00073     protected $_blBargainAction = true;
00074 
00079     protected $_sThisTemplate = 'page/checkout/thankyou.tpl';
00080 
00089     public function init()
00090     {
00091         parent::init();
00092 
00093         // get basket we might need some information from it here
00094         $oBasket = $this->getSession()->getBasket();
00095         $oBasket->setOrderId( oxSession::getVar( 'sess_challenge' ) );
00096 
00097         // copying basket object
00098         $this->_oBasket = clone $oBasket;
00099 
00100         // delete it from the session
00101         $oBasket->deleteBasket();
00102         oxSession::deleteVar( 'sess_challenge' );
00103     }
00104 
00112     public function render()
00113     {
00114         if ( !$this->_oBasket || !$this->_oBasket->getProductsCount() ) {
00115             oxUtils::getInstance()->redirect( $this->getConfig()->getShopHomeURL().'&cl=start', true, 302 );
00116         }
00117 
00118         parent::render();
00119 
00120         $oUser = $this->getUser();
00121 
00122         // removing also unregistered user info (#2580)
00123         if ( !$oUser || !$oUser->oxuser__oxpassword->value) {
00124             oxSession::deleteVar( 'usr' );
00125             oxSession::deleteVar( 'dynvalue' );
00126         }
00127 
00128         // loading order sometimes needed in template
00129         if ( $this->_oBasket->getOrderId() ) {
00130             // owners stock reminder
00131             $oEmail = oxNew( 'oxemail' );
00132             $oEmail->sendStockReminder( $this->_oBasket->getContents() );
00133         }
00134 
00135         // we must set active class as start
00136         $this->getViewConfig()->setViewConfigParam( 'cl', 'start' );
00137 
00138         return $this->_sThisTemplate;
00139     }
00140 
00146     public function getBasket()
00147     {
00148         return $this->_oBasket;
00149     }
00150 
00156     public function showFinalStep()
00157     {
00158         if ( $this->_blShowFinalStep === null ) {
00159             $this->_blShowFinalStep = false;
00160             if ( $this->getConfig()->getConfigParam( 'blShowFinalStep' ) ) {
00161                 $this->_blShowFinalStep = true;
00162             }
00163         }
00164         return $this->_blShowFinalStep;
00165     }
00166 
00172     public function getAlsoBoughtTheseProducts()
00173     {
00174         if ( $this->_aLastProducts === null ) {
00175             $this->_aLastProducts = false;
00176             // 5th order step
00177             if ( $this->showFinalStep() ) {
00178                 $aBasketContents = array_values($this->getBasket()->getContents());
00179                 if ( $oBasketItem = $aBasketContents[0] ) {
00180                     if ( $oProduct = $oBasketItem->getArticle(false) ) {
00181                         $this->_aLastProducts = $oProduct->getCustomerAlsoBoughtThisProducts();
00182                     }
00183                 }
00184             }
00185         }
00186         return $this->_aLastProducts;
00187     }
00188 
00194     public function getCurrencyCovIndex()
00195     {
00196         if ( $this->_dConvIndex === null ) {
00197             // currency conversion index value
00198             $oCur = $this->getConfig()->getActShopCurrencyObject();
00199             $this->_dConvIndex = 1 / $oCur->rate;
00200         }
00201         return $this->_dConvIndex;
00202     }
00203 
00209     public function getIPaymentBasket()
00210     {
00211         if ( $this->_dIPaymentBasket === null ) {
00212             $this->_dIPaymentBasket = $this->getBasket()->getPrice()->getBruttoPrice() * 100;
00213         }
00214         return $this->_dIPaymentBasket;
00215     }
00216 
00222     public function getIPaymentAccount()
00223     {
00224         if ( $this->_sIPaymentAccount === null ) {
00225             $this->_sIPaymentAccount = false;
00226             $this->_sIPaymentAccount = $this->getConfig()->getConfigParam( 'iShopID_iPayment_Account' );
00227         }
00228         return $this->_sIPaymentAccount;
00229     }
00230 
00236     public function getIPaymentUser()
00237     {
00238         if ( $this->_sIPaymentUser === null ) {
00239             $this->_sIPaymentUser = false;
00240             $this->_sIPaymentUser = $this->getConfig()->getConfigParam( 'iShopID_iPayment_User' );
00241         }
00242         return $this->_sIPaymentUser;
00243     }
00244 
00250     public function getIPaymentPassword()
00251     {
00252         if ( $this->_sIPaymentPassword === null ) {
00253             $this->_sIPaymentPassword = false;
00254             $this->_sIPaymentPassword = $this->getConfig()->getConfigParam( 'iShopID_iPayment_Passwort' );
00255         }
00256         return $this->_sIPaymentPassword;
00257     }
00258 
00264     public function getMailError()
00265     {
00266         if ( $this->_sMailError === null ) {
00267             $this->_sMailError = false;
00268             $this->_sMailError = oxConfig::getParameter( 'mailerror' );
00269         }
00270         return $this->_sMailError;
00271     }
00272 
00278     public function getOrder()
00279     {
00280         if ( $this->_oOrder === null ) {
00281             $this->_oOrder = oxNew( 'oxorder' );
00282             // loading order sometimes needed in template
00283             if ( $sOrderId = $this->getBasket()->getOrderId() ) {
00284                 $this->_oOrder->load( $sOrderId );
00285             }
00286         }
00287         return $this->_oOrder;
00288     }
00289 
00295     public function getCountryISO3()
00296     {
00297         $oOrder = $this->getOrder();
00298         if ( $oOrder ) {
00299             $oCountry = oxNew( 'oxcountry' );
00300             $oCountry->load( $oOrder->oxorder__oxbillcountryid->value );
00301             return $oCountry->oxcountry__oxisoalpha3->value;
00302         }
00303     }
00304 
00311     public function getActionClassName()
00312     {
00313         return 'start';
00314     }
00315 
00321     public function getBreadCrumb()
00322     {
00323         $aPaths = array();
00324         $aPath = array();
00325 
00326 
00327         $aPath['title'] = oxLang::getInstance()->translateString( 'PAGE_CHECKOUT_THANKYOU', oxLang::getInstance()->getBaseLanguage(), false );
00328         $aPath['link']  = $this->getLink();
00329         $aPaths[] = $aPath;
00330 
00331         return $aPaths;
00332     }
00333 
00334 }