Example #1
0
        public async Task <ActionResult> SetShippingMethodsJson(string shippingMethodCode)
        {
            await _cartBuilder.GetOrCreateNewTransientCartAsync(WorkContext.CurrentStore, WorkContext.CurrentCustomer, WorkContext.CurrentLanguage, WorkContext.CurrentCurrency);

            var shippingMethods = await _cartApi.CartModuleGetShipmentMethodsAsync(WorkContext.CurrentCart.Id);

            var shippingMethod = shippingMethods.FirstOrDefault(sm => sm.ShipmentMethodCode == shippingMethodCode);

            if (shippingMethod != null)
            {
                await _cartBuilder.AddShipmentAsync(shippingMethod.ToWebModel());

                await _cartBuilder.SaveAsync();
            }

            return(Json(null, JsonRequestBehavior.AllowGet));
        }