public ActionResult AddShippingRate(ShippingByTotalListModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings)) { return Json(new { Result = false, Message = _localizationService.GetResource("Plugins.Shipping.ByTotal.ManageShippingSettings.AccessDenied") }); } var zipPostalCode = model.AddZipPostalCode; if (zipPostalCode != null) { int zipMaxLength = ByTotalShippingComputationMethod.ZipPostalCodeMaxLength; zipPostalCode = zipPostalCode.Trim(); if (zipPostalCode.Length > zipMaxLength) { zipPostalCode = zipPostalCode.Substring(0, zipMaxLength); } } var shippingByTotalRecord = new ShippingByTotalRecord { ShippingMethodId = model.AddShippingMethodId, StoreId = model.AddStoreId, WarehouseId = model.AddWarehouseId, CountryId = model.AddCountryId, StateProvinceId = model.AddStateProvinceId, ZipPostalCode = zipPostalCode, DisplayOrder = model.AddDisplayOrder, From = model.AddFrom, To = model.AddTo, UsePercentage = model.AddUsePercentage, ShippingChargePercentage = (model.AddUsePercentage) ? model.AddShippingChargePercentage : 0, ShippingChargeAmount = (model.AddUsePercentage) ? 0 : model.AddShippingChargeAmount }; _shippingByTotalService.InsertShippingByTotalRecord(shippingByTotalRecord); return Json(new { Result = true }); }
public ActionResult SaveGeneralSettings(ShippingByTotalListModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings)) { return Json(new { Result = false, Message = _localizationService.GetResource("Plugins.Shipping.ByTotal.ManageShippingSettings.AccessDenied") }); } //save settings _shippingByTotalSettings.LimitMethodsToCreated = model.LimitMethodsToCreated; _settingService.SaveSetting(_shippingByTotalSettings); return Json(new { Result = true, Message = _localizationService.GetResource("Plugins.Shipping.ByTotal.ManageShippingSettings.Saved") }); }
public ActionResult Configure() { var shippingMethods = _shippingService.GetAllShippingMethods(); if (shippingMethods.Count == 0) { return Content("No shipping methods can be loaded"); } var model = new ShippingByTotalListModel(); // stores model.AvailableStores.Add(new SelectListItem() { Text = "*", Value = "0" }); foreach (var store in _storeService.GetAllStores()) { model.AvailableStores.Add(new SelectListItem() { Text = store.Name, Value = store.Id.ToString() }); } // warehouses model.AvailableWarehouses.Add(new SelectListItem() { Text = "*", Value = "0" }); foreach (var warehouse in _shippingService.GetAllWarehouses()) { model.AvailableWarehouses.Add(new SelectListItem() { Text = warehouse.Name, Value = warehouse.Id.ToString() }); } // shipping methods foreach (var sm in shippingMethods) { model.AvailableShippingMethods.Add(new SelectListItem() { Text = sm.Name, Value = sm.Id.ToString() }); } // countries model.AvailableCountries.Add(new SelectListItem() { Text = "*", Value = "0" }); var countries = _countryService.GetAllCountries(true); foreach (var c in countries) { model.AvailableCountries.Add(new SelectListItem() { Text = c.Name, Value = c.Id.ToString() }); } model.AvailableStates.Add(new SelectListItem() { Text = "*", Value = "0" }); model.LimitMethodsToCreated = _shippingByTotalSettings.LimitMethodsToCreated; model.PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode; return View("~/Plugins/Shipping.ByTotal/Views/ShippingByTotal/Configure.cshtml", model); }