Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Edgar Rasquin 326 posts 925 karma points
    Sep 01, 2021 @ 10:28
    Edgar Rasquin
    0

    currentShippingMethodId - Handling 'Sequence has no elements' Exception

    Hi Matt,

    we are encountering the following error:

        Zeile 14:     var nextStepPage = Model.GetNextStepPage();
    Zeile 15: 
    Zeile 16:     var currentShippingMethodId = currentOrder.ShippingInfo.ShippingMethodId.HasValue
    Zeile 17:         ? currentOrder.ShippingInfo.ShippingMethodId.Value
    Zeile 18:         : shippingCountry != null && shippingCountry.DefaultShippingMethodId.HasValue && shippingMethods.Any(x => x.Id == shippingCountry.DefaultShippingMethodId.Value)
    
    Quelldatei: D:\Umbraco\shop\App_Plugins\VendrCheckout\Views\VendrCheckoutShippingMethodPage.cshtml    Zeile: 16
    

    For some reason the currentShippingMethodId is null when currentOrder has an id and for example CountryId has a value.

    enter image description here

    What would be the easiest workaround?

    Thanks

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Sep 01, 2021 @ 12:24
    Matt Brailsford
    100

    Hi Edgar,

    My guess is this is coming from the shippingMethods property where .First() is called, but it would potentially appear that the collection is empty. Are you sure you have some shipping methods defined that have been configured to be allowed in the shippingCountryId?

    Matt

  • Edgar Rasquin 326 posts 925 karma points
    Sep 01, 2021 @ 12:24
    Edgar Rasquin
    0

    Problem solved.

    I did not set a Default Shipping Method for the selected country.

    enter image description here

    Is there a way of setting one shipping method as Default in all countries? Since we have vreated all countries from ISO 3166 this would be a rather time consuming task to set the Default Shipping Method individually.

    Thanks

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Sep 01, 2021 @ 12:27
    Matt Brailsford
    1

    Hi Edgar,

    Unfortunately not. This currently need to be set manually, or via code. You could write some quick code to loop through all the countries and set it's default shipping method if not set.

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft