wrapping.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class Wrapping extends oxUBase
00007 {
00013     protected $_sThisTemplate = 'page/checkout/wrapping.tpl';
00014 
00020     protected $_aBasketItemList = null;
00021 
00027     protected $_oWrappings = null;
00028 
00034     protected $_oCards = null;
00035 
00041     public function getBasketItems()
00042     {
00043         if ( $this->_aBasketItemList === null ) {
00044             $this->_aBasketItemList = false;
00045 
00046             // passing basket articles
00047             if ( $oBasket = $this->getSession()->getBasket() ) {
00048                 $this->_aBasketItemList = $oBasket->getBasketArticles();
00049             }
00050         }
00051 
00052         return $this->_aBasketItemList;
00053     }
00054 
00060     public function getWrappingList()
00061     {
00062         if ( $this->_oWrappings === null ) {
00063             $this->_oWrappings = new oxlist();
00064 
00065             // load wrapping papers
00066             if ( $this->getViewConfig()->getShowGiftWrapping() ) {
00067                 $this->_oWrappings = oxNew( 'oxwrapping' )->getWrappingList( 'WRAP' );
00068             }
00069         }
00070         return $this->_oWrappings;
00071     }
00072 
00078     public function getCardList()
00079     {
00080         if ( $this->_oCards === null ) {
00081             $this->_oCards = new oxlist();
00082 
00083             // load gift cards
00084             if ( $this->getViewConfig()->getShowGiftWrapping() ) {
00085                 $this->_oCards = oxNew( 'oxwrapping' )->getWrappingList( 'CARD' );
00086             }
00087         }
00088 
00089         return $this->_oCards;
00090     }
00091 
00103     public function changeWrapping()
00104     {
00105         $aWrapping = oxConfig::getParameter( 'wrapping' );
00106 
00107         if ( $this->getViewConfig()->getShowGiftWrapping() ) {
00108             $oBasket = $this->getSession()->getBasket();
00109             // setting wrapping info
00110             if ( is_array( $aWrapping ) && count( $aWrapping ) ) {
00111                 foreach ( $oBasket->getContents() as $sKey => $oBasketItem ) {
00112                     // wrapping ?
00113                     if ( isset( $aWrapping[$sKey] ) ) {
00114                         $oBasketItem->setWrapping( $aWrapping[$sKey] );
00115                     }
00116                 }
00117             }
00118 
00119             $oBasket->setCardMessage( oxConfig::getParameter( 'giftmessage' ) );
00120             $oBasket->setCardId( oxConfig::getParameter( 'chosencard' ) );
00121             $oBasket->onUpdate();
00122 
00123         }
00124 
00125         return 'order';
00126     }
00127 }