$billingAddress =
$order->
getBillingAddress();
$countryStateId = null;
if ($billingAddress) { $countryStateId =
$billingAddress->
getCountryStateId();
} $options =
[ SalesChannelContextService::CURRENCY_ID =>
$order->
getCurrencyId(),
SalesChannelContextService::LANGUAGE_ID =>
$order->
getLanguageId(),
SalesChannelContextService::CUSTOMER_ID =>
$order->
getOrderCustomer()->
getCustomerId(),
SalesChannelContextService::COUNTRY_STATE_ID =>
$countryStateId,
SalesChannelContextService::CUSTOMER_GROUP_ID =>
$customerGroupId,
SalesChannelContextService::PERMISSIONS => OrderConverter::ADMIN_EDIT_ORDER_PERMISSIONS,
SalesChannelContextService::VERSION_ID =>
$context->
getVersionId(),
];
if ($paymentMethodId =
$this->
getPaymentMethodId($order)) { $options[SalesChannelContextService::PAYMENT_METHOD_ID
] =
$paymentMethodId;
} $delivery =
$order->
getDeliveries() !== null ?
$order->
getDeliveries()->
first() : null;