Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Plugin - Shipping.ByWeight - allow to set display order
KrzysztofPajakb5c9def2cc11
diff --git a/src/Plugins/Shipping.ByWeight/ByWeightShippingPlugin.cs b/src/Plugins/Shipping.ByWeight/ByWeightShippingPlugin.csindex 39fd7f49d..f63ba0fb1 100644--- a/src/Plugins/Shipping.ByWeight/ByWeightShippingPlugin.cs+++ b/src/Plugins/Shipping.ByWeight/ByWeightShippingPlugin.cs@@ -37,8 +37,7 @@ namespace Shipping.ByWeightpublic override async Task Install(){//settings- var settings = new ShippingByWeightSettings- {+ var settings = new ByWeightShippingSettings {LimitMethodsToCreated = false,};await _settingService.SaveSetting(settings);@@ -59,6 +58,7 @@ namespace Shipping.ByWeightawait this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Shipping.ByWeight.Fields.RatePerWeightUnit", "Rate per weight unit");await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Shipping.ByWeight.Fields.LimitMethodsToCreated", "Limit shipping methods to configured ones");await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Shipping.ByWeight.Fields.DataHtml", "Data");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Shipping.ByWeight.Fields.DisplayOrder", "DisplayOrder");await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Shipping.ByWeight.AddRecord", "Add record");await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Shipping.ByWeight.Formula", "Formula to calculate rates");await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Shipping.ByWeight.Formula.Value", "[additional fixed cost] + ([order total weight] - [lower weight limit]) * [rate per weight unit] + [order subtotal] * [charge percentage]");diff --git a/src/Plugins/Shipping.ByWeight/ByWeightShippingProvider.cs b/src/Plugins/Shipping.ByWeight/ByWeightShippingProvider.csindex 82cf08173..6c4f39d2a 100644--- a/src/Plugins/Shipping.ByWeight/ByWeightShippingProvider.cs+++ b/src/Plugins/Shipping.ByWeight/ByWeightShippingProvider.cs@@ -70,7 +70,7 @@ namespace Shipping.ByWeight{var shippingByWeightService = _serviceProvider.GetRequiredService<IShippingByWeightService>();- var shippingByWeightSettings = _serviceProvider.GetRequiredService<ShippingByWeightSettings>();+ var shippingByWeightSettings = _serviceProvider.GetRequiredService<ByWeightShippingSettings>();var shippingByWeightRecord = await shippingByWeightService.FindRecord(shippingMethodId,storeId, warehouseId, countryId, stateProvinceId, zip, weight);diff --git a/src/Plugins/Shipping.ByWeight/ByWeightShippingSettings.cs b/src/Plugins/Shipping.ByWeight/ByWeightShippingSettings.csindex dbad87193..0718cb84a 100644--- a/src/Plugins/Shipping.ByWeight/ByWeightShippingSettings.cs+++ b/src/Plugins/Shipping.ByWeight/ByWeightShippingSettings.cs@@ -4,6 +4,7 @@ namespace Shipping.ByWeight{public class ByWeightShippingSettings : ISettings{+ public bool LimitMethodsToCreated { get; set; }public int DisplayOrder { get; set; }}diff --git a/src/Plugins/Shipping.ByWeight/Controllers/ShippingByWeightController.cs b/src/Plugins/Shipping.ByWeight/Controllers/ShippingByWeightController.csindex c0c2ab277..8471892c0 100644--- a/src/Plugins/Shipping.ByWeight/Controllers/ShippingByWeightController.cs+++ b/src/Plugins/Shipping.ByWeight/Controllers/ShippingByWeightController.cs@@ -31,7 +31,7 @@ namespace Shipping.ByWeight.Controllersprivate readonly IShippingMethodService _shippingMethodService;private readonly IStoreService _storeService;private readonly ICountryService _countryService;- private readonly ShippingByWeightSettings _shippingByWeightSettings;+ private readonly ByWeightShippingSettings _shippingByWeightSettings;private readonly IShippingByWeightService _shippingByWeightService;private readonly ISettingService _settingService;private readonly ITranslationService _translationService;@@ -45,7 +45,7 @@ namespace Shipping.ByWeight.ControllersIShippingMethodService shippingMethodService,IStoreService storeService,ICountryService countryService,- ShippingByWeightSettings shippingByWeightSettings,+ ByWeightShippingSettings shippingByWeightSettings,IShippingByWeightService shippingByWeightService,ISettingService settingService,ITranslationService translationService,@@ -70,8 +70,9 @@ namespace Shipping.ByWeight.Controllerspublic IActionResult Configure(){var model = new ShippingByWeightListModel();- //other settings+model.LimitMethodsToCreated = _shippingByWeightSettings.LimitMethodsToCreated;+ model.DisplayOrder = _shippingByWeightSettings.DisplayOrder;return View("~/Plugins/Shipping.ByWeight/Views/Configure.cshtml", model);}@@ -82,6 +83,8 @@ namespace Shipping.ByWeight.Controllers{//save settings_shippingByWeightSettings.LimitMethodsToCreated = model.LimitMethodsToCreated;+ _shippingByWeightSettings.DisplayOrder = model.DisplayOrder;+await _settingService.SaveSetting(_shippingByWeightSettings);return Json(new { Result = true });diff --git a/src/Plugins/Shipping.ByWeight/Models/ShippingByWeightListModel.cs b/src/Plugins/Shipping.ByWeight/Models/ShippingByWeightListModel.csindex b693ae2a6..3d56b4cea 100644--- a/src/Plugins/Shipping.ByWeight/Models/ShippingByWeightListModel.cs+++ b/src/Plugins/Shipping.ByWeight/Models/ShippingByWeightListModel.cs@@ -7,5 +7,8 @@ namespace Shipping.ByWeight.Models{[GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.LimitMethodsToCreated")]public bool LimitMethodsToCreated { get; set; }++ [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.DisplayOrder")]+ public int DisplayOrder { get; set; }}}\ No newline at end of filediff --git a/src/Plugins/Shipping.ByWeight/ShippingByWeightSettings.cs b/src/Plugins/Shipping.ByWeight/ShippingByWeightSettings.csdeleted file mode 100644index e5f679400..000000000--- a/src/Plugins/Shipping.ByWeight/ShippingByWeightSettings.cs+++ /dev/null@@ -1,10 +0,0 @@--using Grand.Domain.Configuration;--namespace Shipping.ByWeight-{- public class ShippingByWeightSettings : ISettings- {- public bool LimitMethodsToCreated { get; set; }- }-}\ No newline at end of filediff --git a/src/Plugins/Shipping.ByWeight/Views/Configure.cshtml b/src/Plugins/Shipping.ByWeight/Views/Configure.cshtmlindex 7f5ad1347..1c10b623b 100644--- a/src/Plugins/Shipping.ByWeight/Views/Configure.cshtml+++ b/src/Plugins/Shipping.ByWeight/Views/Configure.cshtml@@ -142,11 +142,20 @@<div class="col-md-9 col-sm-9"><label class="mt-checkbox mt-checkbox-outline control control-checkbox"><admin-input asp-for="LimitMethodsToCreated" />- <div class="control__indicator"></div>+ <div class="control__indicator"></div></label><span asp-validation-for="LimitMethodsToCreated"></span></div></div>+ <div class="form-group">+ <div class="col-md-3 col-sm-3 text-right">+ <admin-label asp-for="DisplayOrder" class="control-label" />+ </div>+ <div class="col-md-9 col-sm-9">+ <admin-input asp-for="DisplayOrder" />+ <span asp-validation-for="DisplayOrder"></span>+ </div>+ </div><div class="form-group"><input type="button" id="savegeneralsettings" class="btn default" value="@Loc["Admin.Common.Save"]" /><script>