:
I already had an observer to save the client as a new client automatically after placing the order and before displaying the success page:
In event.xml (an existing observer that I made earlier)
<event name="sales_order_place_after">
<observer name="customcheckout_customer" instance="Dufry\CustomCheckout\Model\Observer\SaveCustomer"/>
</event>
On the SaveCustomer.php observer (already existing observer that I did earlier):
$order = $observer->getOrder();
$increment = $order->getIncrementId();
if(strlen($increment) > 9){
$newIncrement = substr($increment, -8);
$newIncrement = substr($increment,0,1).$newIncrement;
$order->setIncrementId($newIncrement);
}
...
$order->save()
And it worked like a charm.
I did the second part of "substr" to save the prefix that was previously configured.
Sakai source
share