$this->
createAddresses($params,
$order);
// Generate an order number if none was provided. Doing it after validation since
// the generation of the order number cannot be reverted in a simple manner.
if ($order->
getNumber() === null
) { $orderNumberGenerator =
Shopware()->
Container()->
get(NumberRangeIncrementerInterface::
class);
$orderNumber =
$orderNumberGenerator->
increment('invoice'
);
$order->
setNumber((string) $orderNumber);
foreach ($order->
getDetails() as $detail) { $detail->
setNumber((string) $orderNumber);
} } $this->
getManager()->
persist($order);
$this->
flush();
return $order;
} /**
* @param string $number
* @param array<string, mixed> $params
*
* @throws CustomValidationException
* @throws NotFoundException
* @throws ParameterMissingException
* @throws PrivilegeException
* @throws ShopwareOrmException
* @throws ValidationException
*
* @return OrderModel
*/