Page 1 of 1

Change/ update order with new payment

Posted: 10 Aug 2017, 16:04
by bill
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?

Re: Change/ update order with new payment

Posted: 10 Aug 2017, 22:58
by aimeos
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

Re: Change/ update order with new payment

Posted: 14 Aug 2017, 15:09
by bill
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?

Re: Change/ update order with new payment

Posted: 15 Aug 2017, 08:48
by aimeos
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.

Re: Change/ update order with new payment

Posted: 15 Aug 2017, 15:29
by bill
Great

Thanks