private function handleAddresses(OrderInterface $order)
    {
        // If invoice address is no set : use the user's default one.
        if (null === $order->getInvoiceAddress()) {
            $order->setInvoiceAddress(
                $this->getOrderUserDefaultAddress($order)
            );
        }

        // If delivery address is no set and not "same delivery address" : use the user's default one.
        if ((null === $order->getDeliveryAddress()) && !$order->getSameAddress()) {
            $order->setDeliveryAddress(
                $this->getOrderUserDefaultAddress($order)
            );
        }
        // Else if delivery address is set and "same delivery address"
        elseif ((null !== $deliveryAddress = $order->getDeliveryAddress()) && $order->getSameAddress()) {
            // Unset delivery address
            $order->setDeliveryAddress(null);
            // If the address is a clone (do not belong to a user)
            if (null === $deliveryAddress->getUser()) {
                // Delete the address
                $this->addressOperator->delete($deliveryAddress);
            }
        }

        // If type is order or quote, clone the addresses.
        if (in_array($order->getType(), [OrderTypes::TYPE_ORDER, OrderTypes::TYPE_QUOTE])) {
            // Clone invoice address if needed
            $invoiceAddress = $order->getInvoiceAddress();
            if (null !== $user = $invoiceAddress->getUser()) {
                $invoiceAddress = clone $invoiceAddress;
                $this->handleAddressIdentity($invoiceAddress, $user);
                $invoiceAddress->setUser(null);
                $order->setInvoiceAddress($invoiceAddress);
            }
            // Clone delivery address if needed
            if (!$order->getSameAddress()) {
                $deliveryAddress = $order->getDeliveryAddress();
                if (null !== $user = $deliveryAddress->getUser()) {
                    $deliveryAddress = clone $deliveryAddress;
                    $this->handleAddressIdentity($deliveryAddress, $user);
                    $deliveryAddress->setUser(null);
                    $order->setDeliveryAddress($deliveryAddress);
                }
            }
        }
    }