nopSolutions/nopCommerce · error · NopException

Shipping is required, but address is not available. Order ID

Error message

Shipping is required, but address is not available. Order ID = {order.Id}

What it means

Thrown by GetShippingAddressAsync (used during PDF invoice/order print generation) when an order requires shipping (ShippingStatus != ShippingNotRequired), is not a pickup-in-store order, yet has no ShippingAddressId or the address lookup returns null. It indicates an inconsistent order record: the system believes the order must ship but no destination address exists.

Source

Thrown at src/Libraries/Nop.Services/Common/PdfService.cs:265

        return (fontName, fontSize);
    }

    /// <summary>
    /// Get shipping address
    /// </summary>
    /// <param name="lang">Language</param>
    /// <param name="order">Order</param>
    /// <returns>A task that contains address item</returns>
    protected virtual async Task<AddressItem> GetShippingAddressAsync(Language lang, Order order)
    {
        var addressResult = new AddressItem();

        if (order.ShippingStatus != ShippingStatus.ShippingNotRequired)
        {
            if (!order.PickupInStore)
            {
                if (order.ShippingAddressId == null || await _addressService.GetAddressByIdAsync(order.ShippingAddressId.Value) is not Address shippingAddress)
                    throw new NopException($"Shipping is required, but address is not available. Order ID = {order.Id}");

                if (!string.IsNullOrEmpty(shippingAddress.Company))
                    addressResult.Company = shippingAddress.Company;

                addressResult.Name = $"{shippingAddress.FirstName} {shippingAddress.LastName}";

                if (_addressSettings.PhoneEnabled)
                    addressResult.Phone = shippingAddress.PhoneNumber;

                if (_addressSettings.FaxEnabled && !string.IsNullOrEmpty(shippingAddress.FaxNumber))
                    addressResult.Fax = shippingAddress.FaxNumber;

                if (_addressSettings.StreetAddressEnabled)
                    addressResult.Address = shippingAddress.Address1;

                if (_addressSettings.StreetAddress2Enabled && !string.IsNullOrEmpty(shippingAddress.Address2))
                    addressResult.Address2 = shippingAddress.Address2;

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Inspect the offending order's ShippingAddressId and ShippingStatus columns; if the address was deleted, restore or reassign a valid address row.
  2. If the order genuinely needs no shipping, correct its ShippingStatus to ShippingNotRequired so the PDF path skips the address lookup.
  3. Guard the PDF-generation caller: skip or render a placeholder when order.ShippingAddressId is null for a shipping-required order, rather than letting the exception surface to the print job.
  4. Audit the custom checkout/integration that created the order to ensure it always persists the shipping address when shipping is required.

Example fix

// before
var pdf = await _pdfService.PrintOrderToPdfAsync(order, languageId);

// after
if (order.ShippingStatus != ShippingStatus.ShippingNotRequired
    && !order.PickupInStore
    && order.ShippingAddressId is null)
{
    _logger.LogWarning("Order {Id} marked shipping-required but has no address; skipping PDF", order.Id);
    return;
}
var pdf = await _pdfService.PrintOrderToPdfAsync(order, languageId);
Defensive patterns

Strategy: validation

Validate before calling

if (order.ShippingStatus != ShippingStatus.ShippingNotRequired
    && !order.PickupInStore
    && (order.ShippingAddressId is null
        || await _addressService.GetAddressByIdAsync(order.ShippingAddressId.Value) is null))
{
    _logger.LogWarning("Order {Id} shipping-required but address missing", order.Id);
    return; // skip PDF
}

Try / catch

try { await _pdfService.PrintOrderToPdfAsync(order, langId); }
catch (NopException ex) when (ex.Message.Contains("Shipping is required"))
{ _logger.LogError(ex, "Cannot print order {Id}: missing shipping address", order.Id); }

Prevention

When it happens

Trigger: Generating a PDF invoice/order print for an order whose ShippingAddressId is null, or whose referenced address was deleted from the Address table. Occurs inside the PDF rendering pipeline when the order's shipping status is NotYetShipped/PartiallyShipped/Shipped but the address row is gone.

Common situations: Data corruption or manual DB edits that removed address rows; a migration bug that dropped addresses; an order created through a custom checkout flow that never persisted the shipping address while marking shipping required.

Related errors


AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13). Data as JSON: /api/errors/784035c9cc2ea5a2. Report an issue: GitHub.