{"record":{"id":"8418791ff3f0aca9","repo":"nopSolutions/nopCommerce","slug":"shipping-total-couldn-t-be-calculated","errorCode":null,"errorMessage":"Shipping total couldn't be calculated","messagePattern":"Shipping total couldn't be calculated","errorType":"validation","errorClass":"NopException","httpStatus":null,"severity":"error","filePath":"src/Libraries/Nop.Services/Orders/OrderProcessingService.cs","lineNumber":370,"sourceCode":"        details.OrderSubTotalInclTax = subTotalWithoutDiscountInclTax;\r\n        details.OrderSubTotalDiscountInclTax = discountAmountInclTax;\r\n\r\n        //discount history\r\n        foreach (var disc in appliedDiscounts)\r\n        {\r\n            if (!_discountService.ContainsDiscount(details.AppliedDiscounts, disc))\r\n                details.AppliedDiscounts.Add(disc);\r\n        }\r\n\r\n        //sub total (excl tax)\r\n        details.OrderSubTotalExclTax = subTotalWithoutDiscountExclTax;\r\n        details.OrderSubTotalDiscountExclTax = discountAmountExclTax;\r\n\r\n        //shipping total\r\n        var (orderShippingTotalInclTax, orderShippingTotalExclTax, _, shippingTotalDiscounts) = await _orderTotalCalculationService.GetShoppingCartShippingTotalsAsync(details.Cart);\r\n\r\n        if (!orderShippingTotalInclTax.HasValue || !orderShippingTotalExclTax.HasValue)\r\n            throw new NopException(\"Shipping total couldn't be calculated\");\r\n\r\n        details.OrderShippingTotalInclTax = orderShippingTotalInclTax.Value;\r\n        details.OrderShippingTotalExclTax = orderShippingTotalExclTax.Value;\r\n\r\n        foreach (var disc in shippingTotalDiscounts)\r\n        {\r\n            if (!_discountService.ContainsDiscount(details.AppliedDiscounts, disc))\r\n                details.AppliedDiscounts.Add(disc);\r\n        }\r\n\r\n        //payment total\r\n        var paymentAdditionalFee = await _paymentService.GetAdditionalHandlingFeeAsync(details.Cart, processPaymentRequest.PaymentMethodSystemName);\r\n        details.PaymentAdditionalFeeInclTax = (await _taxService.GetPaymentMethodAdditionalFeeAsync(paymentAdditionalFee, true, details.Customer)).price;\r\n        details.PaymentAdditionalFeeExclTax = (await _taxService.GetPaymentMethodAdditionalFeeAsync(paymentAdditionalFee, false, details.Customer)).price;\r\n\r\n        //tax amount\r\n        SortedDictionary<decimal, decimal> taxRatesDictionary;\r\n        (details.OrderTaxTotal, taxRatesDictionary) = await _orderTotalCalculationService.GetTaxTotalAsync(details.Cart);\r","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Libraries/Nop.Services/Orders/OrderProcessingService.cs#L352-L388","documentation":"Thrown when IOrderTotalCalculationService.GetShoppingCartShippingTotalsAsync returns null for either the tax-inclusive or tax-exclusive shipping total. This means the shipping rate computation engine could not produce a quote for the cart's selected shipping option, making it impossible to finalize the order's shipping cost.","triggerScenarios":"No shipping rate computation method is active/installed, the selected shipping option has no matching rate, the shipping address is in a zone not covered by any active provider, the cart weight/dimensions exceed configured limits, or the selected shipping option's generic attribute is stale after the provider was uninstalled.","commonSituations":"Fresh install where no shipping plugin is configured. The shipping provider was disabled in admin but the customer's session still references a now-invalid ShippingOption. Cart total weight is 0 or exceeds the provider's max weight. ShippingByTotal or ShippingByWeight plugin misconfigured. The 'Free shipping over X' setting combined with a shipping method that returns null when the threshold logic fails.","solutions":["Verify at least one shipping rate computation method is installed and active (Configuration > Shipping > Providers).","Re-select a shipping option on the checkout shipping step so the SelectedShippingOptionAttribute is refreshed.","Check the active shipping plugin's configuration (weight brackets, total brackets, geographic zones) covers the destination address.","Ensure cart items have weights assigned if using a weight-based provider.","Enable the TaxSettings and verify shipping tax calculation doesn't return null due to a missing tax provider."],"exampleFix":"// before: no active shipping provider, customer session has stale shipping option\n// after: configure a shipping provider, force re-selection:\nawait _genericAttributeService.SaveAttributeAsync(customer,\n    NopCustomerDefaults.SelectedShippingOptionAttribute, null, storeId);","handlingStrategy":"validation","validationCode":"// Before PlaceOrder, verify a shipping quote is available\nvar shippingOption = await _genericAttributeService\n    .GetAttributeAsync<ShippingOption>(customer,\n        NopCustomerDefaults.SelectedShippingOptionAttribute, storeId);\nif (shippingOption == null)\n{\n    // no option selected; redirect to shipping step\n    return RedirectToRoute(\"CheckoutShippingAddress\");\n}\n// Optionally re-query rates to confirm they're still valid\nvar (inclTax, exclTax, _, _) = await _orderTotalCalculationService\n    .GetShoppingCartShippingTotalsAsync(cart);\nif (!inclTax.HasValue || !exclTax.HasValue)\n{\n    _notificationService.ErrorNotification(\"Shipping to your address is unavailable.\");\n    return RedirectToRoute(\"CheckoutShippingMethod\");\n}","typeGuard":"bool ShippingTotalsAvailable(decimal? inclTax, decimal? exclTax) =>\n    inclTax.HasValue && exclTax.HasValue;","tryCatchPattern":"try\n{\n    var result = await _orderProcessingService.PlaceOrderAsync(processPaymentRequest);\n}\ncatch (NopException ex) when (ex.Message == \"Shipping total couldn't be calculated\")\n{\n    // clear stale shipping option and redirect\n    await _genericAttributeService.SaveAttributeAsync<ShippingOption>(customer,\n        NopCustomerDefaults.SelectedShippingOptionAttribute, null, storeId);\n    _notificationService.ErrorNotification(\"Please re-select a shipping method.\");\n    return RedirectToRoute(\"CheckoutShippingMethod\");\n}","preventionTips":["Always configure at least one active shipping rate computation method in a production store.","On the checkout shipping method step, re-fetch live rates rather than relying on cached/stale session data.","Ensure cart items have non-zero weights when using weight-based shipping providers.","Monitor shipping provider API health and fail gracefully with a user-visible message if the provider is unreachable.","Add a checkout guard that blocks proceeding to payment if no shipping option is selected."],"tags":["nopcommerce","shipping","order-total","configuration","order-processing"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}