public ActionResult ShippingMethod()
        {
            var customer        = HttpContext.GetCustomer();
            var storeId         = AppLogic.StoreID();
            var cart            = CachedShoppingCartProvider.Get(customer, CartTypeEnum.ShoppingCart, storeId);
            var shippingAddress = EffectiveShippingAddressProvider.GetEffectiveShippingAddress(customer);
            var checkoutContext = PersistedCheckoutContextProvider.LoadCheckoutContext(customer);

            var shippingMethodModels = CachedShippingMethodCollectionProvider
                                       .Get(customer, shippingAddress, cart.CartItems, storeId)
                                       .Select(shippingMethod => new ShippingMethodRenderModel(
                                                   id: shippingMethod.Id,
                                                   name: shippingMethod.GetNameForDisplay(),
                                                   rateDisplay: GetShippingMethodRateDisplay(shippingMethod, customer, cart),
                                                   imageFileName: shippingMethod.ImageFileName));

            var selectedShippingMethodModel = shippingMethodModels
                                              .Where(shippingMethod => shippingMethod.Id == checkoutContext.SelectedShippingMethodId)
                                              .FirstOrDefault();

            var model = new SelectShippingMethodViewModel
            {
                RenderModel = new SelectShippingMethodRenderModel(
                    shippingMethods: shippingMethodModels,
                    selectedShippingMethod: selectedShippingMethodModel,
                    showShippingIcons: AppConfigProvider.GetAppConfigValue <bool>("ShowShippingIcons"),
                    cartIsAllFreeShipping: !AppConfigProvider.GetAppConfigValue <bool>("FreeShippingAllowsRateSelection") && cart.IsAllFreeShippingComponents(),
                    numberOfMethodsToShow: AppConfigProvider.GetAppConfigValue <int>("NumberOfShippingMethodsToDisplay"),
                    hideShippingOptions: AppConfigProvider.GetAppConfigValue <bool>("shipping.hide.options")),
                SelectedShippingMethodId = checkoutContext.SelectedShippingMethodId,
            };

            return(PartialView(ViewNames.ShippingMethodPartial, model));
        }
        public ActionResult ShippingMethod(SelectShippingMethodViewModel model)
        {
            var customer = HttpContext.GetCustomer();
            var storeId  = AppLogic.StoreID();

            if (!model.SelectedShippingMethodId.HasValue)
            {
                NoticeProvider.PushNotice("Please select a shipping method", NoticeType.Failure);
                return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout));
            }

            var cart            = CachedShoppingCartProvider.Get(customer, CartTypeEnum.ShoppingCart, storeId);
            var shippingAddress = EffectiveShippingAddressProvider.GetEffectiveShippingAddress(customer);
            var checkoutContext = PersistedCheckoutContextProvider.LoadCheckoutContext(customer);

            var shippingMethods = CachedShippingMethodCollectionProvider.Get(customer, shippingAddress, cart.CartItems, storeId);

            var selectedShippingMethod = shippingMethods
                                         .Where(shippingMethod => shippingMethod.Id == model.SelectedShippingMethodId)
                                         .FirstOrDefault();

            if (selectedShippingMethod == null)
            {
                NoticeProvider.PushNotice("Please select a shipping method", NoticeType.Failure);
                return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout));
            }

            SetShippingMethod(selectedShippingMethod, cart, customer);
            return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout));
        }
        public ActionResult ShippingMethod(SelectShippingMethodViewModel model)
        {
            var customer = HttpContext.GetCustomer();
            var storeId  = AppLogic.StoreID();

            if (!model.SelectedShippingMethodId.HasValue)
            {
                NoticeProvider.PushNotice(StringResourceProvider.GetString("checkoutshipping.aspx.17"), NoticeType.Failure);
                return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout));
            }

            var cart            = CachedShoppingCartProvider.Get(customer, CartTypeEnum.ShoppingCart, storeId);
            var shippingAddress = EffectiveShippingAddressProvider.GetEffectiveShippingAddress(customer);
            var checkoutContext = PersistedCheckoutContextProvider.LoadCheckoutContext(customer);

            var shippingMethods = CachedShippingMethodCollectionProvider.Get(customer, shippingAddress, cart.CartItems, storeId);

            var selectedShippingMethod = shippingMethods
                                         .Where(shippingMethod => shippingMethod.Id == model.SelectedShippingMethodId)
                                         .FirstOrDefault();

            if (selectedShippingMethod == null)
            {
                NoticeProvider.PushNotice(StringResourceProvider.GetString("checkoutshipping.aspx.17"), NoticeType.Failure);
                return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout));
            }

            SetShippingMethod(selectedShippingMethod, cart, customer);

            if (AppConfigProvider.GetAppConfigValue <bool>("shipping.hide.options"))
            {
                return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout));
            }
            else
            {
                return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout, new { name = SelectShippingMethodViewModel.ShippingMethodSelected }));
            }
        }