nopSolutions/nopCommerce · error · Exception

Selected shipping method can't be parsed

Error message

Selected shipping method can't be parsed

What it means

Thrown by OpcSaveShippingMethod at line 1834 when the 'shippingoption' parameter is null or empty. nopCommerce expects a single string 'Name___ShippingRateComputationMethodSystemName' (split on the three-underscore _separator) and refuses empty input. Hardcoded literal message. The client failed to send any selected shipping method.

Source

Thrown at src/Presentation/Nop.Web/Controllers/CheckoutController.cs:1834

            //pickup point
            if (_shippingSettings.AllowPickupInStore && _orderSettings.DisplayPickupInStoreOnShippingMethodPage)
            {
                var pickupInStore = ParsePickupInStore(form);
                if (pickupInStore)
                {
                    var pickupOption = await ParsePickupOptionAsync(cart, form);
                    await SavePickupOptionAsync(pickupOption);

                    return await OpcLoadStepAfterShippingMethod(cart);
                }

                //set value indicating that "pick up in store" option has not been chosen
                await _genericAttributeService.SaveAttributeAsync<PickupPoint>(customer, NopCustomerDefaults.SelectedPickupPointAttribute, null, store.Id);
            }

            //parse selected method 
            if (string.IsNullOrEmpty(shippingoption))
                throw new Exception("Selected shipping method can't be parsed");
            var splittedOption = shippingoption.Split(_separator, StringSplitOptions.RemoveEmptyEntries);
            if (splittedOption.Length != 2)
                throw new Exception("Selected shipping method can't be parsed");
            var selectedName = splittedOption[0];
            var shippingRateComputationMethodSystemName = splittedOption[1];

            //find it
            //performance optimization. try cache first
            var shippingOptions = await _genericAttributeService.GetAttributeAsync<List<ShippingOption>>(customer,
                NopCustomerDefaults.OfferedShippingOptionsAttribute, store.Id);
            if (shippingOptions == null || !shippingOptions.Any())
            {
                //not found? let's load them using shipping service
                shippingOptions = (await _shippingService.GetShippingOptionsAsync(cart, await _customerService.GetCustomerShippingAddressAsync(customer),
                    customer, shippingRateComputationMethodSystemName, store.Id)).ShippingOptions.ToList();
            }
            else
            {

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Ensure the selected radio/hidden input posts a non-empty 'shippingoption'.
  2. Disable the submit button until a shipping method is selected.
  3. Verify the AJAX field name is exactly 'shippingoption' (case-sensitive).
  4. Confirm shipping rate computation methods returned options so one can be chosen.

Example fix

// before: empty payload
$.post('OpcSaveShippingMethod', { shippingoption: '' });
// after
const sel = document.querySelector('input[name=shippingoption]:checked');
if (!sel) { showError('Select a shipping method'); return; }
$.post('OpcSaveShippingMethod', { shippingoption: sel.value }); // e.g. 'Ground___Shipping.FixedByWeightByTotal'
Defensive patterns

Strategy: validation

Validate before calling

// Require a non-empty selected option before submitting.
const sel = document.querySelector('input[name=shippingoption]:checked');
if (!sel || !sel.value) { showError('Select a shipping method'); return; }

Type guard

function isValidShippingOptionInput(v /*: unknown*/) /*: v is string */ {
  return typeof v === 'string' && v.trim().length > 0 && v.split('___').filter(Boolean).length === 2;
}

Try / catch

if (data.error && /shipping method can't be parsed/i.test(data.message)) {
  highlightShippingOptions();
}

Prevention

When it happens

Trigger: POST to OpcSaveShippingMethod with shippingoption missing, null, or whitespace. Form/radio not bound, JS sent an empty value, or the user submitted without selecting a method.

Common situations: Shipping-method radio rendered without a value/unchecked on submit; AJAX payload field name mismatch (e.g. shippingOption vs shippingoption); custom theme forgetting to include the selected option; no shipping options available so none selected.

Related errors


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