Change/ update order with new payment

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
bill
Posts: 51
Joined: 24 Apr 2017, 17:51

Change/ update order with new payment

Post by bill » 10 Aug 2017, 16:04

Hi

Currently in Aimeos , if you are in checkout and you selected for example Paypal , it creates an order ID and redirects you to Paypal , but what I noticed if you cancel and it takes you back to the confirmation page where you can change the payment, if you click on change payment , it will take you to select a new payment , if I selected a different payment I noticed that Aimeos Creates a NEW order ID for that new payment.

MY Question: Is there away to have it where we can Updates the same OrderID which is stored in the session with the NEW payment without creating a whole new order?

I am looking at this code with is in Payment.php class:

Code: Select all

$orderId = $context->getSession()->get( 'aimeos/orderid' );
 $orderItem = $orderCntl->getItem($orderId,false);
// can we update the PAYMENT HERE? which function will update the order with new payment 
How we could do that is it possible?

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Change/ update order with new payment

Post by aimeos » 10 Aug 2017, 22:58

It would be easier to delete the existing order and create a new one from the basket in the session because after the payment option changes, the basket total and the records in the mshop_order_base_service table needs to be replaced:
https://github.com/aimeos/ai-client-htm ... d.php#L273
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

bill
Posts: 51
Joined: 24 Apr 2017, 17:51

Re: Change/ update order with new payment

Post by bill » 14 Aug 2017, 15:09

Sounds like s good idea

but how do we delete the order? I cant find a function that would delete the order by the orderid?

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Change/ update order with new payment

Post by aimeos » 15 Aug 2017, 08:48

There's no controller method for this but you can use the order managers directly:

Code: Select all

$manager = \Aimeos\MShop\Factory::createManager( $context, 'order' );
$order = $manager->getItem( $orderId );
\Aimeos\MShop\Factory::createManager( $context, 'order/base' )->deleteItem( $order->getBaseId() );
Afterwards, the complete order is gone. If you have the order base ID, you only need the last line.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

bill
Posts: 51
Joined: 24 Apr 2017, 17:51

Re: Change/ update order with new payment

Post by bill » 15 Aug 2017, 15:29

Great

Thanks

Post Reply