Question about Basket loading

Hello,

I am trying to finish a payment module. (on Oxid 4.6.5_49955)

When the customer make his payment and click on the link to get back to the shop (on the website of bank), module send an email with informations about order (order references, articles, payment…).

But if customer don’t click on this link and close the bank page’s, I will never receive this email.

So I am trying to get back informations to send this mail when the bank notify us about the payment (server to server). So I don’t got in session all the informations to send the email.

I have only got the order ID to get back all informations.
This is how I get Order, User and Payment references :

// Get order and save status as OK
$oOrder = oxNew('oxorder');
$oOrder->load($_POST['reference']); // Id of Order
$oOrder->oxorder__oxtransstatus = new oxField('OK');
$oOrder->save(); 

// Loading User
$oUser = oxNew( 'oxuser' );
$oUser->load($oOrder->oxorder__oxuserid->rawValue);

// Loading Payment
$oPayment = oxNew( 'oxpayment' );
$oPayment->load($oOrder->oxorder__oxpaymenttype->rawValue);

// Loading Basket
$oOrderArticles = $oOrder->getOrderArticles();
$oBasket = oxNew( 'oxbasket' );
$oOrder->_addOrderArticlesToBasket($oBasket, $oOrderArticles);

It seems to work for Order, User and Payment
But impossible to fill the Basket with Order Articles data.

Do you know if exist an easy way to do this ? (like a magical function getLastUserSession()) ?
Or how to fill the Basket ? :confused:

Thank you :slight_smile:

Hi @crea60,

did you try the tobasket function?
http://docu.oxid-esales.com/CE/sourcecodedocumentation/4.8.5.6fd00216aba774e84700d892fe7c037753ecb0e3/classoxcmp__basket.html#a9230b87ae64707108af3414968473ca0

Cheers

Hi Marco,

To populate with a loop the basket object ?

Regards

Crea60,

actually I’m not a dev, can just pinpoint the one or other function… My hint is - just check out if you get a result in the tpl at all.

Cheers!

If I understood it correctly you are trying to load an existing order from the database. Next you want to create a basket object from that data. This sounds a lot like what the recalculateOrder-method does: http://docu.oxid-esales.com/CE/sourcecodedocumentation/4.6.5.49955/classox_order.html#a66c07157a72791986ec46c92000c5840
However there are some known issues concerning this order recalculation: https://bugs.oxid-esales.com/view.php?id=4624
So you might want to consider implementing your own getOrderBasket-method: http://docu.oxid-esales.com/CE/sourcecodedocumentation/4.6.5.49955/classox_order.html#adb079d5999c61b1aa8e3aedc76dfb4f4

Hi Martin,

If I try to put this code :

$oOrderArticles = $oOrder->getOrderArticles(true);
$oBasket = oxNew( 'oxbasket' );
$oOrder->_addOrderArticlesToBasket($oBasket, $oOrderArticles);

I got blank page instead of showing some data (print for debug), with this notice :

Notice: Undefined offset: 2 in /home/www/.../web/core/oxutils.php on line 657

If I read this file at this line I got :

    public function commitFileCache()
    {
(line 657)      if ( count( $this->_aLockedFileHandles[LOCK_EX] ) ) {

:confused: