Help for integrating the Laravel package
Forum rules: Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#4482 by bill
10 Aug 2017, 16:04

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?
#4485 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:
#4500 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.