{"record":{"id":"5a2acdcd241542eb","repo":"nopSolutions/nopCommerce","slug":"selected-shipping-method-can-t-be-loaded","errorCode":null,"errorMessage":"Selected shipping method can't be loaded","messagePattern":"Selected shipping method can't be loaded","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/Presentation/Nop.Web/Controllers/CheckoutController.cs","lineNumber":1859,"sourceCode":"            //find it\r\n            //performance optimization. try cache first\r\n            var shippingOptions = await _genericAttributeService.GetAttributeAsync<List<ShippingOption>>(customer,\r\n                NopCustomerDefaults.OfferedShippingOptionsAttribute, store.Id);\r\n            if (shippingOptions == null || !shippingOptions.Any())\r\n            {\r\n                //not found? let's load them using shipping service\r\n                shippingOptions = (await _shippingService.GetShippingOptionsAsync(cart, await _customerService.GetCustomerShippingAddressAsync(customer),\r\n                    customer, shippingRateComputationMethodSystemName, store.Id)).ShippingOptions.ToList();\r\n            }\r\n            else\r\n            {\r\n                //loaded cached results. let's filter result by a chosen shipping rate computation method\r\n                shippingOptions = shippingOptions.Where(so => so.ShippingRateComputationMethodSystemName.Equals(shippingRateComputationMethodSystemName, StringComparison.InvariantCultureIgnoreCase))\r\n                    .ToList();\r\n            }\r\n\r\n            var shippingOption = shippingOptions.Find(so => !string.IsNullOrEmpty(so.Name) && so.Name.Equals(selectedName, StringComparison.InvariantCultureIgnoreCase))\r\n                                 ?? throw new Exception(\"Selected shipping method can't be loaded\");\r\n\r\n            //parse DesiredDeliveryDate\r\n            var desiredDeliveryDate = await ParseSelectedShippingMethodDeliveryDateAsync(shippingOption, shippingOptions, form);\r\n            if (desiredDeliveryDate != null)\r\n                await _genericAttributeService.SaveAttributeAsync(customer, NopCustomerDefaults.DesiredDeliveryDate, desiredDeliveryDate, store.Id);\r\n\r\n            //save\r\n            await _genericAttributeService.SaveAttributeAsync(customer, NopCustomerDefaults.SelectedShippingOptionAttribute, shippingOption, store.Id);\r\n\r\n            //load next step\r\n            return await OpcLoadStepAfterShippingMethod(cart);\r\n        }\r\n        catch (Exception exc)\r\n        {\r\n            await _logger.WarningAsync(exc.Message, exc, await _workContext.GetCurrentCustomerAsync());\r\n            return Json(new { error = 1, message = exc.Message });\r\n        }\r\n    }\r","sourceCodeStart":1841,"sourceCodeEnd":1877,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Presentation/Nop.Web/Controllers/CheckoutController.cs#L1841-L1877","documentation":"Thrown by OpcSaveShippingMethod at line 1859 when the parsed shipping option name/systemName cannot be matched in the available shipping options list (cache via generic attribute, or freshly loaded via GetShippingOptionsAsync). The selected method does not exist for this cart/address/provider, so the Find returns null. Hardcoded literal message. The submitted selection is no longer valid.","triggerScenarios":"Client posts a valid 'Name___SystemName' but no matching ShippingOption exists: provider disabled, options not computed for the current address/cart, cache (OfferedShippingOptionsAttribute) stale, or the systemName doesn't match any active shipping rate computation method.","commonSituations":"Shipping provider disabled/removed after options were cached; address changed so options differ; cart contents changed so rates differ; provider plugin uninstalled; cached OfferedShippingOptions attribute from a previous address.","solutions":["Force a recompute of shipping options for the current cart/address before selection.","Ensure the selected shippingRateComputationMethodSystemName matches an active, registered provider.","Invalidate the cached OfferedShippingOptionsAttribute when address/cart changes.","Render the option list from the same GetShippingOptionsAsync source used server-side."],"exampleFix":"// before: posting a cached option whose provider is gone\n$.post('OpcSaveShippingMethod', { shippingoption: 'Ground___Shipping.NowRemoved' });\n// after: recompute and only send an offered option\nconst options = await fetchShippingOptions(cart, address); // server-side source\nconst pick = options[0];\n$.post('OpcSaveShippingMethod', { shippingoption: `${pick.Name}___${pick.ShippingRateComputationMethodSystemName}` });","handlingStrategy":"validation","validationCode":"// Recompute offered options for the current cart/address and only send one of them.\nvar offered = await _genericAttributeService\n    .GetAttributeAsync<List<ShippingOption>>(customer, NopCustomerDefaults.OfferedShippingOptionsAttribute, store.Id);\nif (offered == null || !offered.Any())\n    offered = (await _shippingService.GetShippingOptionsAsync(cart, shipAddress, customer, systemName, store.Id)).ShippingOptions.ToList();\nvar match = offered.Find(o => o.Name == selectedName);\nif (match == null) { /* re-render options, abort submit */ }","typeGuard":"function isOfferedShippingOption(value /*: string*/, offered /*: {Name:string;ShippingRateComputationMethodSystemName:string}[]*/) {\n  const [name, sys] = value.split('___');\n  return offered.some(o => o.Name === name && o.ShippingRateComputationMethodSystemName === sys);\n}","tryCatchPattern":"if (data.error && /shipping method can't be loaded/i.test(data.message)) {\n  await invalidateOfferedShippingCache();\n  await reloadShippingOptions();\n}","preventionTips":["Invalidate OfferedShippingOptionsAttribute when address/cart changes.","Render the option list from the same GetShippingOptionsAsync source as the server.","Confirm the provider systemName matches an active shipping rate computation method."],"tags":["checkout","opc","shipping","config","cache","validation","nopcommerce"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}