Ecommerce - abort an order


#1

In the Ecommerce bundle how do I abort an order (say customer has chaged her mind between confirmation an payment)?


#2

Hi,
depends, if order object already has been created.
If yes, you can just change order state in order object:

$order->setOrderState(AbstractOrder::ORDER_STATE_ABORTED);
$order->save(['versionNote' => 'CommitOrderProcessor::cleanUpPendingOrders - set state to aborted.']);

If payment is already started, you probably want to cancel payment too.
This can be done with OrderAgent cancelStartedOrderPayment() method.

BR
Christian


#3

Great thanks - I’ll give that a go.