$billingAddressId =
$order->
getBillingAddressId();
$billingAddress =
$this->orderAddressRepository->
search(new Criteria([$billingAddressId]),
$context)->
get($billingAddressId);
if (!
$billingAddress instanceof OrderAddressEntity
) { throw CartException::
addressNotFound($billingAddressId);
} $options =
[ SalesChannelContextService::CURRENCY_ID =>
$order->
getCurrencyId(),
SalesChannelContextService::LANGUAGE_ID =>
$order->
getLanguageId(),
SalesChannelContextService::CUSTOMER_ID =>
$customerId,
SalesChannelContextService::COUNTRY_STATE_ID =>
$billingAddress->
getCountryStateId(),
SalesChannelContextService::CUSTOMER_GROUP_ID =>
$customerGroupId,
SalesChannelContextService::PERMISSIONS => self::ADMIN_EDIT_ORDER_PERMISSIONS,
SalesChannelContextService::VERSION_ID =>
$context->
getVersionId(),
];
/** @var OrderDeliveryEntity|null $delivery */
$delivery =
$order->
getDeliveries()?->
first();
if ($delivery !== null
) { $options[SalesChannelContextService::SHIPPING_METHOD_ID
] =
$delivery->
getShippingMethodId();
}