idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
36,600 | public function generateVoucher ( $ iCnt ) { $ iAmount = abs ( ( int ) \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> getVariable ( "voucherAmount" ) ) ; if ( $ iCnt < $ iAmount && ( $ oVoucherSerie = $ this -> _getVoucherSerie ( ) ) ) { if ( ! $ this -> _iGenerated ) { $ this -> _iGenerated = $ iCnt ; } $ blRandomNr = ( bool ) \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> getVariable ( "randomVoucherNr" ) ; $ sVoucherNr = $ blRandomNr ? \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsObject ( ) -> generateUID ( ) : \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> getVariable ( "voucherNr" ) ; $ oNewVoucher = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Voucher :: class ) ; $ oNewVoucher -> oxvouchers__oxvoucherserieid = new \ OxidEsales \ Eshop \ Core \ Field ( $ oVoucherSerie -> getId ( ) ) ; $ oNewVoucher -> oxvouchers__oxvouchernr = new \ OxidEsales \ Eshop \ Core \ Field ( $ sVoucherNr ) ; $ oNewVoucher -> save ( ) ; $ this -> _iGenerated ++ ; } return $ this -> _iGenerated ; } | Generates and saves vouchers . Returns number of saved records |
36,601 | public function run ( ) { $ blContinue = true ; $ iExportedItems = 0 ; $ iStart = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "iStart" ) ; for ( $ i = $ iStart ; $ i < $ iStart + $ this -> iGeneratePerTick ; $ i ++ ) { if ( ( $ iExportedItems = $ this -> nextTick ( $ i ) ) === false ) { $ this -> stop ( ERR_SUCCESS ) ; $ blContinue = false ; break ; } } if ( $ blContinue ) { $ this -> _aViewData [ 'refresh' ] = 0 ; $ this -> _aViewData [ 'iStart' ] = $ i ; $ this -> _aViewData [ 'iExpItems' ] = $ iExportedItems ; } } | Runs voucher generation |
36,602 | protected function _cleanEmptyParents ( $ dom , $ parentXPath , $ childXPath ) { $ xPath = new DomXPath ( $ dom ) ; $ nodeList = $ xPath -> query ( $ parentXPath ) ; foreach ( $ nodeList as $ node ) { $ id = $ node -> getAttribute ( 'id' ) ; $ childList = $ xPath -> query ( "{$parentXPath}[@id='$id']/$childXPath" ) ; if ( ! $ childList -> length ) { $ node -> parentNode -> removeChild ( $ node ) ; } } } | clean empty nodes from tree |
36,603 | protected function _addLinks ( $ dom ) { $ url = 'index.php?' ; $ xPath = new DomXPath ( $ dom ) ; $ nodeList = $ xPath -> query ( "//SUBMENU[@cl]" ) ; foreach ( $ nodeList as $ node ) { $ cl = $ node -> getAttribute ( 'cl' ) ; $ cl = $ cl ? "cl=$cl" : '' ; $ param = $ node -> getAttribute ( 'clparam' ) ; $ param = $ param ? "&$param" : '' ; $ node -> setAttribute ( 'link' , "{$url}{$cl}{$param}" ) ; } } | Adds links to xml nodes to resolve paths |
36,604 | protected function _loadFromFile ( $ menuFile , $ dom ) { $ merge = false ; $ domFile = new DomDocument ( ) ; $ domFile -> preserveWhiteSpace = false ; if ( ! @ $ domFile -> load ( $ menuFile ) ) { $ merge = true ; } elseif ( is_readable ( $ menuFile ) && ( $ xml = @ file_get_contents ( $ menuFile ) ) ) { if ( getStr ( ) -> preg_match ( "/encoding\=(.*)\?\>/" , $ xml , $ matches ) !== 0 ) { if ( isset ( $ matches [ 1 ] ) ) { $ currEncoding = trim ( $ matches [ 1 ] , "\"" ) ; if ( ! in_array ( strtolower ( $ currEncoding ) , $ this -> _aSupportedExpathXmlEncodings ) ) { $ xml = str_replace ( $ matches [ 1 ] , "\"UTF-8\"" , $ xml ) ; $ xml = iconv ( $ currEncoding , "UTF-8" , $ xml ) ; } } } if ( @ $ domFile -> loadXml ( $ xml ) ) { $ merge = true ; } } if ( $ merge ) { $ this -> _merge ( $ domFile , $ dom ) ; } } | Loads data form XML file and merges it with main oDomXML . |
36,605 | protected function _sessionizeLocalUrls ( $ dom ) { $ url = $ this -> _getAdminUrl ( ) ; $ xPath = new DomXPath ( $ dom ) ; $ str = getStr ( ) ; foreach ( [ 'url' , 'link' ] as $ attrType ) { foreach ( $ xPath -> query ( "//OXMENU//*[@$attrType]" ) as $ node ) { $ localUrl = $ node -> getAttribute ( $ attrType ) ; if ( strpos ( $ localUrl , 'index.php?' ) === 0 ) { $ localUrl = $ str -> preg_replace ( '#^index.php\?#' , $ url , $ localUrl ) ; $ node -> setAttribute ( $ attrType , $ localUrl ) ; } } } } | add session parameters to local urls |
36,606 | protected function _checkRights ( $ dom ) { $ xPath = new DomXPath ( $ dom ) ; $ nodeList = $ xPath -> query ( '//*[@rights or @norights]' ) ; foreach ( $ nodeList as $ node ) { if ( ( $ req = $ node -> getAttribute ( 'rights' ) ) ) { $ perms = explode ( ',' , $ req ) ; foreach ( $ perms as $ perm ) { if ( $ perm && ! $ this -> _hasRights ( $ perm ) ) { $ node -> parentNode -> removeChild ( $ node ) ; } } } elseif ( ( $ noReq = $ node -> getAttribute ( 'norights' ) ) ) { $ perms = explode ( ',' , $ noReq ) ; foreach ( $ perms as $ perm ) { if ( $ perm && $ this -> _hasRights ( $ perm ) ) { $ node -> parentNode -> removeChild ( $ node ) ; } } } } } | Removes form tree elements which does not have required user rights |
36,607 | protected function _checkDemoShopDenials ( $ dom ) { if ( ! \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> isDemoShop ( ) ) { return ; } $ xPath = new DomXPath ( $ dom ) ; $ nodeList = $ xPath -> query ( "//*[@disableForDemoShop]" ) ; foreach ( $ nodeList as $ node ) { if ( $ node -> getAttribute ( 'disableForDemoShop' ) ) { $ node -> parentNode -> removeChild ( $ node ) ; } } } | Removes form tree elements if this is demo shop and elements have disableForDemoShop = 1 |
36,608 | protected function _copyAttributes ( $ domElemTo , $ domElemFrom ) { foreach ( $ domElemFrom -> attributes as $ attr ) { $ domElemTo -> setAttribute ( $ attr -> nodeName , $ attr -> nodeValue ) ; } } | Copys attributes form one element to another |
36,609 | protected function _mergeNodes ( $ domElemTo , $ domElemFrom , $ xPathTo , $ domDocTo , $ queryStart ) { foreach ( $ domElemFrom -> childNodes as $ fromNode ) { if ( $ fromNode -> nodeType === XML_ELEMENT_NODE ) { $ fromAttrName = $ fromNode -> getAttribute ( 'id' ) ; $ fromNodeName = $ fromNode -> tagName ; $ query = "{$queryStart}/{$fromNodeName}[@id='{$fromAttrName}']" ; $ curNode = $ xPathTo -> query ( $ query ) ; if ( $ curNode -> length == 0 ) { $ domElemTo -> appendChild ( $ domDocTo -> importNode ( $ fromNode , true ) ) ; } else { $ curNode = $ curNode -> item ( 0 ) ; $ this -> _copyAttributes ( $ curNode , $ fromNode ) ; if ( $ fromNode -> childNodes -> length ) { $ this -> _mergeNodes ( $ curNode , $ fromNode , $ xPathTo , $ domDocTo , $ query ) ; } } } } } | Merges nodes of newly added menu xml file |
36,610 | protected function _merge ( $ domNew , $ dom ) { $ xPath = new DOMXPath ( $ dom ) ; $ this -> _mergeNodes ( $ dom -> documentElement , $ domNew -> documentElement , $ xPath , $ dom , '/OX' ) ; } | If oDomXML exist meges nodes |
36,611 | public function getActiveTab ( $ id , $ act ) { $ nodeList = $ this -> getTabs ( $ id , $ act , false ) ; $ act = ( $ act > $ nodeList -> length ) ? ( $ nodeList -> length - 1 ) : $ act ; if ( $ nodeList -> length && ( $ node = $ nodeList -> item ( $ act ) ) ) { return $ node -> getAttribute ( 'cl' ) ; } } | Returns active TAB class name |
36,612 | protected function _getMenuFiles ( ) { $ editionPathSelector = new EditionPathProvider ( new EditionRootPathProvider ( new EditionSelector ( ) ) ) ; $ fullAdminDir = $ editionPathSelector -> getViewsDirectory ( ) . 'admin' . DIRECTORY_SEPARATOR ; $ menuFile = $ fullAdminDir . 'menu.xml' ; if ( file_exists ( $ menuFile ) ) { $ filesToLoad [ ] = $ menuFile ; } if ( file_exists ( $ fullAdminDir . 'user.xml' ) ) { $ filesToLoad [ ] = $ fullAdminDir . 'user.xml' ; } $ path = getShopBasePath ( ) ; $ modulelist = oxNew ( \ OxidEsales \ Eshop \ Core \ Module \ ModuleList :: class ) ; $ activeModuleInfo = $ modulelist -> getActiveModuleInfo ( ) ; if ( is_array ( $ activeModuleInfo ) ) { foreach ( $ activeModuleInfo as $ modulePath ) { $ fullPath = $ path . "modules/" . $ modulePath ; if ( is_dir ( $ fullPath ) ) { $ menuFile = $ fullPath . "/menu.xml" ; if ( file_exists ( $ menuFile ) && is_readable ( $ menuFile ) ) { $ filesToLoad [ ] = $ menuFile ; } } } } return $ filesToLoad ; } | Returns array witn pathes + names ox manu xml files . Paths are checked |
36,613 | protected function _getInitialDom ( ) { if ( $ this -> _oInitialDom === null ) { $ myOxUtlis = \ OxidEsales \ Eshop \ Core \ Registry :: getUtils ( ) ; if ( is_array ( $ filesToLoad = $ this -> _getMenuFiles ( ) ) ) { $ reload = false ; $ templateLanguageCode = $ this -> getTemplateLanguageCode ( ) ; $ shopId = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getActiveShop ( ) -> getShopId ( ) ; $ cacheName = 'menu_' . $ templateLanguageCode . $ shopId . '_xml' ; $ cacheFile = $ myOxUtlis -> getCacheFilePath ( $ cacheName ) ; $ cacheContents = $ myOxUtlis -> fromFileCache ( $ cacheName ) ; if ( $ cacheContents && file_exists ( $ cacheFile ) && ( $ cacheModTime = filemtime ( $ cacheFile ) ) ) { foreach ( $ filesToLoad as $ dynPath ) { if ( $ cacheModTime < filemtime ( $ dynPath ) ) { $ reload = true ; } } } else { $ reload = true ; } $ this -> _oInitialDom = new DOMDocument ( ) ; if ( $ reload ) { $ this -> _oInitialDom -> appendChild ( new DOMElement ( 'OX' ) ) ; foreach ( $ filesToLoad as $ dynPath ) { $ this -> _loadFromFile ( $ dynPath , $ this -> _oInitialDom ) ; } $ this -> _addLinks ( $ this -> _oInitialDom ) ; $ myOxUtlis -> toFileCache ( $ cacheName , $ this -> _oInitialDom -> saveXML ( ) ) ; } else { $ cacheContents = $ this -> _processCachedFile ( $ cacheContents ) ; $ this -> _oInitialDom -> preserveWhiteSpace = false ; $ this -> _oInitialDom -> loadXML ( $ cacheContents ) ; } $ this -> _sessionizeLocalUrls ( $ this -> _oInitialDom ) ; } } return $ this -> _oInitialDom ; } | get initial dom not modified by init method |
36,614 | public function getListNodes ( $ nodes ) { $ xPath = new DOMXPath ( $ this -> getDomXml ( ) ) ; $ nodeList = $ xPath -> query ( "//SUBMENU[@cl='" . implode ( "' or @cl='" , $ nodes ) . "']" ) ; return ( $ nodeList -> length ) ? $ nodeList : null ; } | Returns DOMNodeList of given navigation classes |
36,615 | public function markNodeActive ( $ nodeId ) { $ xPath = new DOMXPath ( $ this -> getDomXml ( ) ) ; $ nodeList = $ xPath -> query ( "//*[@cl='{$nodeId}' or @list='{$nodeId}']" ) ; if ( $ nodeList -> length ) { foreach ( $ nodeList as $ node ) { $ node -> setAttribute ( 'active' , 1 ) ; $ node -> parentNode -> setAttribute ( 'active' , 1 ) ; } } } | Marks passed node as active |
36,616 | public function getListUrl ( $ id ) { $ xPath = new DOMXPath ( $ this -> getDomXml ( ) ) ; $ nodeList = $ xPath -> query ( "//SUBMENU[@cl='{$id}']" ) ; if ( $ nodeList -> length && ( $ node = $ nodeList -> item ( 0 ) ) ) { $ cl = $ node -> getAttribute ( 'list' ) ; $ cl = $ cl ? "cl=$cl" : '' ; $ params = $ node -> getAttribute ( 'listparam' ) ; $ params = $ params ? "&$params" : '' ; return "{$cl}{$params}" ; } } | Formats and returns url for list area |
36,617 | public function getEditUrl ( $ id , $ actTab ) { $ xPath = new DOMXPath ( $ this -> getDomXml ( ) ) ; $ nodeList = $ xPath -> query ( "//SUBMENU[@cl='{$id}']/TAB" ) ; $ actTab = ( $ actTab > $ nodeList -> length ) ? ( $ nodeList -> length - 1 ) : $ actTab ; if ( $ nodeList -> length && ( $ actTab = $ nodeList -> item ( $ actTab ) ) ) { if ( $ actTab -> getAttribute ( 'external' ) ) { return $ actTab -> getAttribute ( 'location' ) ; } $ cl = $ actTab -> getAttribute ( 'cl' ) ; $ cl = $ cl ? "cl={$cl}" : '' ; $ params = $ actTab -> getAttribute ( 'clparam' ) ; $ params = $ params ? "&{$params}" : '' ; return "{$cl}{$params}" ; } } | Formats and returns url for edit area |
36,618 | protected function _getAdminUrl ( ) { $ myConfig = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) ; if ( ( $ adminSslUrl = $ myConfig -> getConfigParam ( 'sAdminSSLURL' ) ) ) { $ url = trim ( $ adminSslUrl , '/' ) ; } else { $ url = trim ( $ myConfig -> getConfigParam ( 'sShopURL' ) , '/' ) . '/admin' ; } return \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsUrl ( ) -> processUrl ( "{$url}/index.php" , false ) ; } | Admin url getter |
36,619 | public function getClassId ( $ className ) { $ xPath = new DOMXPath ( $ this -> _getInitialDom ( ) ) ; $ nodeList = $ xPath -> query ( "//*[@cl='{$className}' or @list='{$className}']" ) ; if ( $ nodeList -> length && ( $ firstItem = $ nodeList -> item ( 0 ) ) ) { return $ firstItem -> getAttribute ( 'id' ) ; } } | Returns id of class assigned to current node |
36,620 | protected function getTemplateLanguageCode ( ) { $ language = \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) ; $ templateLanguageCode = $ language -> getLanguageArray ( ) [ $ language -> getTplLanguage ( ) ] -> abbr ; return $ templateLanguageCode ; } | Get template language code |
36,621 | public function getBasketItems ( ) { if ( $ this -> _aBasketItemList === null ) { $ this -> _aBasketItemList = false ; if ( $ oBasket = $ this -> getSession ( ) -> getBasket ( ) ) { $ this -> _aBasketItemList = $ oBasket -> getBasketArticles ( ) ; } } return $ this -> _aBasketItemList ; } | Returns array of shopping basket articles |
36,622 | public function getWrappingList ( ) { if ( $ this -> _oWrappings === null ) { $ this -> _oWrappings = new \ OxidEsales \ Eshop \ Core \ Model \ ListModel ( ) ; if ( $ this -> getViewConfig ( ) -> getShowGiftWrapping ( ) ) { $ this -> _oWrappings = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Wrapping :: class ) -> getWrappingList ( 'WRAP' ) ; } } return $ this -> _oWrappings ; } | Return basket wrappings list if available |
36,623 | public function getCardList ( ) { if ( $ this -> _oCards === null ) { $ this -> _oCards = new \ OxidEsales \ Eshop \ Core \ Model \ ListModel ( ) ; if ( $ this -> getViewConfig ( ) -> getShowGiftWrapping ( ) ) { $ this -> _oCards = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Wrapping :: class ) -> getWrappingList ( 'CARD' ) ; } } return $ this -> _oCards ; } | Returns greeting cards list if available |
36,624 | public function render ( ) { parent :: render ( ) ; $ this -> _aViewData [ "edit" ] = $ oArticle = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Article :: class ) ; $ soxId = $ this -> getEditObjectId ( ) ; if ( isset ( $ soxId ) && $ soxId != "-1" ) { $ oArticle -> load ( $ soxId ) ; $ oArticle = $ this -> updateArticle ( $ oArticle ) ; if ( $ oArticle -> oxarticles__oxparentid -> value ) { $ oParentArticle = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Article :: class ) ; $ oParentArticle -> load ( $ oArticle -> oxarticles__oxparentid -> value ) ; $ this -> _aViewData [ "parentarticle" ] = $ oParentArticle ; $ this -> _aViewData [ "oxparentid" ] = $ oArticle -> oxarticles__oxparentid -> value ; } } $ this -> _aViewData [ "iPicCount" ] = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'iPicCount' ) ; return "article_pictures.tpl" ; } | Loads article information - pictures passes data to Smarty engine returns name of template file article_pictures . tpl . |
36,625 | public function deletePicture ( ) { $ myConfig = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) ; if ( $ myConfig -> isDemoShop ( ) ) { $ oEx = oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ ExceptionToDisplay :: class ) ; $ oEx -> setMessage ( 'ARTICLE_PICTURES_UPLOADISDISABLED' ) ; \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsView ( ) -> addErrorToDisplay ( $ oEx , false ) ; return ; } $ sOxId = $ this -> getEditObjectId ( ) ; $ iIndex = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "masterPicIndex" ) ; $ oArticle = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Article :: class ) ; $ oArticle -> load ( $ sOxId ) ; if ( $ iIndex == "ICO" ) { $ this -> _deleteMainIcon ( $ oArticle ) ; } elseif ( $ iIndex == "TH" ) { $ this -> _deleteThumbnail ( $ oArticle ) ; } else { $ iIndex = ( int ) $ iIndex ; if ( $ iIndex > 0 ) { $ this -> _resetMasterPicture ( $ oArticle , $ iIndex , true ) ; } } $ oArticle -> save ( ) ; } | Deletes selected master picture and all other master pictures where master picture index is higher than currently deleted index . Also deletes custom icon and thumbnail . |
36,626 | protected function _resetMasterPicture ( $ oArticle , $ iIndex , $ blDeleteMaster = false ) { if ( $ this -> canResetMasterPicture ( $ oArticle , $ iIndex ) ) { if ( ! $ oArticle -> isDerived ( ) ) { $ oPicHandler = \ OxidEsales \ Eshop \ Core \ Registry :: getPictureHandler ( ) ; $ oPicHandler -> deleteArticleMasterPicture ( $ oArticle , $ iIndex , $ blDeleteMaster ) ; } if ( $ blDeleteMaster ) { $ oArticle -> { "oxarticles__oxpic" . $ iIndex } = new \ OxidEsales \ Eshop \ Core \ Field ( ) ; } if ( isset ( $ oArticle -> { "oxarticles__oxzoom" . $ iIndex } ) ) { $ oArticle -> { "oxarticles__oxzoom" . $ iIndex } = new \ OxidEsales \ Eshop \ Core \ Field ( ) ; } if ( $ iIndex == 1 ) { $ this -> _cleanupCustomFields ( $ oArticle ) ; } } } | Deletes selected master picture and all pictures generated from master picture |
36,627 | protected function _deleteMainIcon ( $ oArticle ) { if ( $ this -> canDeleteMainIcon ( $ oArticle ) ) { if ( ! $ oArticle -> isDerived ( ) ) { $ oPicHandler = \ OxidEsales \ Eshop \ Core \ Registry :: getPictureHandler ( ) ; $ oPicHandler -> deleteMainIcon ( $ oArticle ) ; } $ oArticle -> oxarticles__oxicon = new \ OxidEsales \ Eshop \ Core \ Field ( ) ; } } | Deletes main icon file |
36,628 | protected function _deleteThumbnail ( $ oArticle ) { if ( $ this -> canDeleteThumbnail ( $ oArticle ) ) { if ( ! $ oArticle -> isDerived ( ) ) { $ oPicHandler = \ OxidEsales \ Eshop \ Core \ Registry :: getPictureHandler ( ) ; $ oPicHandler -> deleteThumbnail ( $ oArticle ) ; } $ oArticle -> oxarticles__oxthumb = new \ OxidEsales \ Eshop \ Core \ Field ( ) ; } } | Deletes thumbnail file |
36,629 | protected function _cleanupCustomFields ( $ oArticle ) { $ sIcon = $ oArticle -> oxarticles__oxicon -> value ; $ sThumb = $ oArticle -> oxarticles__oxthumb -> value ; if ( $ sIcon == "nopic.jpg" ) { $ oArticle -> oxarticles__oxicon = new \ OxidEsales \ Eshop \ Core \ Field ( ) ; } if ( $ sThumb == "nopic.jpg" ) { $ oArticle -> oxarticles__oxthumb = new \ OxidEsales \ Eshop \ Core \ Field ( ) ; } } | Cleans up article custom fields oxicon and oxthumb . If there is custom icon or thumb picture leaves records untouched . |
36,630 | protected function _insert ( ) { $ this -> _blNewBasket = false ; if ( ! isset ( $ this -> oxuserbaskets__oxpublic -> value ) ) { $ this -> oxuserbaskets__oxpublic = new \ OxidEsales \ Eshop \ Core \ Field ( 1 , \ OxidEsales \ Eshop \ Core \ Field :: T_RAW ) ; } $ iTime = \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsDate ( ) -> getTime ( ) ; $ this -> oxuserbaskets__oxupdate = new \ OxidEsales \ Eshop \ Core \ Field ( $ iTime ) ; return parent :: _insert ( ) ; } | Inserts object data to DB returns true on success . |
36,631 | public function setIsNewBasket ( ) { $ this -> _blNewBasket = true ; $ iTime = \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsDate ( ) -> getTime ( ) ; $ this -> oxuserbaskets__oxupdate = new \ OxidEsales \ Eshop \ Core \ Field ( $ iTime ) ; } | Sets basket as newly created . This usually means that it is not yet stored in DB and will only be stored if some item is added |
36,632 | public function getArticles ( ) { $ aRes = [ ] ; $ aItems = $ this -> getItems ( ) ; if ( is_array ( $ aItems ) ) { foreach ( $ aItems as $ sId => $ oItem ) { $ oArticle = $ oItem -> getArticle ( $ sId ) ; $ aRes [ $ this -> _getItemKey ( $ oArticle -> getId ( ) , $ oItem -> getSelList ( ) , $ oItem -> getPersParams ( ) ) ] = $ oArticle ; } } return $ aRes ; } | Returns an array of articles belonging to the Items in the basket |
36,633 | public function getItems ( $ blReload = false , $ blActiveCheck = true ) { if ( $ this -> _aBasketItems !== null && ! $ blReload ) { return $ this -> _aBasketItems ; } $ this -> _aBasketItems = [ ] ; $ oArticle = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Article :: class ) ; $ sViewName = $ oArticle -> getViewName ( ) ; $ sSelect = "select oxuserbasketitems.* from oxuserbasketitems left join $sViewName on oxuserbasketitems.oxartid = $sViewName.oxid " ; if ( $ blActiveCheck ) { $ sSelect .= 'and ' . $ oArticle -> getSqlActiveSnippet ( ) . ' ' ; } $ sSelect .= "where oxuserbasketitems.oxbasketid = '" . $ this -> getId ( ) . "' and $sViewName.oxid is not null " ; $ sSelect .= " order by oxartnum, oxsellist, oxpersparam " ; $ oItems = oxNew ( \ OxidEsales \ Eshop \ Core \ Model \ ListModel :: class ) ; $ oItems -> init ( 'oxuserbasketitem' ) ; $ oItems -> selectstring ( $ sSelect ) ; foreach ( $ oItems as $ oItem ) { $ sKey = $ this -> _getItemKey ( $ oItem -> oxuserbasketitems__oxartid -> value , $ oItem -> getSelList ( ) , $ oItem -> getPersParams ( ) ) ; $ this -> _aBasketItems [ $ sKey ] = $ oItem ; } return $ this -> _aBasketItems ; } | Returns list of basket items |
36,634 | protected function _createItem ( $ sProductId , $ aSelList = null , $ aPersParams = null ) { $ oNewItem = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ UserBasketItem :: class ) ; $ oNewItem -> oxuserbasketitems__oxartid = new \ OxidEsales \ Eshop \ Core \ Field ( $ sProductId , \ OxidEsales \ Eshop \ Core \ Field :: T_RAW ) ; $ oNewItem -> oxuserbasketitems__oxbasketid = new \ OxidEsales \ Eshop \ Core \ Field ( $ this -> getId ( ) , \ OxidEsales \ Eshop \ Core \ Field :: T_RAW ) ; if ( $ aPersParams && count ( $ aPersParams ) ) { $ oNewItem -> setPersParams ( $ aPersParams ) ; } if ( ! $ aSelList ) { $ oArticle = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Article :: class ) ; $ oArticle -> load ( $ sProductId ) ; $ aSelectLists = $ oArticle -> getSelectLists ( ) ; if ( ( $ iSelCnt = count ( $ aSelectLists ) ) ) { $ aSelList = array_fill ( 0 , $ iSelCnt , '0' ) ; } } $ oNewItem -> setSelList ( $ aSelList ) ; return $ oNewItem ; } | Creates and returns oxuserbasketitem object |
36,635 | public function getItem ( $ sProductId , $ aSelList , $ aPersParams = null ) { $ aItems = $ this -> getItems ( ) ; $ sItemKey = $ this -> _getItemKey ( $ sProductId , $ aSelList , $ aPersParams ) ; $ oItem = null ; if ( isset ( $ aItems [ $ sProductId ] ) ) { $ oItem = $ aItems [ $ sProductId ] ; } elseif ( isset ( $ aItems [ $ sItemKey ] ) ) { $ oItem = $ aItems [ $ sItemKey ] ; } else { $ oItem = $ this -> _createItem ( $ sProductId , $ aSelList , $ aPersParams ) ; } return $ oItem ; } | Searches for item in basket items array and returns it . If not item was found - new item is created . |
36,636 | protected function _getItemKey ( $ sProductId , $ aSel = null , $ aPersParam = null ) { $ aSel = ( $ aSel != null ) ? $ aSel : [ 0 => '0' ] ; return md5 ( $ sProductId . '|' . serialize ( $ aSel ) . '|' . serialize ( $ aPersParam ) ) ; } | Returns unique item key according to its ID and user chosen select |
36,637 | public function delete ( $ sOXID = null ) { if ( ! $ sOXID ) { $ sOXID = $ this -> getId ( ) ; } $ blDelete = false ; if ( $ sOXID && ( $ blDelete = parent :: delete ( $ sOXID ) ) ) { $ oDb = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ sQ = "delete from oxuserbasketitems where oxbasketid = " . $ oDb -> quote ( $ sOXID ) ; $ oDb -> execute ( $ sQ ) ; $ this -> _aBasketItems = null ; } return $ blDelete ; } | Deletes current basket history |
36,638 | public function deleteReview ( $ userId , $ reviewId ) { $ review = $ this -> getReviewById ( $ reviewId ) ; $ this -> validateUserPermissionsToManageReview ( $ review , $ userId ) ; $ review -> delete ( ) ; } | Delete a Review . |
36,639 | public function updatePassword ( ) { $ sNewPass = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( 'password_new' , true ) ; $ sConfPass = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( 'password_new_confirm' , true ) ; $ oUser = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ User :: class ) ; $ oInputValidator = \ OxidEsales \ Eshop \ Core \ Registry :: getInputValidator ( ) ; if ( ( $ oExcp = $ oInputValidator -> checkPassword ( $ oUser , $ sNewPass , $ sConfPass , true ) ) ) { return \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsView ( ) -> addErrorToDisplay ( $ oExcp -> getMessage ( ) , false , true ) ; } if ( $ oUser -> loadUserByUpdateId ( $ this -> getUpdateId ( ) ) ) { $ oUser -> setPassword ( $ sNewPass ) ; $ oUser -> setUpdateKey ( true ) ; $ oUser -> save ( ) ; \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> setVariable ( 'usr' , $ oUser -> getId ( ) ) ; return 'forgotpwd?success=1' ; } else { $ oUtilsView = \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsView ( ) ; return $ oUtilsView -> addErrorToDisplay ( 'ERROR_MESSAGE_PASSWORD_LINK_EXPIRED' , false , true ) ; } } | Checks if password is fine and updates old one with new password . On success user is redirected to success page |
36,640 | public function isExpiredLink ( ) { if ( ( $ sKey = $ this -> getUpdateId ( ) ) ) { $ blExpired = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ User :: class ) -> isExpiredUpdateId ( $ sKey ) ; } return $ blExpired ; } | Returns password update link expiration status |
36,641 | public function getTitle ( ) { $ sTitle = 'FORGOT_PASSWORD' ; if ( $ this -> showUpdateScreen ( ) ) { $ sTitle = 'NEW_PASSWORD' ; } elseif ( $ this -> updateSuccess ( ) ) { $ sTitle = 'CHANGE_PASSWORD' ; } return \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) -> translateString ( $ sTitle , \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) -> getBaseLanguage ( ) , false ) ; } | Get password reminder page title |
36,642 | public function save ( ) { parent :: save ( ) ; $ config = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) ; $ shopId = $ this -> getEditObjectId ( ) ; $ parameters = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "editval" ) ; $ user = $ this -> getUser ( ) ; $ shopId = $ this -> updateShopIdByUser ( $ user , $ shopId , false ) ; $ parameters [ 'oxshops__oxactive' ] = ( isset ( $ parameters [ 'oxshops__oxactive' ] ) && $ parameters [ 'oxshops__oxactive' ] == true ) ? 1 : 0 ; $ parameters [ 'oxshops__oxproductive' ] = ( isset ( $ parameters [ 'oxshops__oxproductive' ] ) && $ parameters [ 'oxshops__oxproductive' ] == true ) ? 1 : 0 ; $ subjLang = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "subjlang" ) ; $ shopLanguageId = ( $ subjLang && $ subjLang > 0 ) ? $ subjLang : 0 ; $ shop = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Shop :: class ) ; if ( $ shopId != self :: NEW_SHOP_ID ) { $ shop -> loadInLang ( $ shopLanguageId , $ shopId ) ; } else { $ parameters = $ this -> updateParameters ( $ parameters ) ; } if ( $ parameters [ 'oxshops__oxsmtp' ] ) { $ parameters [ 'oxshops__oxsmtp' ] = trim ( $ parameters [ 'oxshops__oxsmtp' ] ) ; } $ shop -> setLanguage ( 0 ) ; $ shop -> assign ( $ parameters ) ; $ shop -> setLanguage ( $ shopLanguageId ) ; if ( ( $ newSMPTPass = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "oxsmtppwd" ) ) ) { $ shop -> oxshops__oxsmtppwd -> setValue ( $ newSMPTPass == '-' ? "" : $ newSMPTPass ) ; } $ canCreateShop = $ this -> canCreateShop ( $ shopId , $ shop , $ config ) ; if ( ! $ canCreateShop ) { return ; } try { $ shop -> save ( ) ; } catch ( \ OxidEsales \ Eshop \ Core \ Exception \ StandardException $ e ) { $ this -> checkExceptionType ( $ e ) ; return ; } $ this -> _aViewData [ "updatelist" ] = "1" ; $ this -> updateShopInformation ( $ config , $ shop , $ shopId ) ; \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> setVariable ( "actshop" , $ shopId ) ; } | Saves changed main shop configuration parameters . |
36,643 | protected function _getNonCopyConfigVars ( ) { $ nonCopyVars = [ "aSerials" , "IMS" , "IMD" , "IMA" , "sBackTag" , "sUtilModule" , "aModulePaths" , "aModuleFiles" , "aModuleEvents" , "aModuleVersions" , "aModuleTemplates" , "aModules" , "aDisabledModules" ] ; $ multiShopTables = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'aMultiShopTables' ) ; foreach ( $ multiShopTables as $ multishopTable ) { $ nonCopyVars [ ] = 'blMallInherit_' . strtolower ( $ multishopTable ) ; } return $ nonCopyVars ; } | Returns array of config variables which cannot be copied |
36,644 | protected function _copyConfigVars ( $ shop ) { $ config = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) ; $ utilsObject = \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsObject ( ) ; $ db = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDb ( ) ; $ nonCopyVars = $ this -> _getNonCopyConfigVars ( ) ; $ selectShopConfigurationQuery = "select oxvarname, oxvartype, DECODE( oxvarvalue, " . $ db -> quote ( $ config -> getConfigParam ( 'sConfigKey' ) ) . ") as oxvarvalue, oxmodule from oxconfig where oxshopid = '1'" ; $ shopConfiguration = $ db -> select ( $ selectShopConfigurationQuery ) ; if ( $ shopConfiguration != false && $ shopConfiguration -> count ( ) > 0 ) { while ( ! $ shopConfiguration -> EOF ) { $ configName = $ shopConfiguration -> fields [ 0 ] ; if ( ! in_array ( $ configName , $ nonCopyVars ) ) { $ newId = $ utilsObject -> generateUID ( ) ; $ insertNewConfigQuery = "insert into oxconfig (oxid, oxshopid, oxvarname, oxvartype, oxvarvalue, oxmodule) values ( '$newId', " . $ db -> quote ( $ shop -> getId ( ) ) . ", " . $ db -> quote ( $ shopConfiguration -> fields [ 0 ] ) . ", " . $ db -> quote ( $ shopConfiguration -> fields [ 1 ] ) . ", ENCODE( " . $ db -> quote ( $ shopConfiguration -> fields [ 2 ] ) . ", '" . $ config -> getConfigParam ( 'sConfigKey' ) . "')" . ", " . $ db -> quote ( $ shopConfiguration -> fields [ 3 ] ) . " )" ; $ db -> execute ( $ insertNewConfigQuery ) ; } $ shopConfiguration -> fetchRow ( ) ; } } $ inheritAll = $ shop -> oxshops__oxisinherited -> value ? "true" : "false" ; $ multiShopTables = $ config -> getConfigParam ( 'aMultiShopTables' ) ; foreach ( $ multiShopTables as $ multishopTable ) { $ config -> saveShopConfVar ( "bool" , 'blMallInherit_' . strtolower ( $ multishopTable ) , $ inheritAll , $ shop -> oxshops__oxid -> value ) ; } } | Copies base shop config variables to current |
36,645 | public function needToUpdate ( $ currentTimestamp ) { return ( $ this -> hasLifetimeExpired ( $ currentTimestamp , self :: SERVER_INFO_UPDATE_PERIOD ) || ! $ this -> isServerTimeValid ( $ currentTimestamp ) ) ; } | Check if application server information must be updated . |
36,646 | private function hasLifetimeExpired ( $ currentTimestamp , $ periodTimestamp ) { $ timestamp = $ this -> getTimestamp ( ) ; return ( bool ) ( $ currentTimestamp - $ timestamp >= $ periodTimestamp ) ; } | Compare if the application server lifetime has exceeded given period . |
36,647 | protected function _getCsvFieldsNames ( ) { $ blCsvContainsHeader = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( 'blContainsHeader' ) ; \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> setVariable ( 'blCsvContainsHeader' , $ blCsvContainsHeader ) ; $ this -> _getUploadedCsvFilePath ( ) ; $ aFirstRow = $ this -> _getCsvFirstRow ( ) ; if ( ! $ blCsvContainsHeader ) { $ iIndex = 1 ; foreach ( $ aFirstRow as $ sValue ) { $ aCsvFields [ $ iIndex ] = 'Column ' . $ iIndex ++ ; } } else { foreach ( $ aFirstRow as $ sKey => $ sValue ) { $ aFirstRow [ $ sKey ] = \ OxidEsales \ Eshop \ Core \ Str :: getStr ( ) -> htmlentities ( $ sValue ) ; } $ aCsvFields = $ aFirstRow ; } return $ aCsvFields ; } | Get columns names from CSV file header . If file has no header returns default columns names Column 1 Column 2 .. |
36,648 | protected function _getCsvFirstRow ( ) { $ sPath = $ this -> _getUploadedCsvFilePath ( ) ; $ iMaxLineLength = 8192 ; if ( ( $ rFile = @ fopen ( $ sPath , "r" ) ) !== false ) { $ aRow = fgetcsv ( $ rFile , $ iMaxLineLength , $ this -> _getCsvFieldsTerminator ( ) , $ this -> _getCsvFieldsEncolser ( ) ) ; fclose ( $ rFile ) ; } return $ aRow ; } | Get first row from uploaded CSV file |
36,649 | protected function _resetUploadedCsvData ( ) { $ this -> _sCsvFilePath = null ; \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> setVariable ( 'sCsvFilePath' , null ) ; \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> setVariable ( 'blCsvContainsHeader' , null ) ; } | Resets CSV parameters stored in session |
36,650 | protected function _checkErrors ( $ iNavStep ) { if ( $ iNavStep == 2 ) { if ( ! $ this -> _getUploadedCsvFilePath ( ) ) { $ oEx = oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ ExceptionToDisplay :: class ) ; $ oEx -> setMessage ( 'GENIMPORT_ERRORUPLOADINGFILE' ) ; \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsView ( ) -> addErrorToDisplay ( $ oEx , false , true , 'genimport' ) ; return 1 ; } } if ( $ iNavStep == 3 ) { $ blIsEmpty = true ; $ aCsvFields = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( 'aCsvFields' ) ; foreach ( $ aCsvFields as $ sValue ) { if ( $ sValue ) { $ blIsEmpty = false ; break ; } } if ( $ blIsEmpty ) { $ oEx = oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ ExceptionToDisplay :: class ) ; $ oEx -> setMessage ( 'GENIMPORT_ERRORASSIGNINGFIELDS' ) ; \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsView ( ) -> addErrorToDisplay ( $ oEx , false , true , 'genimport' ) ; return 2 ; } } return $ iNavStep ; } | Checks current import navigation step errors . Returns step id in which error occured . |
36,651 | protected function _getUploadedCsvFilePath ( ) { if ( $ this -> _sCsvFilePath !== null ) { return $ this -> _sCsvFilePath ; } elseif ( $ this -> _sCsvFilePath = \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> getVariable ( 'sCsvFilePath' ) ) { return $ this -> _sCsvFilePath ; } $ oConfig = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) ; $ aFile = $ oConfig -> getUploadedFile ( 'csvfile' ) ; if ( isset ( $ aFile [ 'name' ] ) && $ aFile [ 'name' ] ) { $ this -> _sCsvFilePath = $ oConfig -> getConfigParam ( 'sCompileDir' ) . basename ( $ aFile [ 'tmp_name' ] ) ; move_uploaded_file ( $ aFile [ 'tmp_name' ] , $ this -> _sCsvFilePath ) ; \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> setVariable ( 'sCsvFilePath' , $ this -> _sCsvFilePath ) ; return $ this -> _sCsvFilePath ; } } | Checks if CSV file was uploaded . If uploaded - moves it to temp dir and stores path to file in session . Return path to uploaded file . |
36,652 | protected function _checkImportErrors ( $ oErpImport ) { foreach ( $ oErpImport -> getStatistics ( ) as $ aValue ) { if ( ! $ aValue [ 'r' ] ) { $ oEx = oxNew ( \ OxidEsales \ Eshop \ Core \ Exception \ ExceptionToDisplay :: class ) ; $ oEx -> setMessage ( $ aValue [ 'm' ] ) ; \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsView ( ) -> addErrorToDisplay ( $ oEx , false , true , 'genimport' ) ; } } } | Checks if any error occured during import and displays them |
36,653 | protected function _getCsvFieldsTerminator ( ) { if ( $ this -> _sStringTerminator === null ) { $ this -> _sStringTerminator = $ this -> _sDefaultStringTerminator ; if ( $ char = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'sGiCsvFieldTerminator' ) ) { $ this -> _sStringTerminator = $ char ; } } return $ this -> _sStringTerminator ; } | Get csv field terminator symbol |
36,654 | protected function _getCsvFieldsEncolser ( ) { if ( $ this -> _sStringEncloser === null ) { $ this -> _sStringEncloser = $ this -> _sDefaultStringEncloser ; if ( $ char = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'sGiCsvFieldEncloser' ) ) { $ this -> _sStringEncloser = $ char ; } } return $ this -> _sStringEncloser ; } | Get csv field encloser symbol |
36,655 | public function render ( ) { parent :: render ( ) ; $ this -> _aViewData [ 'edit' ] = $ article = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Article :: class ) ; $ oxId = $ this -> getEditObjectId ( ) ; $ this -> _createCategoryTree ( "artcattree" ) ; if ( isset ( $ oxId ) && $ oxId != "-1" ) { $ article -> loadInLang ( $ this -> _iEditLang , $ oxId ) ; $ article = $ this -> updateArticle ( $ article ) ; $ otherLang = $ article -> getAvailableInLangs ( ) ; if ( ! isset ( $ otherLang [ $ this -> _iEditLang ] ) ) { $ article -> loadInLang ( key ( $ otherLang ) , $ oxId ) ; } foreach ( $ otherLang as $ id => $ language ) { $ lang = new stdClass ( ) ; $ lang -> sLangDesc = $ language ; $ lang -> selected = ( $ id == $ this -> _iEditLang ) ; $ this -> _aViewData [ "otherlang" ] [ $ id ] = clone $ lang ; } if ( $ article -> oxarticles__oxparentid -> value ) { $ parentArticle = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Article :: class ) ; $ parentArticle -> load ( $ article -> oxarticles__oxparentid -> value ) ; $ this -> _aViewData [ "parentarticle" ] = $ parentArticle ; $ this -> _aViewData [ "oxparentid" ] = $ article -> oxarticles__oxparentid -> value ; } } $ this -> prepareBundledArticlesDataForView ( $ article ) ; $ iAoc = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( "aoc" ) ; if ( $ iAoc == 1 ) { $ oArticleExtendAjax = oxNew ( \ OxidEsales \ Eshop \ Application \ Controller \ Admin \ ArticleExtendAjax :: class ) ; $ this -> _aViewData [ 'oxajax' ] = $ oArticleExtendAjax -> getColumns ( ) ; return "popups/article_extend.tpl" ; } elseif ( $ iAoc == 2 ) { $ oArticleBundleAjax = oxNew ( \ OxidEsales \ Eshop \ Application \ Controller \ Admin \ ArticleBundleAjax :: class ) ; $ this -> _aViewData [ 'oxajax' ] = $ oArticleBundleAjax -> getColumns ( ) ; return "popups/article_bundle.tpl" ; } $ this -> _aViewData [ 'aMediaUrls' ] = $ article -> getMediaUrls ( ) ; return "article_extend.tpl" ; } | Collects available article extended parameters passes them to Smarty engine and returns template file name article_extend . tpl . |
36,656 | public function updateMedia ( ) { $ aMediaUrls = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getRequestParameter ( 'aMediaUrls' ) ; if ( is_array ( $ aMediaUrls ) ) { foreach ( $ aMediaUrls as $ sMediaId => $ aMediaParams ) { $ oMedia = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ MediaUrl :: class ) ; if ( $ oMedia -> load ( $ sMediaId ) ) { $ oMedia -> setLanguage ( 0 ) ; $ oMedia -> assign ( $ aMediaParams ) ; $ oMedia -> setLanguage ( $ this -> _iEditLang ) ; $ oMedia -> save ( ) ; } } } } | Updates existing media descriptions |
36,657 | public function getUnitsArray ( ) { if ( $ this -> _aUnitsArray === null ) { $ this -> _aUnitsArray = \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) -> getSimilarByKey ( "_UNIT_" , $ this -> _iEditLang , false ) ; } return $ this -> _aUnitsArray ; } | Returns array of possible unit combination and its translation for edit language |
36,658 | protected function prepareBundledArticlesDataForView ( $ article ) { $ database = \ OxidEsales \ Eshop \ Core \ DatabaseProvider :: getDB ( ) ; $ config = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) ; $ articleTable = getViewName ( 'oxarticles' , $ this -> _iEditLang ) ; $ query = "select {$articleTable}.oxtitle, {$articleTable}.oxartnum, {$articleTable}.oxvarselect " . "from {$articleTable} where 1 " ; $ isVariantSelectionEnabled = $ config -> getConfigParam ( 'blVariantsSelection' ) ; $ bundleIdField = 'oxarticles__oxbundleid' ; $ query .= $ isVariantSelectionEnabled ? '' : " and {$articleTable}.oxparentid = '' " ; $ query .= " and {$articleTable}.oxid = " . $ database -> quote ( $ article -> $ bundleIdField -> value ) ; $ resultFromDatabase = $ database -> select ( $ query ) ; if ( $ resultFromDatabase != false && $ resultFromDatabase -> count ( ) > 0 ) { while ( ! $ resultFromDatabase -> EOF ) { $ articleNumber = new \ OxidEsales \ Eshop \ Core \ Field ( $ resultFromDatabase -> fields [ 1 ] ) ; $ articleTitle = new \ OxidEsales \ Eshop \ Core \ Field ( $ resultFromDatabase -> fields [ 0 ] . " " . $ resultFromDatabase -> fields [ 2 ] ) ; $ resultFromDatabase -> fetchRow ( ) ; } } $ this -> _aViewData [ 'bundle_artnum' ] = $ articleNumber ; $ this -> _aViewData [ 'bundle_title' ] = $ articleTitle ; } | Adds data to _aViewData for later use in templates . |
36,659 | public function isSaveToDataBaseEnabled ( ) { if ( is_null ( $ this -> _blSaveToDataBase ) ) { $ this -> _blSaveToDataBase = ( bool ) ! \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'blPerfNoBasketSaving' ) ; } return $ this -> _blSaveToDataBase ; } | Returns true if saving to data base enabled |
36,660 | public function isCalculationModeNetto ( ) { if ( $ this -> _isCalculationModeNetto === null ) { $ this -> setCalculationModeNetto ( $ this -> isPriceViewModeNetto ( ) ) ; } return $ this -> _isCalculationModeNetto ; } | Return true if calculation mode is netto |
36,661 | protected function _changeBasketItemKey ( $ sOldKey , $ sNewKey , $ value = null ) { reset ( $ this -> _aBasketContents ) ; $ iOldKeyPlace = 0 ; while ( key ( $ this -> _aBasketContents ) != $ sOldKey && next ( $ this -> _aBasketContents ) ) { ++ $ iOldKeyPlace ; } $ aNewCopy = array_merge ( array_slice ( $ this -> _aBasketContents , 0 , $ iOldKeyPlace , true ) , [ $ sNewKey => $ value ] , array_slice ( $ this -> _aBasketContents , $ iOldKeyPlace + 1 , count ( $ this -> _aBasketContents ) - $ iOldKeyPlace , true ) ) ; $ this -> _aBasketContents = $ aNewCopy ; } | change old key to new one but retain key position in array |
36,662 | public function getItemKey ( $ sProductId , $ aSel = null , $ aPersParam = null , $ blBundle = false , $ sAdditionalParam = '' ) { $ aSel = ( $ aSel != null ) ? $ aSel : [ 0 => '0' ] ; $ sItemKey = md5 ( $ sProductId . '|' . serialize ( $ aSel ) . '|' . serialize ( $ aPersParam ) . '|' . ( int ) $ blBundle . '|' . serialize ( $ sAdditionalParam ) ) ; return $ sItemKey ; } | Returns unique basket item identifier which consist from product ID select lists data persistent info and bundle property |
36,663 | public function removeItem ( $ sItemKey ) { if ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'blPsBasketReservationEnabled' ) ) { if ( isset ( $ this -> _aBasketContents [ $ sItemKey ] ) ) { $ sArticleId = $ this -> _aBasketContents [ $ sItemKey ] -> getProductId ( ) ; if ( $ sArticleId ) { $ this -> getSession ( ) -> getBasketReservations ( ) -> discardArticleReservation ( $ sArticleId ) ; } } } unset ( $ this -> _aBasketContents [ $ sItemKey ] ) ; if ( ! count ( $ this -> _aBasketContents ) && \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'blBasketExcludeEnabled' ) ) { $ this -> setBasketRootCatId ( null ) ; } } | Removes item from basket |
36,664 | protected function _clearBundles ( ) { reset ( $ this -> _aBasketContents ) ; foreach ( $ this -> _aBasketContents as $ sItemKey => $ oBasketItem ) { if ( $ oBasketItem -> isBundle ( ) ) { $ this -> removeItem ( $ sItemKey ) ; } } } | Unsets bundled basket items from basket contents array |
36,665 | protected function _getArticleBundles ( $ oBasketItem ) { $ aBundles = [ ] ; if ( $ oBasketItem -> isBundle ( ) ) { return $ aBundles ; } $ oArticle = $ oBasketItem -> getArticle ( true ) ; if ( $ oArticle && $ oArticle -> oxarticles__oxbundleid -> value ) { $ aBundles [ $ oArticle -> oxarticles__oxbundleid -> value ] = 1 ; } return $ aBundles ; } | Returns array of bundled articles IDs for basket item |
36,666 | protected function _getItemBundles ( $ oBasketItem , $ aBundles = [ ] ) { if ( $ oBasketItem -> isBundle ( ) ) { return [ ] ; } if ( $ oArticle = $ oBasketItem -> getArticle ( ) ) { $ aDiscounts = \ OxidEsales \ Eshop \ Core \ Registry :: get ( \ OxidEsales \ Eshop \ Application \ Model \ DiscountList :: class ) -> getBasketItemBundleDiscounts ( $ oArticle , $ this , $ this -> getBasketUser ( ) ) ; foreach ( $ aDiscounts as $ oDiscount ) { $ iAmnt = $ oDiscount -> getBundleAmount ( $ oBasketItem -> getAmount ( ) ) ; if ( $ iAmnt ) { if ( ! isset ( $ aBundles [ $ oDiscount -> oxdiscount__oxitmartid -> value ] ) ) { $ aBundles [ $ oDiscount -> oxdiscount__oxitmartid -> value ] = 0 ; } if ( $ oDiscount -> oxdiscount__oxitmmultiple -> value ) { $ aBundles [ $ oDiscount -> oxdiscount__oxitmartid -> value ] += $ iAmnt ; } else { $ aBundles [ $ oDiscount -> oxdiscount__oxitmartid -> value ] = $ iAmnt ; } } } } return $ aBundles ; } | Returns array of bundled discount articles |
36,667 | protected function _getBasketBundles ( $ aBundles = [ ] ) { $ aDiscounts = \ OxidEsales \ Eshop \ Core \ Registry :: get ( \ OxidEsales \ Eshop \ Application \ Model \ DiscountList :: class ) -> getBasketBundleDiscounts ( $ this , $ this -> getBasketUser ( ) ) ; $ dAmount = 0 ; foreach ( $ this -> _aBasketContents as $ oBasketItem ) { if ( ! ( $ oBasketItem -> isBundle ( ) || $ oBasketItem -> isDiscountArticle ( ) ) ) { $ dAmount += $ oBasketItem -> getAmount ( ) ; } } foreach ( $ aDiscounts as $ oDiscount ) { if ( $ oDiscount -> oxdiscount__oxitmartid -> value ) { if ( ! isset ( $ aBundles [ $ oDiscount -> oxdiscount__oxitmartid -> value ] ) ) { $ aBundles [ $ oDiscount -> oxdiscount__oxitmartid -> value ] = 0 ; } $ aBundles [ $ oDiscount -> oxdiscount__oxitmartid -> value ] += $ oDiscount -> getBundleAmount ( $ dAmount ) ; } } return $ aBundles ; } | Returns array of bundled discount articles for whole basket |
36,668 | protected function _addBundles ( ) { $ aBundles = [ ] ; foreach ( $ this -> _aBasketContents as $ key => $ oBasketItem ) { try { if ( ! $ oBasketItem -> isDiscountArticle ( ) && ! $ oBasketItem -> isBundle ( ) ) { $ aBundles = $ this -> _getItemBundles ( $ oBasketItem , $ aBundles ) ; } else { continue ; } $ aArtBundles = $ this -> _getArticleBundles ( $ oBasketItem ) ; $ this -> _addBundlesToBasket ( $ aArtBundles ) ; } catch ( \ OxidEsales \ Eshop \ Core \ Exception \ NoArticleException $ oEx ) { $ this -> removeItem ( $ key ) ; \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsView ( ) -> addErrorToDisplay ( $ oEx ) ; } catch ( \ OxidEsales \ Eshop \ Core \ Exception \ ArticleInputException $ oEx ) { $ this -> removeItem ( $ key ) ; \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsView ( ) -> addErrorToDisplay ( $ oEx ) ; } } $ aBundles = $ this -> _getBasketBundles ( $ aBundles ) ; if ( $ aBundles ) { $ this -> _addBundlesToBasket ( $ aBundles ) ; } } | Iterates through basket contents and adds bundles to items + adds global basket bundles |
36,669 | protected function _addBundlesToBasket ( $ aBundles ) { foreach ( $ aBundles as $ sBundleId => $ dAmount ) { if ( $ dAmount ) { try { if ( $ oBundleItem = $ this -> addToBasket ( $ sBundleId , $ dAmount , null , null , false , true ) ) { $ oBundleItem -> setAsDiscountArticle ( true ) ; } } catch ( \ OxidEsales \ Eshop \ Core \ Exception \ ArticleException $ oEx ) { if ( $ oEx instanceof \ OxidEsales \ Eshop \ Core \ Exception \ OutOfStockException && $ oEx -> getRemainingAmount ( ) > 0 ) { $ sItemId = $ this -> getItemKey ( $ sBundleId , null , null , true ) ; $ this -> _aBasketContents [ $ sItemId ] -> setAsDiscountArticle ( true ) ; } } } } } | Adds bundles to basket |
36,670 | protected function _calcItemsPrice ( ) { $ this -> setSkipDiscounts ( false ) ; $ this -> _iProductsCnt = 0 ; $ this -> _dItemsCnt = 0 ; $ this -> _dWeight = 0 ; $ this -> _oProductsPriceList = oxNew ( \ OxidEsales \ Eshop \ Core \ PriceList :: class ) ; $ this -> _oDiscountProductsPriceList = oxNew ( \ OxidEsales \ Eshop \ Core \ PriceList :: class ) ; $ this -> _oNotDiscountedProductsPriceList = oxNew ( \ OxidEsales \ Eshop \ Core \ PriceList :: class ) ; $ oDiscountList = \ OxidEsales \ Eshop \ Core \ Registry :: get ( \ OxidEsales \ Eshop \ Application \ Model \ DiscountList :: class ) ; foreach ( $ this -> _aBasketContents as $ oBasketItem ) { $ this -> _iProductsCnt ++ ; $ this -> _dItemsCnt += $ oBasketItem -> getAmount ( ) ; $ this -> _dWeight += $ oBasketItem -> getWeight ( ) ; if ( ! $ oBasketItem -> isDiscountArticle ( ) && ( $ oArticle = $ oBasketItem -> getArticle ( true ) ) ) { $ oBasketPrice = $ oArticle -> getBasketPrice ( $ oBasketItem -> getAmount ( ) , $ oBasketItem -> getSelList ( ) , $ this ) ; $ oBasketItem -> setRegularUnitPrice ( clone $ oBasketPrice ) ; if ( ! $ oArticle -> skipDiscounts ( ) && $ this -> canCalcDiscounts ( ) ) { $ aDiscounts = $ oDiscountList -> getBasketItemDiscounts ( $ oArticle , $ this , $ this -> getBasketUser ( ) ) ; reset ( $ aDiscounts ) ; foreach ( $ aDiscounts as $ oDiscount ) { $ oBasketPrice -> setDiscount ( $ oDiscount -> getAddSum ( ) , $ oDiscount -> getAddSumType ( ) ) ; } $ oBasketPrice -> calculateDiscount ( ) ; } else { $ oBasketItem -> setSkipDiscounts ( true ) ; $ this -> setSkipDiscounts ( true ) ; } $ oBasketItem -> setPrice ( $ oBasketPrice ) ; $ this -> _oProductsPriceList -> addToPriceList ( $ oBasketItem -> getPrice ( ) ) ; if ( ! $ oArticle -> skipDiscounts ( ) ) { $ this -> _oDiscountProductsPriceList -> addToPriceList ( $ oBasketItem -> getPrice ( ) ) ; } else { $ this -> _oNotDiscountedProductsPriceList -> addToPriceList ( $ oBasketItem -> getPrice ( ) ) ; $ oBasketItem -> setSkipDiscounts ( true ) ; $ this -> setSkipDiscounts ( true ) ; } } elseif ( $ oBasketItem -> isBundle ( ) ) { $ oPrice = oxNew ( \ OxidEsales \ Eshop \ Core \ Price :: class ) ; $ oBasketItem -> setPrice ( $ oPrice ) ; } } } | Iterates through basket items and calculates its prices and discounts |
36,671 | protected function _mergeDiscounts ( $ aDiscounts , $ aItemDiscounts ) { foreach ( $ aItemDiscounts as $ sKey => $ oDiscount ) { if ( array_key_exists ( $ sKey , $ aDiscounts ) ) { $ aDiscounts [ $ sKey ] -> dDiscount += $ oDiscount -> dDiscount ; } else { $ aDiscounts [ $ sKey ] = $ oDiscount ; } } return $ aDiscounts ; } | Merges two discount arrays . If there are two the same discounts discount values will be added . |
36,672 | protected function _calcDeliveryCost ( ) { if ( $ this -> _oDeliveryPrice !== null ) { return $ this -> _oDeliveryPrice ; } $ myConfig = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) ; $ oDeliveryPrice = oxNew ( \ OxidEsales \ Eshop \ Core \ Price :: class ) ; if ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'blDeliveryVatOnTop' ) ) { $ oDeliveryPrice -> setNettoPriceMode ( ) ; } else { $ oDeliveryPrice -> setBruttoPriceMode ( ) ; } $ oUser = $ this -> getBasketUser ( ) ; if ( ! $ oUser && ! $ myConfig -> getConfigParam ( 'blCalculateDelCostIfNotLoggedIn' ) ) { return $ oDeliveryPrice ; } $ fDelVATPercent = $ this -> getAdditionalServicesVatPercent ( ) ; $ oDeliveryPrice -> setVat ( $ fDelVATPercent ) ; if ( $ myConfig -> getConfigParam ( 'bl_perfLoadDelivery' ) ) { $ aDeliveryList = \ OxidEsales \ Eshop \ Core \ Registry :: get ( \ OxidEsales \ Eshop \ Application \ Model \ DeliveryList :: class ) -> getDeliveryList ( $ this , $ oUser , $ this -> _findDelivCountry ( ) , $ this -> getShippingId ( ) ) ; if ( count ( $ aDeliveryList ) > 0 ) { foreach ( $ aDeliveryList as $ oDelivery ) { if ( $ myConfig -> getConfigParam ( 'iDebug' ) == 5 ) { echo ( "DelCost : " . $ oDelivery -> oxdelivery__oxtitle -> value . "<br>" ) ; } $ oDeliveryPrice -> addPrice ( $ oDelivery -> getDeliveryPrice ( $ fDelVATPercent ) ) ; } } } return $ oDeliveryPrice ; } | Iterates through basket items and calculates its delivery costs |
36,673 | protected function _calcTotalPrice ( ) { $ dPrice = $ this -> _dBruttoSum ; $ oTotalPrice = oxNew ( \ OxidEsales \ Eshop \ Core \ Price :: class ) ; $ oTotalPrice -> setBruttoPriceMode ( ) ; $ oTotalPrice -> setPrice ( $ dPrice ) ; if ( $ dPrice && ! $ this -> isCalculationModeNetto ( ) ) { $ oTotalPrice -> subtract ( $ this -> _oTotalDiscount -> getBruttoPrice ( ) ) ; if ( $ oVoucherDisc = $ this -> getVoucherDiscount ( ) ) { $ oTotalPrice -> subtract ( $ oVoucherDisc -> getBruttoPrice ( ) ) ; } } if ( isset ( $ this -> _aCosts [ 'oxdelivery' ] ) ) { $ oTotalPrice -> add ( $ this -> _aCosts [ 'oxdelivery' ] -> getBruttoPrice ( ) ) ; } if ( isset ( $ this -> _aCosts [ 'oxwrapping' ] ) ) { $ oTotalPrice -> add ( $ this -> _aCosts [ 'oxwrapping' ] -> getBruttoPrice ( ) ) ; } if ( isset ( $ this -> _aCosts [ 'oxgiftcard' ] ) ) { $ oTotalPrice -> add ( $ this -> _aCosts [ 'oxgiftcard' ] -> getBruttoPrice ( ) ) ; } if ( isset ( $ this -> _aCosts [ 'oxpayment' ] ) ) { $ oTotalPrice -> add ( $ this -> _aCosts [ 'oxpayment' ] -> getBruttoPrice ( ) ) ; } $ this -> setPrice ( $ oTotalPrice ) ; } | Performs final sum calculation and rounding . |
36,674 | public function setVoucherDiscount ( $ dDiscount ) { $ this -> _oVoucherDiscount = oxNew ( \ OxidEsales \ Eshop \ Core \ Price :: class ) ; $ this -> _oVoucherDiscount -> setBruttoPriceMode ( ) ; $ this -> _oVoucherDiscount -> add ( $ dDiscount ) ; } | Voucher discount setter |
36,675 | protected function _calcVoucherDiscount ( ) { if ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'bl_showVouchers' ) && ( $ this -> _oVoucherDiscount === null || ( $ this -> _blUpdateNeeded && ! $ this -> isAdmin ( ) ) ) ) { $ this -> _oVoucherDiscount = $ this -> _getPriceObject ( ) ; $ dPrice = $ this -> _oDiscountProductsPriceList -> getSum ( $ this -> isCalculationModeNetto ( ) ) - $ this -> _oTotalDiscount -> getPrice ( ) ; if ( count ( $ this -> _aVouchers ) ) { $ oLang = \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) ; foreach ( $ this -> _aVouchers as $ sVoucherId => $ oStdVoucher ) { $ oVoucher = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Voucher :: class ) ; try { $ oVoucher -> load ( $ oStdVoucher -> sVoucherId ) ; if ( ! $ this -> _blSkipVouchersAvailabilityChecking ) { $ oVoucher -> checkBasketVoucherAvailability ( $ this -> _aVouchers , $ dPrice ) ; $ oVoucher -> checkUserAvailability ( $ this -> getBasketUser ( ) ) ; } $ dVoucherdiscount = $ oVoucher -> getDiscountValue ( $ dPrice ) ; if ( $ dVoucherdiscount > 0 ) { $ dVatPart = ( $ dPrice - $ dVoucherdiscount ) / $ dPrice * 100 ; if ( ! $ this -> _aDiscountedVats ) { if ( $ oPriceList = $ this -> getDiscountProductsPrice ( ) ) { $ this -> _aDiscountedVats = $ oPriceList -> getVatInfo ( $ this -> isCalculationModeNetto ( ) ) ; } } foreach ( $ this -> _aDiscountedVats as $ sKey => $ dVat ) { $ this -> _aDiscountedVats [ $ sKey ] = \ OxidEsales \ Eshop \ Core \ Price :: percent ( $ dVat , $ dVatPart ) ; } } $ this -> _oVoucherDiscount -> add ( $ dVoucherdiscount ) ; $ oStdVoucher -> fVoucherdiscount = $ oLang -> formatCurrency ( $ dVoucherdiscount , $ this -> getBasketCurrency ( ) ) ; $ oStdVoucher -> dVoucherdiscount = $ dVoucherdiscount ; $ dPrice = $ dPrice - $ dVoucherdiscount ; } catch ( \ OxidEsales \ Eshop \ Core \ Exception \ VoucherException $ oEx ) { $ oVoucher -> unMarkAsReserved ( ) ; unset ( $ this -> _aVouchers [ $ sVoucherId ] ) ; \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsView ( ) -> addErrorToDisplay ( $ oEx , false , true ) ; } } } } } | Calculates voucher discount |
36,676 | protected function _applyDiscounts ( ) { $ dDiscountedSum = $ this -> _getDiscountedProductsSum ( ) ; $ oUtils = \ OxidEsales \ Eshop \ Core \ Registry :: getUtils ( ) ; $ dVatSum = 0 ; foreach ( $ this -> _aDiscountedVats as $ dVat ) { $ dVatSum += $ oUtils -> fRound ( $ dVat , $ this -> _oCurrency ) ; } $ oNotDiscounted = $ this -> getNotDiscountProductsPrice ( ) ; if ( $ this -> isCalculationModeNetto ( ) ) { $ this -> setNettoSum ( $ this -> getProductsPrice ( ) -> getSum ( ) ) ; $ this -> setBruttoSum ( $ oNotDiscounted -> getSum ( false ) + $ dDiscountedSum + $ dVatSum ) ; } else { $ this -> setNettoSum ( $ oNotDiscounted -> getSum ( ) + $ dDiscountedSum - $ dVatSum ) ; $ this -> setBruttoSum ( $ this -> getProductsPrice ( ) -> getSum ( false ) ) ; } } | Performs netto price and VATs calculations including discounts and vouchers . |
36,677 | public function isPriceViewModeNetto ( ) { $ blResult = ( bool ) \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'blShowNetPrice' ) ; $ oUser = $ this -> getBasketUser ( ) ; if ( $ oUser ) { $ blResult = $ oUser -> isPriceViewModeNetto ( ) ; } return $ blResult ; } | Returns true if view mode is netto |
36,678 | protected function _getPriceObject ( ) { $ oPrice = oxNew ( \ OxidEsales \ Eshop \ Core \ Price :: class ) ; if ( $ this -> isCalculationModeNetto ( ) ) { $ oPrice -> setNettoPriceMode ( ) ; } else { $ oPrice -> setBruttoPriceMode ( ) ; } return $ oPrice ; } | Returns prepared price object depending on view mode |
36,679 | protected function _calcBasketDiscount ( ) { $ this -> _aDiscounts = [ ] ; $ dOldPrice = $ this -> _oDiscountProductsPriceList -> getSum ( $ this -> isCalculationModeNetto ( ) ) ; if ( $ this -> _oTotalDiscount !== null && isset ( $ this -> _isForOrderRecalculation ) && $ this -> _isForOrderRecalculation ) { $ oTotalPrice = $ this -> getTotalDiscount ( ) ; $ oDiscount = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Discount :: class ) ; $ oDiscount -> oxdiscount__oxaddsum = new \ OxidEsales \ Eshop \ Core \ Field ( $ oTotalPrice -> getPrice ( ) ) ; $ oDiscount -> oxdiscount__oxaddsumtype = new \ OxidEsales \ Eshop \ Core \ Field ( 'abs' ) ; $ aDiscounts [ ] = $ oDiscount ; } else { $ aDiscounts = \ OxidEsales \ Eshop \ Core \ Registry :: get ( \ OxidEsales \ Eshop \ Application \ Model \ DiscountList :: class ) -> getBasketDiscounts ( $ this , $ this -> getBasketUser ( ) ) ; } if ( $ oPriceList = $ this -> getDiscountProductsPrice ( ) ) { $ this -> _aDiscountedVats = $ oPriceList -> getVatInfo ( $ this -> isCalculationModeNetto ( ) ) ; } foreach ( $ aDiscounts as $ oDiscount ) { $ oStdDiscount = $ oDiscount -> getSimpleDiscount ( ) ; if ( $ oDiscount -> oxdiscount__oxaddsumtype -> value == 'itm' ) { continue ; } $ oStdDiscount -> dDiscount = $ oDiscount -> getAbsValue ( $ dOldPrice ) ; $ dVatPart = 100 - $ oDiscount -> getPercentage ( $ dOldPrice ) ; if ( $ dOldPrice < $ oStdDiscount -> dDiscount ) { $ oStdDiscount -> dDiscount = $ dOldPrice ; $ dVatPart = 0 ; } foreach ( $ this -> _aDiscountedVats as $ sKey => $ dVat ) { $ this -> _aDiscountedVats [ $ sKey ] = \ OxidEsales \ Eshop \ Core \ Price :: percent ( $ dVat , $ dVatPart ) ; } if ( $ oStdDiscount -> dDiscount != 0 ) { $ this -> _aDiscounts [ $ oDiscount -> getId ( ) ] = $ oStdDiscount ; $ dOldPrice = $ dOldPrice - $ oStdDiscount -> dDiscount ; } } } | Loads basket discounts and calculates discount values . |
36,680 | protected function _calcBasketTotalDiscount ( ) { if ( $ this -> _oTotalDiscount === null || ( ! $ this -> isAdmin ( ) ) ) { $ this -> _oTotalDiscount = $ this -> _getPriceObject ( ) ; if ( is_array ( $ this -> _aDiscounts ) ) { foreach ( $ this -> _aDiscounts as $ oDiscount ) { if ( $ oDiscount -> sType == 'itm' ) { continue ; } $ this -> _oTotalDiscount -> add ( $ oDiscount -> dDiscount ) ; } } } } | Calculates total basket discount value . |
36,681 | protected function _calcPaymentCost ( ) { $ oPaymentPrice = oxNew ( \ OxidEsales \ Eshop \ Core \ Price :: class ) ; if ( ( $ this -> _sPaymentId = $ this -> getPaymentId ( ) ) ) { $ oPayment = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Payment :: class ) ; $ oPayment -> load ( $ this -> _sPaymentId ) ; $ oPayment -> calculate ( $ this ) ; $ oPaymentPrice = $ oPayment -> getPrice ( ) ; } return $ oPaymentPrice ; } | Payment cost calculation applying payment discount if available . |
36,682 | public function calculateBasket ( $ blForceUpdate = false ) { if ( ! $ this -> isEnabled ( ) ) { return ; } if ( $ blForceUpdate ) { $ this -> onUpdate ( ) ; } if ( ! ( $ this -> _blUpdateNeeded || $ blForceUpdate ) ) { return ; } $ this -> _aCosts = [ ] ; $ this -> _save ( ) ; $ this -> _clearBundles ( ) ; $ this -> _addBundles ( ) ; $ this -> _calcItemsPrice ( ) ; $ this -> _calcBasketDiscount ( ) ; $ this -> _calcBasketTotalDiscount ( ) ; $ this -> _calcVoucherDiscount ( ) ; $ this -> _applyDiscounts ( ) ; $ this -> setCost ( 'oxdelivery' , $ this -> _calcDeliveryCost ( ) ) ; $ this -> setCost ( 'oxwrapping' , $ this -> _calcBasketWrapping ( ) ) ; $ this -> setCost ( 'oxgiftcard' , $ this -> _calcBasketGiftCard ( ) ) ; $ this -> setCost ( 'oxpayment' , $ this -> _calcPaymentCost ( ) ) ; $ this -> _calcTotalPrice ( ) ; $ this -> formatDiscount ( ) ; $ this -> afterUpdate ( ) ; } | Executes all needed functions to calculate basket price and other needed info |
36,683 | public function removeVoucher ( $ sVoucherId ) { if ( isset ( $ this -> _aVouchers [ $ sVoucherId ] ) ) { $ oVoucher = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Voucher :: class ) ; $ oVoucher -> load ( $ sVoucherId ) ; $ oVoucher -> unMarkAsReserved ( ) ; unset ( $ this -> _aVouchers [ $ sVoucherId ] ) ; $ this -> onUpdate ( ) ; } } | Removes voucher from basket and unreserved it . |
36,684 | public function load ( ) { $ oUser = $ this -> getBasketUser ( ) ; if ( ! $ oUser ) { return ; } $ oBasket = $ oUser -> getBasket ( 'savedbasket' ) ; $ aSavedItems = $ oBasket -> getItems ( ) ; foreach ( $ aSavedItems as $ oItem ) { try { $ oSelList = $ oItem -> getSelList ( ) ; $ this -> addToBasket ( $ oItem -> oxuserbasketitems__oxartid -> value , $ oItem -> oxuserbasketitems__oxamount -> value , $ oSelList , $ oItem -> getPersParams ( ) , true ) ; } catch ( \ OxidEsales \ Eshop \ Core \ Exception \ ArticleException $ oEx ) { } } } | Populates current basket from the saved one . |
36,685 | protected function _save ( ) { if ( $ this -> isSaveToDataBaseEnabled ( ) ) { if ( $ oUser = $ this -> getBasketUser ( ) ) { $ oSavedBasket = $ oUser -> getBasket ( 'savedbasket' ) ; $ oSavedBasket -> delete ( ) ; foreach ( $ this -> _aBasketContents as $ oBasketItem ) { if ( ! $ oBasketItem -> isBundle ( ) && ! $ oBasketItem -> isDiscountArticle ( ) ) { $ oSavedBasket -> addItemToBasket ( $ oBasketItem -> getProductId ( ) , $ oBasketItem -> getAmount ( ) , $ oBasketItem -> getSelList ( ) , true , $ oBasketItem -> getPersParams ( ) ) ; } } } } } | Saves existing basket to database |
36,686 | protected function _findDelivCountry ( ) { $ myConfig = \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) ; $ oUser = $ this -> getBasketUser ( ) ; $ sDeliveryCountry = null ; if ( ! $ oUser ) { $ aHomeCountry = $ myConfig -> getConfigParam ( 'aHomeCountry' ) ; if ( $ myConfig -> getConfigParam ( 'blCalculateDelCostIfNotLoggedIn' ) && is_array ( $ aHomeCountry ) ) { $ sDeliveryCountry = current ( $ aHomeCountry ) ; } } else { if ( $ sCountryId = $ myConfig -> getGlobalParameter ( 'delcountryid' ) ) { $ sDeliveryCountry = $ sCountryId ; } elseif ( $ sAddressId = \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> getVariable ( 'deladrid' ) ) { $ oDeliveryAddress = oxNew ( \ OxidEsales \ Eshop \ Application \ Model \ Address :: class ) ; if ( $ oDeliveryAddress -> load ( $ sAddressId ) ) { $ sDeliveryCountry = $ oDeliveryAddress -> oxaddress__oxcountryid -> value ; } } if ( ! $ sDeliveryCountry ) { $ sDeliveryCountry = $ oUser -> oxuser__oxcountryid -> value ; } } return $ sDeliveryCountry ; } | Tries to fetch user delivery country ID |
36,687 | public function deleteBasket ( ) { $ this -> _aBasketContents = [ ] ; $ this -> getSession ( ) -> delBasket ( ) ; if ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'blPsBasketReservationEnabled' ) ) { $ this -> getSession ( ) -> getBasketReservations ( ) -> discardReservations ( ) ; } $ this -> _deleteSavedBasket ( ) ; } | Deletes user basket object from session |
36,688 | public function getPaymentId ( ) { if ( ! $ this -> _sPaymentId ) { $ this -> _sPaymentId = \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> getVariable ( 'paymentid' ) ; } return $ this -> _sPaymentId ; } | Get basket payment if payment id is not set try to get it from session |
36,689 | public function setShipping ( $ sShippingSetId = null ) { $ this -> _sShippingSetId = $ sShippingSetId ; \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> setVariable ( 'sShipSet' , $ sShippingSetId ) ; } | Set basket shipping set ID |
36,690 | public function getShippingId ( ) { if ( ! $ this -> _sShippingSetId ) { $ this -> _sShippingSetId = \ OxidEsales \ Eshop \ Core \ Registry :: getSession ( ) -> getVariable ( 'sShipSet' ) ; } $ sActPaymentId = $ this -> getPaymentId ( ) ; if ( ! $ this -> _sShippingSetId && $ sActPaymentId != 'oxempty' ) { $ oUser = $ this -> getUser ( ) ; list ( , $ sActShipSet ) = \ OxidEsales \ Eshop \ Core \ Registry :: get ( \ OxidEsales \ Eshop \ Application \ Model \ DeliverySetList :: class ) -> getDeliverySetData ( null , $ oUser , $ this ) ; $ this -> _sShippingSetId = $ sActShipSet ? $ sActShipSet : ( $ oUser ? null : 'oxidstandard' ) ; } elseif ( ! $ this -> isAdmin ( ) && $ sActPaymentId == 'oxempty' ) { $ this -> _sShippingSetId = null ; } return $ this -> _sShippingSetId ; } | Get basket shipping set if shipping set id is not set try to get it from session |
36,691 | public function getBasketArticles ( ) { $ aBasketArticles = [ ] ; foreach ( $ this -> _aBasketContents as $ sItemKey => $ oBasketItem ) { try { $ oProduct = $ oBasketItem -> getArticle ( true ) ; if ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'bl_perfLoadSelectLists' ) ) { $ aSelList = $ oBasketItem -> getSelList ( ) ; if ( is_array ( $ aSelList ) && ( $ aSelectlist = $ oProduct -> getSelectLists ( $ sItemKey ) ) ) { reset ( $ aSelList ) ; foreach ( $ aSelList as $ conkey => $ iSel ) { $ aSelectlist [ $ conkey ] [ $ iSel ] -> selected = 1 ; } $ oProduct -> setSelectlist ( $ aSelectlist ) ; } } } catch ( \ OxidEsales \ Eshop \ Core \ Exception \ NoArticleException $ oEx ) { \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsView ( ) -> addErrorToDisplay ( $ oEx ) ; $ this -> removeItem ( $ sItemKey ) ; $ this -> calculateBasket ( true ) ; continue ; } catch ( \ OxidEsales \ Eshop \ Core \ Exception \ ArticleInputException $ oEx ) { \ OxidEsales \ Eshop \ Core \ Registry :: getUtilsView ( ) -> addErrorToDisplay ( $ oEx ) ; $ this -> removeItem ( $ sItemKey ) ; $ this -> calculateBasket ( true ) ; continue ; } $ aBasketArticles [ $ sItemKey ] = $ oProduct ; } return $ aBasketArticles ; } | Returns array of basket oxarticle objects |
36,692 | public function getProductsPrice ( ) { if ( is_null ( $ this -> _oProductsPriceList ) ) { $ this -> _oProductsPriceList = oxNew ( \ OxidEsales \ Eshop \ Core \ PriceList :: class ) ; } return $ this -> _oProductsPriceList ; } | Returns basket products price list object |
36,693 | public function getPrice ( ) { if ( is_null ( $ this -> _oPrice ) ) { $ price = oxNew ( \ OxidEsales \ Eshop \ Core \ Price :: class ) ; $ this -> setPrice ( $ price ) ; } return $ this -> _oPrice ; } | Returns basket price object |
36,694 | public function getCosts ( $ sId = null ) { if ( $ sId ) { return isset ( $ this -> _aCosts [ $ sId ] ) ? $ this -> _aCosts [ $ sId ] : null ; } return $ this -> _aCosts ; } | Returns array of basket costs . By passing cost identifier method will return this cost if available |
36,695 | public function getItemsCount ( ) { $ itemsCount = 0 ; foreach ( $ this -> _aBasketContents as $ oBasketItem ) { $ itemsCount += $ oBasketItem -> getAmount ( ) ; } return $ itemsCount ; } | Returns count of items stored in basket . |
36,696 | public function getWeight ( ) { $ weight = 0 ; foreach ( $ this -> _aBasketContents as $ oBasketItem ) { $ weight += $ oBasketItem -> getWeight ( ) ; } return $ weight ; } | Returns total basket weight . |
36,697 | public function getProductVats ( $ blFormatCurrency = true ) { if ( ! $ this -> _oNotDiscountedProductsPriceList ) { return [ ] ; } $ aVats = $ this -> _oNotDiscountedProductsPriceList -> getVatInfo ( $ this -> isCalculationModeNetto ( ) ) ; $ oUtils = \ OxidEsales \ Eshop \ Core \ Registry :: getUtils ( ) ; foreach ( ( array ) $ this -> _aDiscountedVats as $ sKey => $ dVat ) { if ( ! isset ( $ aVats [ $ sKey ] ) ) { $ aVats [ $ sKey ] = 0 ; } $ aVats [ $ sKey ] += $ oUtils -> fRound ( $ dVat , $ this -> _oCurrency ) ; } if ( $ blFormatCurrency ) { $ oLang = \ OxidEsales \ Eshop \ Core \ Registry :: getLang ( ) ; foreach ( $ aVats as $ sKey => $ dVat ) { $ aVats [ $ sKey ] = $ oLang -> formatCurrency ( $ dVat , $ this -> getBasketCurrency ( ) ) ; } } return $ aVats ; } | Returns array of plain of formatted VATs which were calculated for basket |
36,698 | public function getDiscounts ( ) { if ( $ this -> getTotalDiscount ( ) && $ this -> getTotalDiscount ( ) -> getBruttoPrice ( ) == 0 && count ( $ this -> _aItemDiscounts ) == 0 ) { return [ ] ; } return array_merge ( $ this -> _aItemDiscounts , $ this -> _aDiscounts ) ; } | Returns applied discount information array |
36,699 | public function getVoucherDiscount ( ) { if ( \ OxidEsales \ Eshop \ Core \ Registry :: getConfig ( ) -> getConfigParam ( 'bl_showVouchers' ) ) { return $ this -> _oVoucherDiscount ; } return null ; } | Returns basket voucher discount price object |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.