OXID Community Forum> add the products of a previously placed order to the basket (download link) |
Login |
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Reply |
|
|
|
Thread Tools | Display Modes |
|
hi,
so this is my first module, i would like to post the code here. maybe some more experienced members have some improvements. the purpose of this little module is to put a button 'add to cart' under each order in account-order-history. by clicking this button the articles of the order are added to the basket. regards. added this to account_order.tpl: [code type="smarty"] [{foreach from=$oView->getOrderList() item=order }] [{ $oViewConf->getHiddenSid() }] [{ $oViewConf->getNavFormParams() }] ... [{/foreach }] [/code] [code type="php"] class ext_oxorder extends ext_oxorder_parent { public function makeSelListArray( $sArtId = null, $sOrderArtSelList = null ) { $this->_makeSelListArray( $sArtId, $sOrderArtSelList ); } } [/code] [code type="php"] // oxcmp_basket => reorder/ext_oxcmp_basket // oxorder => reorder/ext_oxorder class ext_oxcmp_basket extends ext_oxcmp_basket_parent { const OverwriteArticleAmount = false; public function reorder() { if ( oxUtils::getInstance()->isSearchEngine() ) return; $myConfig = $this->getConfig(); $sOrderNr = oxConfig::getParameter( 'oxordernr' ); $oUser = $this->getUser(); if ( !$oUser ) return; $oOrderList = $oUser->getOrders(); $oCurOrder = null; foreach( $oOrderList as $oOrder ) if ( $oOrder->oxorder__oxordernr->value == $sOrderNr ) { $oCurOrder = $oOrder; break; } if ( !$oCurOrder ) return; $oOrderArticleList = $oOrder->getOrderArticles(); $oArticleList = oxNew( 'oxarticlelist' ); $oArticleList->loadOrderArticles( array( $oCurOrder->getId() => $oCurOrder ) ); $aArticles = array(); foreach( $oOrderArticleList as $oOrderArticle ) { $oCurArticle = $oArticleList[ $oOrderArticle->oxorderarticles__oxartid->value ]; if ( !$oCurArticle->isBuyable() ) continue; $sArtId = $oOrderArticle->oxorderarticles__oxartid->value; $dAmount = $oOrderArticle->oxorderarticles__oxamount->value; $sSelVariant = $oOrderArticle->oxorderarticles__oxselvariant->value; $aSelVariant = $oOrder->makeSelListArray( $sArtId, $sSelVariant ); $aPersParam = ( ( $oOrderArticle->oxorderarticles__oxpersparam->value ) ? unserialize( $oOrderArticle->oxorderarticles__oxpersparam->value ) : null ); $aArticleInfo[ 'aid' ] = $sArtId; $aArticleInfo[ 'am' ] = $dAmount; $aArticleInfo[ 'sel' ] = $aSelVariant; $aArticleInfo[ 'persparam' ] = $aPersParam; $aArticleInfo[ 'override' ] = self::OverwriteArticleAmount; $aArticles[ $sArtId ] = $aArticleInfo; } if ( count( $aArticles ) ) { $oBasketItem = $this->_addItems( $aArticles ); if ( $oBasketItem && $myConfig->getConfigParam( 'iNewBasketItemMessage' ) != 0 ) { $oNewItem = new OxstdClass(); $oNewItem->sTitle = $oBasketItem->getTitle(); $oNewItem->sId = $oBasketItem->getProductId(); $oNewItem->dAmount = $oBasketItem->getAmount(); $oNewItem->dBundledAmount = $oBasketItem->getdBundledAmount(); oxSession::setVar( '_newitem', $oNewItem ); } $sReturn = $this->_getRedirectUrl(); } else $sReturn = ''; return $sReturn; } } [/code] |
|||
|
just a few hints what you could change ... you don't need to if it works ( I haven't tried it yet)
I would have done it in a different way getting the article ids in the same way as u but then using oxbasket->addToBasket function to add the articles again to basket. Additionally you could add OverwriteArticleAmount to the config.inc.php or to the config table. Basically thats a cool solution and I actually need the same functionality in a project, so will you make a full module out of this code and publish it open source? I could help u with this if you want. If not, would u allow me to reuse some of your lines to make this as a module myself? Greetings Mathias |
|||
|
hi mathias,of course i will make a full module out of it. if you would like to help me - great.
just tell me which functionality you would add to it.my last decision was either using this approach or the oxbasket->addToBasket function. i will have a look at the code again - maybe i missed something. regards,ralf |
|||
|
i used oxcmp_basket->_additems, because it uses oxbasket->addToBasket but also implements an exception-handling. i thought if itsnecessary to update this, oxid will take care of it
. but if you have a better solution - we'll use that one.
|
|||
| Reply |
|
| Bookmarks |
| Tags |
| add, basket, download, link, order, previously, products |
| Thread Tools | |
| Display Modes | |
|
Nicht Sichtbar
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Optische Aenderung im Warenkorb (basket.tpl) | m.streiber | Templates und Design | 1 | 04-28-2010 04:25 PM |
| Basket/Order can be send to other person for ordering | didi | Feature requests | 5 | 03-08-2010 11:54 AM |
| to Basket popup Problem IE6 | Chrif | Templates und Design | 3 | 12-11-2009 04:56 PM |
| Frage zu basket.tpl | Roger | Newbies | 1 | 04-24-2009 12:56 PM |
| Datei-Download: Fehlermeldung im Link (missing argument getPictureUrl) | oliverdroese | Installation und Konfiguration | 1 | 03-01-2009 09:12 PM |