OXID Community Forum

> International Forums > Modules > 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

Thread: add the products of a previously placed order to the basket (download link)


Reply
 
Thread Tools Display Modes
#Top   #11  
Old 03-22-2009, 02:05 PM
rdx rdx is offline
Junior Member
Join Date: Jan 2009
Posts: 26
rdx is on a distinguished road
Default hi mathias,

hi mathias,
thanks a lot. yes, i found this in the code, but i will not change anything in the core-classes (update). i extended oxcmp_basket. it only took a few lines of code and seems to work pretty well.
Reply With Quote
#Top   #12  
Old 03-23-2009, 06:47 PM
rdx rdx is offline
Junior Member
Join Date: Jan 2009
Posts: 26
rdx is on a distinguished road
Default hi,

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]
Reply With Quote
#Top   #13  
Old 03-23-2009, 09:19 PM
MaFi MaFi is offline
Member
Join Date: Oct 2008
Posts: 51
MaFi is on a distinguished road
Default goooood

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
Reply With Quote
#Top   #14  
Old 03-23-2009, 10:09 PM
rdx rdx is offline
Junior Member
Join Date: Jan 2009
Posts: 26
rdx is on a distinguished road
Default hi mathias, of course i will

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
Reply With Quote
#Top   #15  
Old 03-23-2009, 10:40 PM
rdx rdx is offline
Junior Member
Join Date: Jan 2009
Posts: 26
rdx is on a distinguished road
Default i used

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 With Quote
#Top   #16  
Old 03-24-2009, 12:09 AM
MaFi MaFi is offline
Member
Join Date: Oct 2008
Posts: 51
MaFi is on a distinguished road
Default ups

oh even better ... I haven't seen that very good! now I'm really looking forward to use your module
Reply With Quote
#Top   #17  
Old 03-24-2009, 11:46 AM
rdx rdx is offline
Junior Member
Join Date: Jan 2009
Posts: 26
rdx is on a distinguished road
Default hi mathias, first version :)

hi mathias,first version of the module is ready - just some testing.

if you like, i could send it to you.regards.
Reply With Quote
#Top   #18  
Old 03-28-2009, 10:07 PM
rdx rdx is offline
Junior Member
Join Date: Jan 2009
Posts: 26
rdx is on a distinguished road
Default hi, here is a link to

hi,

here is a link to download the module: Reorder

regards,
ralf
Reply With Quote
Reply

Bookmarks

Tags
add, basket, download, link, order, previously, products

« Previous Thread | Next Thread »
Thread Tools
Display Modes

Nicht Sichtbar
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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

All times are GMT +2. The time now is 05:11 PM.