Ecommerce - abort an order


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


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

$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.



Great thanks - I’ll give that a go.