/// <summary> /// Delete the shipping by weight record /// </summary> /// <param name="shippingByWeightRecord">Shipping by weight record</param> public virtual void DeleteShippingByWeightRecord(ShippingByWeightByTotalRecord shippingByWeightRecord) { if (shippingByWeightRecord == null) { throw new ArgumentNullException(nameof(shippingByWeightRecord)); } _sbwtRepository.Delete(shippingByWeightRecord); _cacheManager.RemoveByPattern(SHIPPINGBYWEIGHTBYTOTAL_PATTERN_KEY); }
/// <summary> /// Insert the shipping by weight record /// </summary> /// <param name="shippingByWeightRecord">Shipping by weight record</param> public virtual void InsertShippingByWeightRecord(ShippingByWeightByTotalRecord shippingByWeightRecord) { if (shippingByWeightRecord == null) { throw new ArgumentNullException(nameof(shippingByWeightRecord)); } _sbwtRepository.Insert(shippingByWeightRecord); _staticCacheManager.RemoveByPrefix(SHIPPINGBYWEIGHTBYTOTAL_PATTERN_KEY); }
public IActionResult DeleteRateByWeightByTotal(int id) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings)) { return(Content("Access denied")); } ShippingByWeightByTotalRecord sbw = _shippingByWeightService.GetById(id); if (sbw != null) { _shippingByWeightService.DeleteShippingByWeightRecord(sbw); } return(new NullJsonResult()); }
/// <summary> /// Get rate by weight and by total /// </summary> /// <param name="shippingByWeightByTotalRecord">Shipping by weight/by total record</param> /// <param name="subTotal">Subtotal</param> /// <param name="weight">Weight</param> /// <param name="length">Length</param> /// <param name="width">Width</param> /// <param name="height">Height</param> /// <returns>Rate</returns> private decimal GetRate(ShippingByWeightByTotalRecord shippingByWeightByTotalRecord, decimal subTotal, decimal weight, decimal length, decimal width, decimal height) { //additional fixed cost var shippingTotal = shippingByWeightByTotalRecord.AdditionalFixedCost; //charge amount per weight unit if (shippingByWeightByTotalRecord.RatePerWeightUnit > decimal.Zero) { var weightRate = Math.Max(weight - shippingByWeightByTotalRecord.LowerWeightLimit, decimal.Zero); shippingTotal += shippingByWeightByTotalRecord.RatePerWeightUnit * weightRate; } //percentage rate of subtotal if (shippingByWeightByTotalRecord.PercentageRateOfSubtotal > decimal.Zero) { shippingTotal += Math.Round((decimal)((((float)subTotal) * ((float)shippingByWeightByTotalRecord.PercentageRateOfSubtotal)) / 100f), 2); } return(Math.Max(shippingTotal, decimal.Zero)); }
public IActionResult EditRateByWeightByTotalPopup(ShippingByWeightByTotalModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings)) { return(AccessDeniedView()); } ShippingByWeightByTotalRecord sbw = _shippingByWeightService.GetById(model.Id); if (sbw == null) { //no record found with the specified id return(RedirectToAction("Configure")); } sbw.StoreId = model.StoreId; sbw.WarehouseId = model.WarehouseId; sbw.CountryId = model.CountryId; sbw.StateProvinceId = model.StateProvinceId; sbw.Zip = model.Zip == "*" ? null : model.Zip; sbw.ShippingMethodId = model.ShippingMethodId; sbw.WeightFrom = model.WeightFrom; sbw.WeightTo = model.WeightTo; sbw.OrderSubtotalFrom = model.OrderSubtotalFrom; sbw.OrderSubtotalTo = model.OrderSubtotalTo; sbw.AdditionalFixedCost = model.AdditionalFixedCost; sbw.RatePerWeightUnit = model.RatePerWeightUnit; sbw.PercentageRateOfSubtotal = model.PercentageRateOfSubtotal; sbw.LowerWeightLimit = model.LowerWeightLimit; sbw.MontoDolar = model.MontoDolar; _shippingByWeightService.UpdateShippingByWeightRecord(sbw); ViewBag.RefreshPage = true; return(View("~/Plugins/Shipping.FixedByWeightByTotal/Views/EditRateByWeightByTotalPopup.cshtml", model)); }
/// <summary> /// Delete the shipping by weight record /// </summary> /// <param name="shippingByWeightRecord">Shipping by weight record</param> public virtual async Task DeleteShippingByWeightRecordAsync(ShippingByWeightByTotalRecord shippingByWeightRecord) { await _sbwtRepository.DeleteAsync(shippingByWeightRecord, false); await _staticCacheManager.RemoveByPrefixAsync(SHIPPINGBYWEIGHTBYTOTAL_PATTERN_KEY); }
/// <summary> /// Delete the shipping by weight record /// </summary> /// <param name="shippingByWeightRecord">Shipping by weight record</param> public virtual void DeleteShippingByWeightRecord(ShippingByWeightByTotalRecord shippingByWeightRecord) { _sbwtRepository.Delete(shippingByWeightRecord, false); _staticCacheManager.RemoveByPrefix(SHIPPINGBYWEIGHTBYTOTAL_PATTERN_KEY); }
public IActionResult EditRateByWeightByTotalPopup(int id) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageShippingSettings)) { return(AccessDeniedView()); } ShippingByWeightByTotalRecord sbw = _shippingByWeightService.GetById(id); if (sbw == null) { //no record found with the specified id return(RedirectToAction("Configure")); } ShippingByWeightByTotalModel model = new ShippingByWeightByTotalModel { Id = sbw.Id, StoreId = sbw.StoreId, WarehouseId = sbw.WarehouseId, CountryId = sbw.CountryId, StateProvinceId = sbw.StateProvinceId, Zip = sbw.Zip, ShippingMethodId = sbw.ShippingMethodId, WeightFrom = sbw.WeightFrom, WeightTo = sbw.WeightTo, OrderSubtotalFrom = sbw.OrderSubtotalFrom, OrderSubtotalTo = sbw.OrderSubtotalTo, AdditionalFixedCost = sbw.AdditionalFixedCost, PercentageRateOfSubtotal = sbw.PercentageRateOfSubtotal, RatePerWeightUnit = sbw.RatePerWeightUnit, LowerWeightLimit = sbw.LowerWeightLimit, PrimaryStoreCurrencyCode = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId)?.CurrencyCode, BaseWeightIn = _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId)?.Name, MontoDolar = sbw.MontoDolar }; IList <Core.Domain.Shipping.ShippingMethod> shippingMethods = _shippingService.GetAllShippingMethods(); if (!shippingMethods.Any()) { return(Content("No shipping methods can be loaded")); } Core.Domain.Stores.Store selectedStore = _storeService.GetStoreById(sbw.StoreId); Core.Domain.Shipping.Warehouse selectedWarehouse = _shippingService.GetWarehouseById(sbw.WarehouseId); Core.Domain.Shipping.ShippingMethod selectedShippingMethod = _shippingService.GetShippingMethodById(sbw.ShippingMethodId); Country selectedCountry = _countryService.GetCountryById(sbw.CountryId); StateProvince selectedState = _stateProvinceService.GetStateProvinceById(sbw.StateProvinceId); //stores model.AvailableStores.Add(new SelectListItem { Text = "*", Value = "0" }); foreach (Core.Domain.Stores.Store store in _storeService.GetAllStores()) { model.AvailableStores.Add(new SelectListItem { Text = store.Name, Value = store.Id.ToString(), Selected = selectedStore != null && store.Id == selectedStore.Id }); } //warehouses model.AvailableWarehouses.Add(new SelectListItem { Text = "*", Value = "0" }); foreach (Core.Domain.Shipping.Warehouse warehouse in _shippingService.GetAllWarehouses()) { model.AvailableWarehouses.Add(new SelectListItem { Text = warehouse.Name, Value = warehouse.Id.ToString(), Selected = selectedWarehouse != null && warehouse.Id == selectedWarehouse.Id }); } //shipping methods foreach (Core.Domain.Shipping.ShippingMethod sm in shippingMethods) { model.AvailableShippingMethods.Add(new SelectListItem { Text = sm.Name, Value = sm.Id.ToString(), Selected = selectedShippingMethod != null && sm.Id == selectedShippingMethod.Id }); } //countries model.AvailableCountries.Add(new SelectListItem { Text = "*", Value = "0" }); IList <Country> countries = _countryService.GetAllCountries(showHidden: true); foreach (Country c in countries) { model.AvailableCountries.Add(new SelectListItem { Text = c.Name, Value = c.Id.ToString(), Selected = selectedCountry != null && c.Id == selectedCountry.Id }); } //states List <StateProvince> states = selectedCountry != null?_stateProvinceService.GetStateProvincesByCountryId(selectedCountry.Id, showHidden : true).ToList() : new List <StateProvince>(); model.AvailableStates.Add(new SelectListItem { Text = "*", Value = "0" }); foreach (StateProvince s in states) { model.AvailableStates.Add(new SelectListItem { Text = s.Name, Value = s.Id.ToString(), Selected = selectedState != null && s.Id == selectedState.Id }); } return(View("~/Plugins/Shipping.FixedByWeightByTotal/Views/EditRateByWeightByTotalPopup.cshtml", model)); }