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
Plugins - Code cleanup (ReSharper)
supporta4e2a19e6d5d
diff --git a/src/Plugins/Authentication.Facebook/Areas/Admin/Controllers/FacebookAuthenticationSettingsController.cs b/src/Plugins/Authentication.Facebook/Areas/Admin/Controllers/FacebookAuthenticationSettingsController.csindex 941452cce..40f575769 100644--- a/src/Plugins/Authentication.Facebook/Areas/Admin/Controllers/FacebookAuthenticationSettingsController.cs+++ b/src/Plugins/Authentication.Facebook/Areas/Admin/Controllers/FacebookAuthenticationSettingsController.cs@@ -9,79 +9,77 @@ using Grand.Web.Common.Security.Authorization;using Microsoft.AspNetCore.Mvc;using Microsoft.Extensions.Configuration;-namespace Authentication.Facebook.Areas.Admin.Controllers-{- [AuthorizeAdmin]- [Area("Admin")]- [PermissionAuthorize(PermissionSystemName.ExternalAuthenticationMethods)]- public class FacebookAuthenticationSettingsController : BasePluginController- {- #region Fields-- private readonly FacebookExternalAuthSettings _facebookExternalAuthSettings;- private readonly ITranslationService _translationService;- private readonly IPermissionService _permissionService;- private readonly ISettingService _settingService;- private readonly IConfiguration _configuration;+namespace Authentication.Facebook.Areas.Admin.Controllers;- #endregion+[AuthorizeAdmin]+[Area("Admin")]+[PermissionAuthorize(PermissionSystemName.ExternalAuthenticationMethods)]+public class FacebookAuthenticationSettingsController : BasePluginController+{+ #region Ctor- #region Ctor+ public FacebookAuthenticationSettingsController(FacebookExternalAuthSettings facebookExternalAuthSettings,+ ITranslationService translationService,+ IPermissionService permissionService,+ ISettingService settingService,+ IConfiguration configuration)+ {+ _facebookExternalAuthSettings = facebookExternalAuthSettings;+ _translationService = translationService;+ _permissionService = permissionService;+ _settingService = settingService;+ _configuration = configuration;+ }- public FacebookAuthenticationSettingsController(FacebookExternalAuthSettings facebookExternalAuthSettings,- ITranslationService translationService,- IPermissionService permissionService,- ISettingService settingService,- IConfiguration configuration)- {- _facebookExternalAuthSettings = facebookExternalAuthSettings;- _translationService = translationService;- _permissionService = permissionService;- _settingService = settingService;- _configuration = configuration;- }+ #endregion- #endregion+ #region Fields- #region Methods+ private readonly FacebookExternalAuthSettings _facebookExternalAuthSettings;+ private readonly ITranslationService _translationService;+ private readonly IPermissionService _permissionService;+ private readonly ISettingService _settingService;+ private readonly IConfiguration _configuration;- public async Task<IActionResult> Configure()- {- if (!await _permissionService.Authorize(StandardPermission.ManageExternalAuthenticationMethods))- return AccessDeniedView();+ #endregion- var model = new ConfigurationModel {- ClientId = _configuration["FacebookSettings:AppId"],- ClientSecret = _configuration["FacebookSettings:AppSecret"],- DisplayOrder = _facebookExternalAuthSettings.DisplayOrder- };+ #region Methods+ public async Task<IActionResult> Configure()+ {+ if (!await _permissionService.Authorize(StandardPermission.ManageExternalAuthenticationMethods))+ return AccessDeniedView();- return View(model);- }+ var model = new ConfigurationModel {+ ClientId = _configuration["FacebookSettings:AppId"],+ ClientSecret = _configuration["FacebookSettings:AppSecret"],+ DisplayOrder = _facebookExternalAuthSettings.DisplayOrder+ };- [HttpPost]- public async Task<IActionResult> Configure(ConfigurationModel model)- {- if (!await _permissionService.Authorize(StandardPermission.ManageExternalAuthenticationMethods))- return AccessDeniedView();- if (!ModelState.IsValid)- return await Configure();+ return View(model);+ }- _facebookExternalAuthSettings.DisplayOrder = model.DisplayOrder;+ [HttpPost]+ public async Task<IActionResult> Configure(ConfigurationModel model)+ {+ if (!await _permissionService.Authorize(StandardPermission.ManageExternalAuthenticationMethods))+ return AccessDeniedView();- await _settingService.SaveSetting(_facebookExternalAuthSettings);+ if (!ModelState.IsValid)+ return await Configure();- //now clear settings cache- await _settingService.ClearCache();+ _facebookExternalAuthSettings.DisplayOrder = model.DisplayOrder;- Success(_translationService.GetResource("Admin.Plugins.Saved"));+ await _settingService.SaveSetting(_facebookExternalAuthSettings);- return await Configure();- }+ //now clear settings cache+ await _settingService.ClearCache();+ Success(_translationService.GetResource("Admin.Plugins.Saved"));- #endregion+ return await Configure();}++ #endregion}\ No newline at end of filediff --git a/src/Plugins/Authentication.Facebook/Areas/Admin/Views/FacebookAuthenticationSettings/Configure.cshtml b/src/Plugins/Authentication.Facebook/Areas/Admin/Views/FacebookAuthenticationSettings/Configure.cshtmlindex 112dfb5c7..b39644747 100644--- a/src/Plugins/Authentication.Facebook/Areas/Admin/Views/FacebookAuthenticationSettings/Configure.cshtml+++ b/src/Plugins/Authentication.Facebook/Areas/Admin/Views/FacebookAuthenticationSettings/Configure.cshtml@@ -2,56 +2,56 @@@{Layout = "_ConfigurePlugin";}-<input id="active-menu-item" type="hidden" value="/Admin/ExternalAuthentication/Methods" />+<input id="active-menu-item" type="hidden" value="/Admin/ExternalAuthentication/Methods"/><form asp-controller="FacebookAuthenticationSettings" asp-area="Admin" asp-action="Configure" method="post"><div class="form-horizontal"><div class="form-body"><div class="note note-info"><p>- To configure authentication with Facebook follow these steps:<br />- <br />- 1. Navigate to the <a href="https://developers.facebook.com/apps" target="_blank">Facebook for Developers</a> page and sign in. If you don't already have a Facebook account, use the <b>Sign up for Facebook</b> link on the login page to create one.<br />- 2. Tap the <b>+ Add a New App button</b> in the upper right corner to create a new App ID. (If this is your first app with Facebook, the text of the button will be <b>Create a New App</b>.)<br />- 3. Fill out the form and tap the <b>Create App ID button</b>.<br />- 4. The <b>Product Setup</b> page is displayed, letting you select the features for your new app. Click <b>Get Started</b> on <b>Facebook Login</b>.<br />- 5. Click the <b>Settings</b> link in the menu at the left, you are presented with the <b>Client OAuth Settings</b> page with some defaults already set.<br />- 6. Enter "@("https://yourstore.com/signin-facebook")" into the <b>Valid OAuth Redirect URIs</b> field.<br />- 7. Click <b>Save Changes</b>.<br />- 8. Click the <b>Dashboard</b> link in the left navigation.<br />- 9. Copy your App ID and App secret below.<br />+ To configure authentication with Facebook follow these steps:<br/>+ <br/>+ 1. Navigate to the <a href="https://developers.facebook.com/apps" target="_blank">Facebook for Developers</a> page and sign in. If you don't already have a Facebook account, use the <b>Sign up for Facebook</b> link on the login page to create one.<br/>+ 2. Tap the <b>+ Add a New App button</b> in the upper right corner to create a new App ID. (If this is your first app with Facebook, the text of the button will be <b>Create a New App</b>.)<br/>+ 3. Fill out the form and tap the <b>Create App ID button</b>.<br/>+ 4. The <b>Product Setup</b> page is displayed, letting you select the features for your new app. Click <b>Get Started</b> on <b>Facebook Login</b>.<br/>+ 5. Click the <b>Settings</b> link in the menu at the left, you are presented with the <b>Client OAuth Settings</b> page with some defaults already set.<br/>+ 6. Enter "@("https://yourstore.com/signin-facebook")" into the <b>Valid OAuth Redirect URIs</b> field.<br/>+ 7. Click <b>Save Changes</b>.<br/>+ 8. Click the <b>Dashboard</b> link in the left navigation.<br/>+ 9. Copy your App ID and App secret below.<br/></p><p>- <br /><br />- To edit facebook settings in the grandnode application, please open the file App_Settings.json,+ <br/><br/>+ To edit facebook settings in the grandnode application, please open the file App_Settings.json,find section FacebookSettings and enter the correct values.</p></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="ClientId" class="control-label" />+ <admin-label asp-for="ClientId" class="control-label"/></div><div class="col-md-9 col-sm-9"><input asp-for="ClientId" type="text"- disabled class="form-control k-input text-box single-line" />+ disabled class="form-control k-input text-box single-line"/><span asp-validation-for="ClientId"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="ClientSecret" class="control-label" />+ <admin-label asp-for="ClientSecret" class="control-label"/></div><div class="col-md-9 col-sm-9">- <input asp-for="ClientSecret" type="text" disabled class="form-control k-input text-box single-line" />+ <input asp-for="ClientSecret" type="text" disabled class="form-control k-input text-box single-line"/><span asp-validation-for="ClientSecret"></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" />+ <admin-label asp-for="DisplayOrder" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="DisplayOrder" />+ <admin-input asp-for="DisplayOrder"/><span asp-validation-for="DisplayOrder"></span></div></div>@@ -59,7 +59,7 @@<div class="form-actions"><div class="row"><div class="offset-md-3 offset-sm-3 col-md-9 col-sm-9">- <input type="submit" name="save" class="btn green" value="@Loc["Admin.Common.Save"]" />+ <input type="submit" name="save" class="btn green" value="@Loc["Admin.Common.Save"]"/></div></div></div>diff --git a/src/Plugins/Authentication.Facebook/Areas/Admin/Views/_ViewImports.cshtml b/src/Plugins/Authentication.Facebook/Areas/Admin/Views/_ViewImports.cshtmlindex 2fb08c043..fb3b84aa9 100644--- a/src/Plugins/Authentication.Facebook/Areas/Admin/Views/_ViewImports.cshtml+++ b/src/Plugins/Authentication.Facebook/Areas/Admin/Views/_ViewImports.cshtml@@ -4,5 +4,6 @@@using Microsoft.AspNetCore.Mvc.ViewFeatures@using Grand.Infrastructure.Extensions+@using Grand.Web.Common.Localization-@inject Grand.Web.Common.Localization.LocService Loc+@inject LocService Loc\ No newline at end of filediff --git a/src/Plugins/Authentication.Facebook/Components/FacebookAuthentication.cs b/src/Plugins/Authentication.Facebook/Components/FacebookAuthentication.csindex af3d1fe3a..b63d81551 100644--- a/src/Plugins/Authentication.Facebook/Components/FacebookAuthentication.cs+++ b/src/Plugins/Authentication.Facebook/Components/FacebookAuthentication.cs@@ -1,13 +1,12 @@using Microsoft.AspNetCore.Mvc;-namespace Authentication.Facebook.Components+namespace Authentication.Facebook.Components;++[ViewComponent(Name = "FacebookAuthentication")]+public class FacebookAuthenticationViewComponent : ViewComponent{- [ViewComponent(Name = "FacebookAuthentication")]- public class FacebookAuthenticationViewComponent : ViewComponent+ public IViewComponentResult Invoke(){- public IViewComponentResult Invoke()- {- return View();- }+ return View();}}\ No newline at end of filediff --git a/src/Plugins/Authentication.Facebook/Controllers/FacebookAuthenticationController.cs b/src/Plugins/Authentication.Facebook/Controllers/FacebookAuthenticationController.csindex 67d6dfe59..872797afc 100644--- a/src/Plugins/Authentication.Facebook/Controllers/FacebookAuthenticationController.cs+++ b/src/Plugins/Authentication.Facebook/Controllers/FacebookAuthenticationController.cs@@ -1,5 +1,6 @@using Authentication.Facebook.Models;using Grand.Business.Core.Interfaces.Authentication;+using Grand.Business.Core.Utilities.Authentication;using Grand.SharedKernel;using Grand.Web.Common.Controllers;using Microsoft.AspNetCore.Authentication;@@ -7,80 +8,81 @@ using Microsoft.AspNetCore.Authentication.Facebook;using Microsoft.AspNetCore.Mvc;using Microsoft.Extensions.Configuration;using System.Security.Claims;-using Grand.Business.Core.Utilities.Authentication;-namespace Authentication.Facebook.Controllers+namespace Authentication.Facebook.Controllers;++public class FacebookAuthenticationController : BasePluginController{- public class FacebookAuthenticationController : BasePluginController+ #region Ctor++ public FacebookAuthenticationController(+ IExternalAuthenticationService externalAuthenticationService,+ IConfiguration configuration)+ {+ _externalAuthenticationService = externalAuthenticationService;+ _configuration = configuration;+ }++ #endregion++ #region Fields++ private readonly IExternalAuthenticationService _externalAuthenticationService;+ private readonly IConfiguration _configuration;++ #endregion++ #region Methods++ public IActionResult FacebookLogin(string returnUrl){- #region Fields-- private readonly IExternalAuthenticationService _externalAuthenticationService;- private readonly IConfiguration _configuration;-- #endregion-- #region Ctor-- public FacebookAuthenticationController(- IExternalAuthenticationService externalAuthenticationService,- IConfiguration configuration)- {- _externalAuthenticationService = externalAuthenticationService;- _configuration = configuration;- }-- #endregion-- #region Methods-- public IActionResult FacebookLogin(string returnUrl)- {- if (!_externalAuthenticationService.AuthenticationProviderIsAvailable(FacebookAuthenticationDefaults.ProviderSystemName))- throw new GrandException("Facebook authentication module cannot be loaded");-- if (string.IsNullOrEmpty(_configuration["FacebookSettings:AppId"]) || string.IsNullOrEmpty(_configuration["FacebookSettings:AppSecret"]))- throw new GrandException("Facebook authentication module not configured");-- //configure login callback action- var authenticationProperties = new AuthenticationProperties {- RedirectUri = Url.Action("FacebookLoginCallback", "FacebookAuthentication", new { returnUrl })- };-- return Challenge(authenticationProperties, FacebookDefaults.AuthenticationScheme);- }-- public async Task<IActionResult> FacebookLoginCallback(string returnUrl)- {- //authenticate Facebook user- var authenticateResult = await HttpContext.AuthenticateAsync(FacebookDefaults.AuthenticationScheme);- if (!authenticateResult.Succeeded || !authenticateResult.Principal.Claims.Any())- return RedirectToRoute("Login");-- //create external authentication parameters- var authenticationParameters = new ExternalAuthParam {- ProviderSystemName = FacebookAuthenticationDefaults.ProviderSystemName,- AccessToken = await HttpContext.GetTokenAsync(FacebookDefaults.AuthenticationScheme, "access_token"),- Email = authenticateResult.Principal.FindFirst(claim => claim.Type == ClaimTypes.Email)?.Value,- Identifier = authenticateResult.Principal.FindFirst(claim => claim.Type == ClaimTypes.NameIdentifier)?.Value,- Name = authenticateResult.Principal.FindFirst(claim => claim.Type == ClaimTypes.Name)?.Value,- Claims = authenticateResult.Principal.Claims.ToList()- };-- //authenticate Grand user- return await _externalAuthenticationService.Authenticate(authenticationParameters, returnUrl);- }- public IActionResult FacebookSignInFailed(string error_code, string error_message, string state)- {- //handle exception and display message to user- var model = new FailedModel {- ErrorCode = error_code,- ErrorMessage = error_message- };- return View(model);- }--- #endregion+ if (!_externalAuthenticationService.AuthenticationProviderIsAvailable(FacebookAuthenticationDefaults+ .ProviderSystemName))+ throw new GrandException("Facebook authentication module cannot be loaded");++ if (string.IsNullOrEmpty(_configuration["FacebookSettings:AppId"]) ||+ string.IsNullOrEmpty(_configuration["FacebookSettings:AppSecret"]))+ throw new GrandException("Facebook authentication module not configured");++ //configure login callback action+ var authenticationProperties = new AuthenticationProperties {+ RedirectUri = Url.Action("FacebookLoginCallback", "FacebookAuthentication", new { returnUrl })+ };++ return Challenge(authenticationProperties, FacebookDefaults.AuthenticationScheme);}++ public async Task<IActionResult> FacebookLoginCallback(string returnUrl)+ {+ //authenticate Facebook user+ var authenticateResult = await HttpContext.AuthenticateAsync(FacebookDefaults.AuthenticationScheme);+ if (!authenticateResult.Succeeded || !authenticateResult.Principal.Claims.Any())+ return RedirectToRoute("Login");++ //create external authentication parameters+ var authenticationParameters = new ExternalAuthParam {+ ProviderSystemName = FacebookAuthenticationDefaults.ProviderSystemName,+ AccessToken = await HttpContext.GetTokenAsync(FacebookDefaults.AuthenticationScheme, "access_token"),+ Email = authenticateResult.Principal.FindFirst(claim => claim.Type == ClaimTypes.Email)?.Value,+ Identifier =+ authenticateResult.Principal.FindFirst(claim => claim.Type == ClaimTypes.NameIdentifier)?.Value,+ Name = authenticateResult.Principal.FindFirst(claim => claim.Type == ClaimTypes.Name)?.Value,+ Claims = authenticateResult.Principal.Claims.ToList()+ };++ //authenticate Grand user+ return await _externalAuthenticationService.Authenticate(authenticationParameters, returnUrl);+ }++ public IActionResult FacebookSignInFailed(string error_code, string error_message, string state)+ {+ //handle exception and display message to user+ var model = new FailedModel {+ ErrorCode = error_code,+ ErrorMessage = error_message+ };+ return View(model);+ }++ #endregion}\ No newline at end of filediff --git a/src/Plugins/Authentication.Facebook/EndpointProvider.cs b/src/Plugins/Authentication.Facebook/EndpointProvider.csindex 71da303a7..3a37cfb24 100644--- a/src/Plugins/Authentication.Facebook/EndpointProvider.cs+++ b/src/Plugins/Authentication.Facebook/EndpointProvider.cs@@ -2,17 +2,17 @@using Microsoft.AspNetCore.Builder;using Microsoft.AspNetCore.Routing;-namespace Authentication.Facebook+namespace Authentication.Facebook;++public class EndpointProvider : IEndpointProvider{- public class EndpointProvider : IEndpointProvider+ public void RegisterEndpoint(IEndpointRouteBuilder endpointRouteBuilder){- public void RegisterEndpoint(IEndpointRouteBuilder endpointRouteBuilder)- {- endpointRouteBuilder.MapControllerRoute("Plugin.ExternalAuth.Facebook.SignInFacebook",- "fb-signin-failed",- new { controller = "FacebookAuthentication", action = "FacebookSignInFailed" }- );- }- public int Priority => 10;+ endpointRouteBuilder.MapControllerRoute("Plugin.ExternalAuth.Facebook.SignInFacebook",+ "fb-signin-failed",+ new { controller = "FacebookAuthentication", action = "FacebookSignInFailed" }+ );}-}++ public int Priority => 10;+}\ No newline at end of filediff --git a/src/Plugins/Authentication.Facebook/FacebookAuthenticationDefaults.cs b/src/Plugins/Authentication.Facebook/FacebookAuthenticationDefaults.csindex dd0e21358..e72608239 100644--- a/src/Plugins/Authentication.Facebook/FacebookAuthenticationDefaults.cs+++ b/src/Plugins/Authentication.Facebook/FacebookAuthenticationDefaults.cs@@ -1,16 +1,14 @@--namespace Authentication.Facebook+namespace Authentication.Facebook;++/// <summary>+/// Default values used by the Facebook authentication middleware+/// </summary>+public static class FacebookAuthenticationDefaults{/// <summary>- /// Default values used by the Facebook authentication middleware+ /// System name of the external authentication method/// </summary>- public static class FacebookAuthenticationDefaults- {- /// <summary>- /// System name of the external authentication method- /// </summary>- public const string ProviderSystemName = "ExternalAuth.Facebook";+ public const string ProviderSystemName = "ExternalAuth.Facebook";- public const string ConfigurationUrl = "../FacebookAuthenticationSettings/Configure";- }-}+ public const string ConfigurationUrl = "../FacebookAuthenticationSettings/Configure";+}\ No newline at end of filediff --git a/src/Plugins/Authentication.Facebook/FacebookAuthenticationPlugin.cs b/src/Plugins/Authentication.Facebook/FacebookAuthenticationPlugin.csindex b017cfde9..68c199ec6 100644--- a/src/Plugins/Authentication.Facebook/FacebookAuthenticationPlugin.cs+++ b/src/Plugins/Authentication.Facebook/FacebookAuthenticationPlugin.cs@@ -3,82 +3,90 @@ using Grand.Business.Core.Interfaces.Common.Configuration;using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Infrastructure.Plugins;-namespace Authentication.Facebook+namespace Authentication.Facebook;++/// <summary>+/// Represents method for the authentication with Facebook account+/// </summary>+public class FacebookAuthenticationPlugin : BasePlugin, IPlugin{+ #region Ctor++ public FacebookAuthenticationPlugin(ISettingService settingService,+ ITranslationService translationService,+ ILanguageService languageService)+ {+ _settingService = settingService;+ _translationService = translationService;+ _languageService = languageService;+ }++ #endregion++ #region Fields++ private readonly ISettingService _settingService;+ private readonly ITranslationService _translationService;+ private readonly ILanguageService _languageService;++ #endregion++ #region Methods++ /// <summary>+ /// Gets a configuration page URL+ /// </summary>+ public override string ConfigurationUrl()+ {+ return FacebookAuthenticationDefaults.ConfigurationUrl;+ }++/// <summary>- /// Represents method for the authentication with Facebook account+ /// Install the plugin/// </summary>- public class FacebookAuthenticationPlugin : BasePlugin, IPlugin+ public override async Task Install(){- #region Fields-- private readonly ISettingService _settingService;- private readonly ITranslationService _translationService;- private readonly ILanguageService _languageService;-- #endregion-- #region Ctor-- public FacebookAuthenticationPlugin(ISettingService settingService,- ITranslationService translationService,- ILanguageService languageService)- {- _settingService = settingService;- _translationService = translationService;- _languageService = languageService;- }-- #endregion-- #region Methods-- /// <summary>- /// Gets a configuration page URL- /// </summary>- public override string ConfigurationUrl()- {- return FacebookAuthenticationDefaults.ConfigurationUrl;- }---- /// <summary>- /// Install the plugin- /// </summary>- public override async Task Install()- {- //settings- await _settingService.SaveSetting(new FacebookExternalAuthSettings());-- //locales- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Authentication.Facebook.Login", "Login using Facebook account");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Authentication.Facebook.ClientKeyIdentifier", "App ID/API Key");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Authentication.Facebook.ClientSecret", "App Secret");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Authentication.Facebook.Failed", "Facebook - Login error");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Authentication.Facebook.Failed.ErrorCode", "Error code");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Authentication.Facebook.Failed.ErrorMessage", "Error message");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Authentication.Facebook.DisplayOrder", "Display order");-- await base.Install();- }-- /// <summary>- /// Uninstall the plugin- /// </summary>- public override async Task Uninstall()- {- //settings- await _settingService.DeleteSetting<FacebookExternalAuthSettings>();-- //locales- await this.DeletePluginTranslationResource(_translationService, _languageService, "Authentication.Facebook.Login");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Authentication.Facebook.ClientKeyIdentifier");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Authentication.Facebook.ClientSecret");-- await base.Uninstall();- }-- #endregion+ //settings+ await _settingService.SaveSetting(new FacebookExternalAuthSettings());++ //locales+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Authentication.Facebook.Login", "Login using Facebook account");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Authentication.Facebook.ClientKeyIdentifier", "App ID/API Key");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Authentication.Facebook.ClientSecret", "App Secret");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Authentication.Facebook.Failed", "Facebook - Login error");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Authentication.Facebook.Failed.ErrorCode", "Error code");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Authentication.Facebook.Failed.ErrorMessage", "Error message");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Authentication.Facebook.DisplayOrder", "Display order");++ await base.Install();}-}++ /// <summary>+ /// Uninstall the plugin+ /// </summary>+ public override async Task Uninstall()+ {+ //settings+ await _settingService.DeleteSetting<FacebookExternalAuthSettings>();++ //locales+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Authentication.Facebook.Login");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Authentication.Facebook.ClientKeyIdentifier");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Authentication.Facebook.ClientSecret");++ await base.Uninstall();+ }++ #endregion+}\ No newline at end of filediff --git a/src/Plugins/Authentication.Facebook/FacebookAuthenticationProvider.cs b/src/Plugins/Authentication.Facebook/FacebookAuthenticationProvider.csindex fc79a5666..4679abc40 100644--- a/src/Plugins/Authentication.Facebook/FacebookAuthenticationProvider.cs+++ b/src/Plugins/Authentication.Facebook/FacebookAuthenticationProvider.cs@@ -1,33 +1,33 @@using Grand.Business.Core.Interfaces.Authentication;-namespace Authentication.Facebook+namespace Authentication.Facebook;++public class FacebookAuthenticationProvider : IExternalAuthenticationProvider{- public class FacebookAuthenticationProvider : IExternalAuthenticationProvider+ private readonly FacebookExternalAuthSettings _facebookExternalAuthSettings;++ public FacebookAuthenticationProvider(FacebookExternalAuthSettings facebookExternalAuthSettings){- private readonly FacebookExternalAuthSettings _facebookExternalAuthSettings;+ _facebookExternalAuthSettings = facebookExternalAuthSettings;+ }- public FacebookAuthenticationProvider(FacebookExternalAuthSettings facebookExternalAuthSettings)- {- _facebookExternalAuthSettings = facebookExternalAuthSettings;- }- public string SystemName => FacebookAuthenticationDefaults.ProviderSystemName;+ public string SystemName => FacebookAuthenticationDefaults.ProviderSystemName;- public string FriendlyName => "Facebook authentication";+ public string FriendlyName => "Facebook authentication";- public int Priority => _facebookExternalAuthSettings.DisplayOrder;+ public int Priority => _facebookExternalAuthSettings.DisplayOrder;- public string ConfigurationUrl => FacebookAuthenticationDefaults.ConfigurationUrl;+ public string ConfigurationUrl => FacebookAuthenticationDefaults.ConfigurationUrl;- public IList<string> LimitedToStores => new List<string>();+ public IList<string> LimitedToStores => new List<string>();- public IList<string> LimitedToGroups => new List<string>();+ public IList<string> LimitedToGroups => new List<string>();- /// <summary>- /// Gets a view component for displaying plugin in public store- /// </summary>- public async Task<string> GetPublicViewComponentName()- {- return await Task.FromResult("FacebookAuthentication");- }+ /// <summary>+ /// Gets a view component for displaying plugin in public store+ /// </summary>+ public async Task<string> GetPublicViewComponentName()+ {+ return await Task.FromResult("FacebookAuthentication");}-}+}\ No newline at end of filediff --git a/src/Plugins/Authentication.Facebook/FacebookExternalAuthSettings.cs b/src/Plugins/Authentication.Facebook/FacebookExternalAuthSettings.csindex 8ac2d6693..8317e5da2 100644--- a/src/Plugins/Authentication.Facebook/FacebookExternalAuthSettings.cs+++ b/src/Plugins/Authentication.Facebook/FacebookExternalAuthSettings.cs@@ -1,15 +1,14 @@using Grand.Domain.Configuration;-namespace Authentication.Facebook+namespace Authentication.Facebook;++/// <summary>+/// Represents settings of the Facebook authentication method+/// </summary>+public class FacebookExternalAuthSettings : ISettings{/// <summary>- /// Represents settings of the Facebook authentication method+ /// Gets or sets display order/// </summary>- public class FacebookExternalAuthSettings : ISettings- {- /// <summary>- /// Gets or sets display order- /// </summary>- public int DisplayOrder { get; set; }- }-}+ public int DisplayOrder { get; set; }+}\ No newline at end of filediff --git a/src/Plugins/Authentication.Facebook/Infrastructure/Cache/FacebookAuthenticationEventConsumer.cs b/src/Plugins/Authentication.Facebook/Infrastructure/Cache/FacebookAuthenticationEventConsumer.csindex 0ef3b5fdd..2587bb7a8 100644--- a/src/Plugins/Authentication.Facebook/Infrastructure/Cache/FacebookAuthenticationEventConsumer.cs+++ b/src/Plugins/Authentication.Facebook/Infrastructure/Cache/FacebookAuthenticationEventConsumer.cs@@ -6,71 +6,70 @@ using Grand.Infrastructure;using MediatR;using System.Security.Claims;-namespace Authentication.Facebook.Infrastructure.Cache+namespace Authentication.Facebook.Infrastructure.Cache;++/// <summary>+/// Facebook authentication event consumer (used for saving customer fields on registration)+/// </summary>+public class FacebookAuthenticationEventConsumer : INotificationHandler<RegisteredByExternalMethod>{- /// <summary>- /// Facebook authentication event consumer (used for saving customer fields on registration)- /// </summary>- public class FacebookAuthenticationEventConsumer : INotificationHandler<RegisteredByExternalMethod>- {- #region Fields+ #region Ctor- private readonly IUserFieldService _userFieldService;- private readonly IMessageProviderService _messageProviderService;- private readonly IWorkContext _workContext;- private readonly CustomerSettings _customerSettings;+ public FacebookAuthenticationEventConsumer(+ IUserFieldService userFieldService,+ IMessageProviderService messageProviderService,+ IWorkContext workContext,+ CustomerSettings customerSettings)+ {+ _userFieldService = userFieldService;+ _messageProviderService = messageProviderService;+ _workContext = workContext;+ _customerSettings = customerSettings;+ }- #endregion+ #endregion- #region Ctor+ #region Methods- public FacebookAuthenticationEventConsumer(- IUserFieldService userFieldService,- IMessageProviderService messageProviderService,- IWorkContext workContext,- CustomerSettings customerSettings)- {- _userFieldService = userFieldService;- _messageProviderService = messageProviderService;- _workContext = workContext;- _customerSettings = customerSettings;- }+ public async Task Handle(RegisteredByExternalMethod eventMessage, CancellationToken cancellationToken)+ {+ if (eventMessage?.Customer == null || eventMessage.AuthenticationParameters == null)+ return;- #endregion+ //handle event only for this authentication method+ if (!eventMessage.AuthenticationParameters.ProviderSystemName.Equals(FacebookAuthenticationDefaults+ .ProviderSystemName))+ return;- #region Methods+ //store some of the customer fields+ var firstName = eventMessage.AuthenticationParameters.Claims+ ?.FirstOrDefault(claim => claim.Type == ClaimTypes.GivenName)?.Value;+ if (!string.IsNullOrEmpty(firstName))+ await _userFieldService.SaveField(eventMessage.Customer, SystemCustomerFieldNames.FirstName, firstName);- public async Task Handle(RegisteredByExternalMethod eventMessage, CancellationToken cancellationToken)- {- if (eventMessage?.Customer == null || eventMessage.AuthenticationParameters == null)- return;+ var lastName = eventMessage.AuthenticationParameters.Claims+ ?.FirstOrDefault(claim => claim.Type == ClaimTypes.Surname)?.Value;+ if (!string.IsNullOrEmpty(lastName))+ await _userFieldService.SaveField(eventMessage.Customer, SystemCustomerFieldNames.LastName, lastName);- //handle event only for this authentication method- if (!eventMessage.AuthenticationParameters.ProviderSystemName.Equals(FacebookAuthenticationDefaults- .ProviderSystemName))- return;+ //notifications for admin+ if (_customerSettings.NotifyNewCustomerRegistration)+ await _messageProviderService.SendCustomerRegisteredMessage(eventMessage.Customer,+ _workContext.CurrentStore, _workContext.WorkingLanguage.Id);- //store some of the customer fields- var firstName = eventMessage.AuthenticationParameters.Claims- ?.FirstOrDefault(claim => claim.Type == ClaimTypes.GivenName)?.Value;- if (!string.IsNullOrEmpty(firstName))- await _userFieldService.SaveField(eventMessage.Customer, SystemCustomerFieldNames.FirstName, firstName);+ //send welcome message+ await _messageProviderService.SendCustomerWelcomeMessage(eventMessage.Customer, _workContext.CurrentStore,+ _workContext.WorkingLanguage.Id);+ }- var lastName = eventMessage.AuthenticationParameters.Claims- ?.FirstOrDefault(claim => claim.Type == ClaimTypes.Surname)?.Value;- if (!string.IsNullOrEmpty(lastName))- await _userFieldService.SaveField(eventMessage.Customer, SystemCustomerFieldNames.LastName, lastName);+ #endregion- //notifications for admin- if (_customerSettings.NotifyNewCustomerRegistration)- await _messageProviderService.SendCustomerRegisteredMessage(eventMessage.Customer,- _workContext.CurrentStore, _workContext.WorkingLanguage.Id);+ #region Fields- //send welcome message- await _messageProviderService.SendCustomerWelcomeMessage(eventMessage.Customer, _workContext.CurrentStore,- _workContext.WorkingLanguage.Id);- }+ private readonly IUserFieldService _userFieldService;+ private readonly IMessageProviderService _messageProviderService;+ private readonly IWorkContext _workContext;+ private readonly CustomerSettings _customerSettings;- #endregion- }+ #endregion}\ No newline at end of filediff --git a/src/Plugins/Authentication.Facebook/Infrastructure/FacebookAuthenticationBuilder.cs b/src/Plugins/Authentication.Facebook/Infrastructure/FacebookAuthenticationBuilder.csindex f0aacd3f5..7e54109ff 100644--- a/src/Plugins/Authentication.Facebook/Infrastructure/FacebookAuthenticationBuilder.cs+++ b/src/Plugins/Authentication.Facebook/Infrastructure/FacebookAuthenticationBuilder.cs@@ -6,50 +6,49 @@ using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;using System.Net;-namespace Authentication.Facebook.Infrastructure+namespace Authentication.Facebook.Infrastructure;++/// <summary>+/// Registration of Facebook authentication service (plugin)+/// </summary>+public class FacebookAuthenticationBuilder : IAuthenticationBuilder{/// <summary>- /// Registration of Facebook authentication service (plugin)+ /// Configure/// </summary>- public class FacebookAuthenticationBuilder : IAuthenticationBuilder+ /// <param name="builder">Authentication builder</param>+ /// <param name="configuration">Configuration</param>+ public void AddAuthentication(AuthenticationBuilder builder, IConfiguration configuration){- /// <summary>- /// Configure- /// </summary>- /// <param name="builder">Authentication builder</param>- /// <param name="configuration">Configuration</param>- public void AddAuthentication(AuthenticationBuilder builder, IConfiguration configuration)+ builder.AddFacebook(FacebookDefaults.AuthenticationScheme, options =>{- builder.AddFacebook(FacebookDefaults.AuthenticationScheme, options =>- {- var appId = configuration["FacebookSettings:AppId"];- var appSecret = configuration["FacebookSettings:AppSecret"];-- //no empty values allowed. otherwise, an exception could be thrown on application startup- options.AppId = !string.IsNullOrWhiteSpace(appId) ? appId : "000";- options.AppSecret = !string.IsNullOrWhiteSpace(appSecret) ? appSecret : "000";- options.SaveTokens = true;- //handles exception thrown by external auth provider- options.Events = new OAuthEvents {- OnRemoteFailure = ctx =>- {- ctx.HandleResponse();- var errorCode = ctx.Request.Query["error_code"].FirstOrDefault();- var errorMessage = ctx.Request.Query["error_message"].FirstOrDefault();- var state = ctx.Request.Query["state"].FirstOrDefault();- errorCode = WebUtility.UrlEncode(errorCode);- errorMessage = WebUtility.UrlEncode(errorMessage);- ctx.Response.Redirect($"/fb-signin-failed?error_code={errorCode}&error_message={errorMessage}");+ var appId = configuration["FacebookSettings:AppId"];+ var appSecret = configuration["FacebookSettings:AppSecret"];- return Task.FromResult(0);- }- };- });- }+ //no empty values allowed. otherwise, an exception could be thrown on application startup+ options.AppId = !string.IsNullOrWhiteSpace(appId) ? appId : "000";+ options.AppSecret = !string.IsNullOrWhiteSpace(appSecret) ? appSecret : "000";+ options.SaveTokens = true;+ //handles exception thrown by external auth provider+ options.Events = new OAuthEvents {+ OnRemoteFailure = ctx =>+ {+ ctx.HandleResponse();+ var errorCode = ctx.Request.Query["error_code"].FirstOrDefault();+ var errorMessage = ctx.Request.Query["error_message"].FirstOrDefault();+ var state = ctx.Request.Query["state"].FirstOrDefault();+ errorCode = WebUtility.UrlEncode(errorCode);+ errorMessage = WebUtility.UrlEncode(errorMessage);+ ctx.Response.Redirect($"/fb-signin-failed?error_code={errorCode}&error_message={errorMessage}");- /// <summary>- /// Gets order of this registrar implementation- /// </summary>- public int Priority => 501;+ return Task.FromResult(0);+ }+ };+ });}++ /// <summary>+ /// Gets order of this registrar implementation+ /// </summary>+ public int Priority => 501;}\ No newline at end of filediff --git a/src/Plugins/Authentication.Facebook/Infrastructure/StartupApplication.cs b/src/Plugins/Authentication.Facebook/Infrastructure/StartupApplication.csindex e38852ff8..7805312ac 100644--- a/src/Plugins/Authentication.Facebook/Infrastructure/StartupApplication.cs+++ b/src/Plugins/Authentication.Facebook/Infrastructure/StartupApplication.cs@@ -5,21 +5,20 @@ using Microsoft.AspNetCore.Hosting;using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;-namespace Authentication.Facebook.Infrastructure+namespace Authentication.Facebook.Infrastructure;++public class StartupApplication : IStartupApplication{- public class StartupApplication : IStartupApplication+ public void ConfigureServices(IServiceCollection services, IConfiguration configuration){- public void ConfigureServices(IServiceCollection services, IConfiguration configuration)- {- services.AddScoped<IExternalAuthenticationProvider, FacebookAuthenticationProvider>();- }+ services.AddScoped<IExternalAuthenticationProvider, FacebookAuthenticationProvider>();+ }- public int Priority => 10;- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)- {+ public int Priority => 10;- }- public bool BeforeConfigure => false;+ public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)+ {}-}+ public bool BeforeConfigure => false;+}\ No newline at end of filediff --git a/src/Plugins/Authentication.Facebook/Models/ConfigurationModel.cs b/src/Plugins/Authentication.Facebook/Models/ConfigurationModel.csindex c054d9f68..51a182ed9 100644--- a/src/Plugins/Authentication.Facebook/Models/ConfigurationModel.cs+++ b/src/Plugins/Authentication.Facebook/Models/ConfigurationModel.cs@@ -1,17 +1,16 @@using Grand.Infrastructure.ModelBinding;using Grand.Infrastructure.Models;-namespace Authentication.Facebook.Models+namespace Authentication.Facebook.Models;++public class ConfigurationModel : BaseModel{- public class ConfigurationModel : BaseModel- {- [GrandResourceDisplayName("Authentication.Facebook.ClientKeyIdentifier")]- public string ClientId { get; set; }+ [GrandResourceDisplayName("Authentication.Facebook.ClientKeyIdentifier")]+ public string ClientId { get; set; }- [GrandResourceDisplayName("Authentication.Facebook.ClientSecret")]- public string ClientSecret { get; set; }+ [GrandResourceDisplayName("Authentication.Facebook.ClientSecret")]+ public string ClientSecret { get; set; }- [GrandResourceDisplayName("Authentication.Facebook.DisplayOrder")]- public int DisplayOrder { get; set; }- }+ [GrandResourceDisplayName("Authentication.Facebook.DisplayOrder")]+ public int DisplayOrder { get; set; }}\ No newline at end of filediff --git a/src/Plugins/Authentication.Facebook/Models/FailedModel.cs b/src/Plugins/Authentication.Facebook/Models/FailedModel.csindex 032300832..c09d4e109 100644--- a/src/Plugins/Authentication.Facebook/Models/FailedModel.cs+++ b/src/Plugins/Authentication.Facebook/Models/FailedModel.cs@@ -1,10 +1,9 @@using Grand.Infrastructure.Models;-namespace Authentication.Facebook.Models+namespace Authentication.Facebook.Models;++public class FailedModel : BaseModel{- public class FailedModel : BaseModel- {- public string ErrorCode { get; set; }- public string ErrorMessage { get; set; }- }-}+ public string ErrorCode { get; set; }+ public string ErrorMessage { get; set; }+}\ No newline at end of filediff --git a/src/Plugins/Authentication.Facebook/Views/FacebookAuthentication/FacebookSignInFailed.cshtml b/src/Plugins/Authentication.Facebook/Views/FacebookAuthentication/FacebookSignInFailed.cshtmlindex f3fd33026..3f3d23519 100644--- a/src/Plugins/Authentication.Facebook/Views/FacebookAuthentication/FacebookSignInFailed.cshtml+++ b/src/Plugins/Authentication.Facebook/Views/FacebookAuthentication/FacebookSignInFailed.cshtml@@ -12,4 +12,4 @@@Loc["Authentication.Facebook.Failed.ErrorMessage"]: @Model.ErrorMessage</div></div>-</div>+</div>\ No newline at end of filediff --git a/src/Plugins/Authentication.Facebook/Views/Shared/Components/FacebookAuthentication/Default.cshtml b/src/Plugins/Authentication.Facebook/Views/Shared/Components/FacebookAuthentication/Default.cshtmlindex fb591d647..4ad52f9bd 100644--- a/src/Plugins/Authentication.Facebook/Views/Shared/Components/FacebookAuthentication/Default.cshtml+++ b/src/Plugins/Authentication.Facebook/Views/Shared/Components/FacebookAuthentication/Default.cshtml@@ -1,9 +1,9 @@@{Layout = "";}-<link rel="stylesheet" type="text/css" asp-src="/Plugins/Authentication.Facebook/Assets/facebookstyles.css" />+<link rel="stylesheet" type="text/css" asp-src="/Plugins/Authentication.Facebook/Assets/facebookstyles.css"/><div class="facebook-login-block"><div class="buttons">- <a href="@Url.Action("FacebookLogin", "FacebookAuthentication", new { ReturnUrl = Context.Request.Query["ReturnUrl"].ToString()})" class="facebook-btn"></a>+ <a href="@Url.Action("FacebookLogin", "FacebookAuthentication", new { ReturnUrl = Context.Request.Query["ReturnUrl"].ToString() })" class="facebook-btn"></a></div>-</div>+</div>\ No newline at end of filediff --git a/src/Plugins/Authentication.Facebook/Views/_ViewImports.cshtml b/src/Plugins/Authentication.Facebook/Views/_ViewImports.cshtmlindex 2fb08c043..fb3b84aa9 100644--- a/src/Plugins/Authentication.Facebook/Views/_ViewImports.cshtml+++ b/src/Plugins/Authentication.Facebook/Views/_ViewImports.cshtml@@ -4,5 +4,6 @@@using Microsoft.AspNetCore.Mvc.ViewFeatures@using Grand.Infrastructure.Extensions+@using Grand.Web.Common.Localization-@inject Grand.Web.Common.Localization.LocService Loc+@inject LocService Loc\ No newline at end of filediff --git a/src/Plugins/Authentication.Google/Areas/Admin/Controllers/GoogleAuthenticationSettingsController.cs b/src/Plugins/Authentication.Google/Areas/Admin/Controllers/GoogleAuthenticationSettingsController.csindex 31925e51c..ce1afb1a2 100644--- a/src/Plugins/Authentication.Google/Areas/Admin/Controllers/GoogleAuthenticationSettingsController.cs+++ b/src/Plugins/Authentication.Google/Areas/Admin/Controllers/GoogleAuthenticationSettingsController.cs@@ -8,78 +8,75 @@ using Grand.Web.Common.Security.Authorization;using Microsoft.AspNetCore.Mvc;using Microsoft.Extensions.Configuration;-namespace Authentication.Google.Areas.Admin.Controllers+namespace Authentication.Google.Areas.Admin.Controllers;++[PermissionAuthorize(PermissionSystemName.ExternalAuthenticationMethods)]+public class GoogleAuthenticationSettingsController : BaseAdminPluginController{- [PermissionAuthorize(PermissionSystemName.ExternalAuthenticationMethods)]- public class GoogleAuthenticationSettingsController : BaseAdminPluginController+ #region Ctor++ public GoogleAuthenticationSettingsController(+ GoogleExternalAuthSettings googleExternalAuthSettings,+ ITranslationService translationService,+ IPermissionService permissionService,+ ISettingService settingService,+ IConfiguration configuration){- #region Fields-- private readonly GoogleExternalAuthSettings _googleExternalAuthSettings;- private readonly ITranslationService _translationService;- private readonly IPermissionService _permissionService;- private readonly ISettingService _settingService;- private readonly IConfiguration _configuration;-- #endregion-- #region Ctor-- public GoogleAuthenticationSettingsController(- GoogleExternalAuthSettings googleExternalAuthSettings,- ITranslationService translationService,- IPermissionService permissionService,- ISettingService settingService,- IConfiguration configuration)- {- _googleExternalAuthSettings = googleExternalAuthSettings;- _translationService = translationService;- _permissionService = permissionService;- _settingService = settingService;- _configuration = configuration;- }+ _googleExternalAuthSettings = googleExternalAuthSettings;+ _translationService = translationService;+ _permissionService = permissionService;+ _settingService = settingService;+ _configuration = configuration;+ }- #endregion+ #endregion- #region Methods+ #region Fields+ private readonly GoogleExternalAuthSettings _googleExternalAuthSettings;+ private readonly ITranslationService _translationService;+ private readonly IPermissionService _permissionService;+ private readonly ISettingService _settingService;+ private readonly IConfiguration _configuration;- public async Task<IActionResult> Configure()- {- if (!await _permissionService.Authorize(StandardPermission.ManageExternalAuthenticationMethods))- return AccessDeniedView();+ #endregion- var model = new ConfigurationModel {- ClientKeyIdentifier = _configuration["GoogleSettings:ClientId"],- ClientSecret = _configuration["GoogleSettings:ClientSecret"],- DisplayOrder = _googleExternalAuthSettings.DisplayOrder- };+ #region Methods- return View(model);- }+ public async Task<IActionResult> Configure()+ {+ if (!await _permissionService.Authorize(StandardPermission.ManageExternalAuthenticationMethods))+ return AccessDeniedView();- [HttpPost]- public async Task<IActionResult> Configure(ConfigurationModel model)- {- if (!await _permissionService.Authorize(StandardPermission.ManageExternalAuthenticationMethods))- return AccessDeniedView();+ var model = new ConfigurationModel {+ ClientKeyIdentifier = _configuration["GoogleSettings:ClientId"],+ ClientSecret = _configuration["GoogleSettings:ClientSecret"],+ DisplayOrder = _googleExternalAuthSettings.DisplayOrder+ };- if (!ModelState.IsValid)- return await Configure();+ return View(model);+ }- _googleExternalAuthSettings.DisplayOrder = model.DisplayOrder;+ [HttpPost]+ public async Task<IActionResult> Configure(ConfigurationModel model)+ {+ if (!await _permissionService.Authorize(StandardPermission.ManageExternalAuthenticationMethods))+ return AccessDeniedView();- await _settingService.SaveSetting(_googleExternalAuthSettings);+ if (!ModelState.IsValid)+ return await Configure();- //now clear settings cache- await _settingService.ClearCache();+ _googleExternalAuthSettings.DisplayOrder = model.DisplayOrder;- Success(_translationService.GetResource("Admin.Plugins.Saved"));+ await _settingService.SaveSetting(_googleExternalAuthSettings);- return await Configure();+ //now clear settings cache+ await _settingService.ClearCache();- }+ Success(_translationService.GetResource("Admin.Plugins.Saved"));- #endregion+ return await Configure();}++ #endregion}\ No newline at end of filediff --git a/src/Plugins/Authentication.Google/Areas/Admin/Views/GoogleAuthenticationSettings/Configure.cshtml b/src/Plugins/Authentication.Google/Areas/Admin/Views/GoogleAuthenticationSettings/Configure.cshtmlindex 873ff6e1a..049efa8fb 100644--- a/src/Plugins/Authentication.Google/Areas/Admin/Views/GoogleAuthenticationSettings/Configure.cshtml+++ b/src/Plugins/Authentication.Google/Areas/Admin/Views/GoogleAuthenticationSettings/Configure.cshtml@@ -3,7 +3,7 @@Layout = "_ConfigurePlugin";}-<input id="active-menu-item" type="hidden" value="/Admin/ExternalAuthentication/Methods" />+<input id="active-menu-item" type="hidden" value="/Admin/ExternalAuthentication/Methods"/><form asp-controller="GoogleAuthenticationSettings" asp-area="Admin" asp-action="Configure" method="post"><div class="panel-group">@@ -14,35 +14,35 @@<div class="panel-body">@Html.Raw(Loc["Plugins.ExternalAuth.Google.Description"])<p>- <br /><br />- To edit google settings in the grandnode application, please open the file App_Settings.json,+ <br/><br/>+ To edit google settings in the grandnode application, please open the file App_Settings.json,find section GoogleSettings and enter the correct values.</p><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="ClientKeyIdentifier" class="control-label" />+ <admin-label asp-for="ClientKeyIdentifier" class="control-label"/></div><div class="col-md-9 col-sm-9">- <input asp-for=ClientKeyIdentifier type="text"- disabled class="form-control k-input text-box single-line" />+ <input asp-for="ClientKeyIdentifier" type="text"+ disabled class="form-control k-input text-box single-line"/><span asp-validation-for="ClientKeyIdentifier"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="ClientSecret" class="control-label" />+ <admin-label asp-for="ClientSecret" class="control-label"/></div><div class="col-md-9 col-sm-9">- <input asp-for=ClientSecret type="text" disabled class="form-control k-input text-box single-line" />+ <input asp-for="ClientSecret" type="text" disabled class="form-control k-input text-box single-line"/><span asp-validation-for="ClientSecret"></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" />+ <admin-label asp-for="DisplayOrder" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="DisplayOrder" />+ <admin-input asp-for="DisplayOrder"/><span asp-validation-for="DisplayOrder"></span></div></div>@@ -50,7 +50,7 @@<div class="panel-footer"><div class="row"><div class="offset-md-3 offset-sm-3 col-md-9 col-sm-9">- <input type="submit" name="save" class="btn green" value="@Loc["Admin.Common.Save"]" />+ <input type="submit" name="save" class="btn green" value="@Loc["Admin.Common.Save"]"/></div></div></div>diff --git a/src/Plugins/Authentication.Google/Areas/Admin/_ViewImports.cshtml b/src/Plugins/Authentication.Google/Areas/Admin/_ViewImports.cshtmlindex 2fb08c043..fb3b84aa9 100644--- a/src/Plugins/Authentication.Google/Areas/Admin/_ViewImports.cshtml+++ b/src/Plugins/Authentication.Google/Areas/Admin/_ViewImports.cshtml@@ -4,5 +4,6 @@@using Microsoft.AspNetCore.Mvc.ViewFeatures@using Grand.Infrastructure.Extensions+@using Grand.Web.Common.Localization-@inject Grand.Web.Common.Localization.LocService Loc+@inject LocService Loc\ No newline at end of filediff --git a/src/Plugins/Authentication.Google/Components/GoogleAuthenticationViewComponent.cs b/src/Plugins/Authentication.Google/Components/GoogleAuthenticationViewComponent.csindex 05f6eb47d..0ffe0bdad 100644--- a/src/Plugins/Authentication.Google/Components/GoogleAuthenticationViewComponent.cs+++ b/src/Plugins/Authentication.Google/Components/GoogleAuthenticationViewComponent.cs@@ -1,13 +1,12 @@using Microsoft.AspNetCore.Mvc;-namespace Authentication.Google.Components+namespace Authentication.Google.Components;++[ViewComponent(Name = "GoogleAuthentication")]+public class GoogleAuthenticationViewComponent : ViewComponent{- [ViewComponent(Name = "GoogleAuthentication")]- public class GoogleAuthenticationViewComponent : ViewComponent+ public IViewComponentResult Invoke(){- public IViewComponentResult Invoke()- {- return View();- }+ return View();}}\ No newline at end of filediff --git a/src/Plugins/Authentication.Google/Controllers/GoogleAuthenticationController.cs b/src/Plugins/Authentication.Google/Controllers/GoogleAuthenticationController.csindex b2098b234..9cc8fe194 100644--- a/src/Plugins/Authentication.Google/Controllers/GoogleAuthenticationController.cs+++ b/src/Plugins/Authentication.Google/Controllers/GoogleAuthenticationController.cs@@ -1,5 +1,6 @@using Authentication.Google.Models;using Grand.Business.Core.Interfaces.Authentication;+using Grand.Business.Core.Utilities.Authentication;using Grand.SharedKernel;using Grand.Web.Common.Controllers;using Microsoft.AspNetCore.Authentication;@@ -7,77 +8,79 @@ using Microsoft.AspNetCore.Authentication.Google;using Microsoft.AspNetCore.Mvc;using Microsoft.Extensions.Configuration;using System.Security.Claims;-using Grand.Business.Core.Utilities.Authentication;-namespace Authentication.Google.Controllers+namespace Authentication.Google.Controllers;++public class GoogleAuthenticationController : BasePluginController{- public class GoogleAuthenticationController : BasePluginController+ #region Ctor++ public GoogleAuthenticationController(IExternalAuthenticationService externalAuthenticationService,+ IConfiguration configuration)+ {+ _externalAuthenticationService = externalAuthenticationService;+ _configuration = configuration;+ }++ #endregion++ #region Fields++ private readonly IExternalAuthenticationService _externalAuthenticationService;+ private readonly IConfiguration _configuration;++ #endregion++ #region Methods++ public IActionResult GoogleLogin(string returnUrl){- #region Fields-- private readonly IExternalAuthenticationService _externalAuthenticationService;- private readonly IConfiguration _configuration;-- #endregion-- #region Ctor-- public GoogleAuthenticationController(IExternalAuthenticationService externalAuthenticationService,- IConfiguration configuration)- {- _externalAuthenticationService = externalAuthenticationService;- _configuration = configuration;- }-- #endregion-- #region Methods-- public IActionResult GoogleLogin(string returnUrl)- {- if (!_externalAuthenticationService.AuthenticationProviderIsAvailable(GoogleAuthenticationDefaults.ProviderSystemName))- throw new GrandException("Google authentication module cannot be loaded");-- if (string.IsNullOrEmpty(_configuration["GoogleSettings:ClientId"]) || string.IsNullOrEmpty(_configuration["GoogleSettings:ClientSecret"]))- throw new GrandException("Google authentication module not configured");-- //configure login callback action- var authenticationProperties = new AuthenticationProperties {- RedirectUri = Url.Action("GoogleLoginCallback", "GoogleAuthentication", new { returnUrl })- };-- return Challenge(authenticationProperties, GoogleDefaults.AuthenticationScheme);- }-- public async Task<IActionResult> GoogleLoginCallback(string returnUrl)- {- //authenticate google user- var authenticateResult = await HttpContext.AuthenticateAsync(GoogleDefaults.AuthenticationScheme);- if (!authenticateResult.Succeeded || !authenticateResult.Principal.Claims.Any())- return RedirectToRoute("Login");-- //create external authentication parameters- var authenticationParameters = new ExternalAuthParam {- ProviderSystemName = GoogleAuthenticationDefaults.ProviderSystemName,- AccessToken = await HttpContext.GetTokenAsync(GoogleDefaults.AuthenticationScheme, "access_token"),- Email = authenticateResult.Principal.FindFirst(claim => claim.Type == ClaimTypes.Email)?.Value,- Identifier = authenticateResult.Principal.FindFirst(claim => claim.Type == ClaimTypes.NameIdentifier)?.Value,- Name = authenticateResult.Principal.FindFirst(claim => claim.Type == ClaimTypes.Name)?.Value,- Claims = authenticateResult.Principal.Claims.ToList()- };-- //authenticate grand user- return await _externalAuthenticationService.Authenticate(authenticationParameters, returnUrl);- }-- public IActionResult GoogleSignInFailed(string error_message)- {- //handle exception and display message to user- var model = new FailedModel {- ErrorMessage = error_message- };- return View(model);- }- #endregion+ if (!_externalAuthenticationService.AuthenticationProviderIsAvailable(GoogleAuthenticationDefaults+ .ProviderSystemName))+ throw new GrandException("Google authentication module cannot be loaded");++ if (string.IsNullOrEmpty(_configuration["GoogleSettings:ClientId"]) ||+ string.IsNullOrEmpty(_configuration["GoogleSettings:ClientSecret"]))+ throw new GrandException("Google authentication module not configured");++ //configure login callback action+ var authenticationProperties = new AuthenticationProperties {+ RedirectUri = Url.Action("GoogleLoginCallback", "GoogleAuthentication", new { returnUrl })+ };++ return Challenge(authenticationProperties, GoogleDefaults.AuthenticationScheme);+ }++ public async Task<IActionResult> GoogleLoginCallback(string returnUrl)+ {+ //authenticate google user+ var authenticateResult = await HttpContext.AuthenticateAsync(GoogleDefaults.AuthenticationScheme);+ if (!authenticateResult.Succeeded || !authenticateResult.Principal.Claims.Any())+ return RedirectToRoute("Login");++ //create external authentication parameters+ var authenticationParameters = new ExternalAuthParam {+ ProviderSystemName = GoogleAuthenticationDefaults.ProviderSystemName,+ AccessToken = await HttpContext.GetTokenAsync(GoogleDefaults.AuthenticationScheme, "access_token"),+ Email = authenticateResult.Principal.FindFirst(claim => claim.Type == ClaimTypes.Email)?.Value,+ Identifier =+ authenticateResult.Principal.FindFirst(claim => claim.Type == ClaimTypes.NameIdentifier)?.Value,+ Name = authenticateResult.Principal.FindFirst(claim => claim.Type == ClaimTypes.Name)?.Value,+ Claims = authenticateResult.Principal.Claims.ToList()+ };++ //authenticate grand user+ return await _externalAuthenticationService.Authenticate(authenticationParameters, returnUrl);+ }++ public IActionResult GoogleSignInFailed(string error_message)+ {+ //handle exception and display message to user+ var model = new FailedModel {+ ErrorMessage = error_message+ };+ return View(model);}++ #endregion}\ No newline at end of filediff --git a/src/Plugins/Authentication.Google/EndpointProvider.cs b/src/Plugins/Authentication.Google/EndpointProvider.csindex d328b8ee1..f4a82d0f6 100644--- a/src/Plugins/Authentication.Google/EndpointProvider.cs+++ b/src/Plugins/Authentication.Google/EndpointProvider.cs@@ -2,17 +2,17 @@using Microsoft.AspNetCore.Builder;using Microsoft.AspNetCore.Routing;-namespace Authentication.Google+namespace Authentication.Google;++public class EndpointProvider : IEndpointProvider{- public class EndpointProvider : IEndpointProvider+ public void RegisterEndpoint(IEndpointRouteBuilder endpointRouteBuilder){- public void RegisterEndpoint(IEndpointRouteBuilder endpointRouteBuilder)- {- endpointRouteBuilder.MapControllerRoute("Plugin.ExternalAuth.Google.SignInGoogle",- "google-signin-failed",- new { controller = "GoogleAuthentication", action = "GoogleSignInFailed" }- );- }- public int Priority => 10;+ endpointRouteBuilder.MapControllerRoute("Plugin.ExternalAuth.Google.SignInGoogle",+ "google-signin-failed",+ new { controller = "GoogleAuthentication", action = "GoogleSignInFailed" }+ );}-}++ public int Priority => 10;+}\ No newline at end of filediff --git a/src/Plugins/Authentication.Google/GoogleAuthenticationDefaults.cs b/src/Plugins/Authentication.Google/GoogleAuthenticationDefaults.csindex 808c3a72f..f18d7b023 100644--- a/src/Plugins/Authentication.Google/GoogleAuthenticationDefaults.cs+++ b/src/Plugins/Authentication.Google/GoogleAuthenticationDefaults.cs@@ -1,16 +1,14 @@--namespace Authentication.Google+namespace Authentication.Google;++/// <summary>+/// Default values used by the Google authentication middleware+/// </summary>+public static class GoogleAuthenticationDefaults{/// <summary>- /// Default values used by the Google authentication middleware+ /// System name of the external authentication method/// </summary>- public static class GoogleAuthenticationDefaults- {- /// <summary>- /// System name of the external authentication method- /// </summary>- public const string ProviderSystemName = "ExternalAuth.Google";+ public const string ProviderSystemName = "ExternalAuth.Google";- public const string ConfigurationUrl = "../GoogleAuthenticationSettings/Configure";- }-}+ public const string ConfigurationUrl = "../GoogleAuthenticationSettings/Configure";+}\ No newline at end of filediff --git a/src/Plugins/Authentication.Google/GoogleAuthenticationPlugin.cs b/src/Plugins/Authentication.Google/GoogleAuthenticationPlugin.csindex dbdd208fc..b557dd5a7 100644--- a/src/Plugins/Authentication.Google/GoogleAuthenticationPlugin.cs+++ b/src/Plugins/Authentication.Google/GoogleAuthenticationPlugin.cs@@ -3,84 +3,101 @@ using Grand.Business.Core.Interfaces.Common.Configuration;using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Infrastructure.Plugins;-namespace Authentication.Google+namespace Authentication.Google;++/// <summary>+/// Represents method for the authentication with google account+/// </summary>+public class GoogleAuthenticationPlugin : BasePlugin, IPlugin{+ #region Ctor++ public GoogleAuthenticationPlugin(ISettingService settingService, ITranslationService translationService,+ ILanguageService languageService)+ {+ _settingService = settingService;+ _translationService = translationService;+ _languageService = languageService;+ }++ #endregion++ #region Fields++ private readonly ISettingService _settingService;+ private readonly ITranslationService _translationService;+ private readonly ILanguageService _languageService;++ #endregion++ #region Methods+/// <summary>- /// Represents method for the authentication with google account+ /// Gets a configuration page URL/// </summary>- public class GoogleAuthenticationPlugin : BasePlugin, IPlugin+ public override string ConfigurationUrl(){- #region Fields-- private readonly ISettingService _settingService;- private readonly ITranslationService _translationService;- private readonly ILanguageService _languageService;-- #endregion-- #region Ctor-- public GoogleAuthenticationPlugin(ISettingService settingService, ITranslationService translationService, ILanguageService languageService)- {- _settingService = settingService;- _translationService = translationService;- _languageService = languageService;- }-- #endregion-- #region Methods-- /// <summary>- /// Gets a configuration page URL- /// </summary>- public override string ConfigurationUrl()- {- return GoogleAuthenticationDefaults.ConfigurationUrl;- }-- /// <summary>- /// Install the plugin- /// </summary>- public override async Task Install()- {- //settings- await _settingService.SaveSetting(new GoogleExternalAuthSettings());-- //locales- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.ExternalAuth.Google.Description", "<h4>Google Developers Console</h4><ul><li>Go to the <a href=\"https://console.developers.google.com/\" target=\"_blank\">Google Developers Console</a> and log in with your Google Developer Account</li><li>Select \"Create Project\"</li><li>Go to APIs & Auth -> Credentials in the left-hand navigation panel</li><li>Select \"Create new Client ID\" in the OAuth Panel</li><li>In the creation panel:<ul><li>Select \"Web application\" as Application Type</li><li>Set \"Authorized JavaScript origins\" to the URL of your store (http://www.yourStore.com)</li><li>Set \"Authorized redirect URI\" to URL of login callback (http://www.yourStore.com/signin-google)</li></ul></li><li>Then go to APIs & Auth -> Consent Screen and fill out</li><li>Now get your API key (Client ID and Client Secret) and configure your store</li><li>Please remember to restart the application after changes.</li></ul><p>For more details, read the Google docs: <a href=\"https://developers.google.com/accounts/docs/OAuth2\">Using OAuth 2.0 to Access Google APIs</a>.</p>");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.ExternalAuth.Google.Login", "Login using Google account");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.ExternalAuth.Google.ClientKeyIdentifier", "Client ID");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.ExternalAuth.Google.ClientSecret", "Client Secret");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.ExternalAuth.Google.Title", "<h4>Configuring Google OAuth2</h4>");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.ExternalAuth.Google.Failed", "Failed authentication");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.ExternalAuth.Google.Failed.Errormessage", "Error message: ");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.ExternalAuth.Google.DisplayOrder", "Display order");-- await base.Install();- }-- /// <summary>- /// Uninstall the plugin- /// </summary>- public override async Task Uninstall()- {- //settings- await _settingService.DeleteSetting<GoogleExternalAuthSettings>();-- //locales- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.ExternalAuth.Google.Description");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.ExternalAuth.Google.Login");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.ExternalAuth.Google.ClientKeyIdentifier");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.ExternalAuth.Google.ClientSecret");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.ExternalAuth.Google.Title");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.ExternalAuth.Google.DisplayOrder");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.ExternalAuth.Google.Failed");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.ExternalAuth.Google.Failed.Errormessage");-- await base.Uninstall();- }-- #endregion+ return GoogleAuthenticationDefaults.ConfigurationUrl;}-}++ /// <summary>+ /// Install the plugin+ /// </summary>+ public override async Task Install()+ {+ //settings+ await _settingService.SaveSetting(new GoogleExternalAuthSettings());++ //locales+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.ExternalAuth.Google.Description",+ "<h4>Google Developers Console</h4><ul><li>Go to the <a href=\"https://console.developers.google.com/\" target=\"_blank\">Google Developers Console</a> and log in with your Google Developer Account</li><li>Select \"Create Project\"</li><li>Go to APIs & Auth -> Credentials in the left-hand navigation panel</li><li>Select \"Create new Client ID\" in the OAuth Panel</li><li>In the creation panel:<ul><li>Select \"Web application\" as Application Type</li><li>Set \"Authorized JavaScript origins\" to the URL of your store (http://www.yourStore.com)</li><li>Set \"Authorized redirect URI\" to URL of login callback (http://www.yourStore.com/signin-google)</li></ul></li><li>Then go to APIs & Auth -> Consent Screen and fill out</li><li>Now get your API key (Client ID and Client Secret) and configure your store</li><li>Please remember to restart the application after changes.</li></ul><p>For more details, read the Google docs: <a href=\"https://developers.google.com/accounts/docs/OAuth2\">Using OAuth 2.0 to Access Google APIs</a>.</p>");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.ExternalAuth.Google.Login", "Login using Google account");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.ExternalAuth.Google.ClientKeyIdentifier", "Client ID");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.ExternalAuth.Google.ClientSecret", "Client Secret");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.ExternalAuth.Google.Title", "<h4>Configuring Google OAuth2</h4>");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.ExternalAuth.Google.Failed", "Failed authentication");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.ExternalAuth.Google.Failed.Errormessage", "Error message: ");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.ExternalAuth.Google.DisplayOrder", "Display order");++ await base.Install();+ }++ /// <summary>+ /// Uninstall the plugin+ /// </summary>+ public override async Task Uninstall()+ {+ //settings+ await _settingService.DeleteSetting<GoogleExternalAuthSettings>();++ //locales+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.ExternalAuth.Google.Description");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.ExternalAuth.Google.Login");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.ExternalAuth.Google.ClientKeyIdentifier");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.ExternalAuth.Google.ClientSecret");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.ExternalAuth.Google.Title");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.ExternalAuth.Google.DisplayOrder");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.ExternalAuth.Google.Failed");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.ExternalAuth.Google.Failed.Errormessage");++ await base.Uninstall();+ }++ #endregion+}\ No newline at end of filediff --git a/src/Plugins/Authentication.Google/GoogleAuthenticationProvider.cs b/src/Plugins/Authentication.Google/GoogleAuthenticationProvider.csindex 91c78117c..49122f1cf 100644--- a/src/Plugins/Authentication.Google/GoogleAuthenticationProvider.cs+++ b/src/Plugins/Authentication.Google/GoogleAuthenticationProvider.cs@@ -1,35 +1,33 @@using Grand.Business.Core.Interfaces.Authentication;-namespace Authentication.Google-{- public class GoogleAuthenticationProvider : IExternalAuthenticationProvider- {- private readonly GoogleExternalAuthSettings _googleExternalAuthSettings;+namespace Authentication.Google;- public GoogleAuthenticationProvider(GoogleExternalAuthSettings googleExternalAuthSettings)- {- _googleExternalAuthSettings = googleExternalAuthSettings;- }+public class GoogleAuthenticationProvider : IExternalAuthenticationProvider+{+ private readonly GoogleExternalAuthSettings _googleExternalAuthSettings;- public string ConfigurationUrl => GoogleAuthenticationDefaults.ConfigurationUrl;+ public GoogleAuthenticationProvider(GoogleExternalAuthSettings googleExternalAuthSettings)+ {+ _googleExternalAuthSettings = googleExternalAuthSettings;+ }- public string SystemName => GoogleAuthenticationDefaults.ProviderSystemName;+ public string ConfigurationUrl => GoogleAuthenticationDefaults.ConfigurationUrl;- public string FriendlyName => "Google authentication";+ public string SystemName => GoogleAuthenticationDefaults.ProviderSystemName;- public int Priority => _googleExternalAuthSettings.DisplayOrder;+ public string FriendlyName => "Google authentication";- public IList<string> LimitedToStores => new List<string>();+ public int Priority => _googleExternalAuthSettings.DisplayOrder;- public IList<string> LimitedToGroups => new List<string>();+ public IList<string> LimitedToStores => new List<string>();- /// <summary>- /// Gets a view component for displaying plugin in public store- /// </summary>- public async Task<string> GetPublicViewComponentName()- {- return await Task.FromResult("GoogleAuthentication");- }+ public IList<string> LimitedToGroups => new List<string>();+ /// <summary>+ /// Gets a view component for displaying plugin in public store+ /// </summary>+ public async Task<string> GetPublicViewComponentName()+ {+ return await Task.FromResult("GoogleAuthentication");}-}+}\ No newline at end of filediff --git a/src/Plugins/Authentication.Google/GoogleExternalAuthSettings.cs b/src/Plugins/Authentication.Google/GoogleExternalAuthSettings.csindex eaa80f682..889d35a92 100644--- a/src/Plugins/Authentication.Google/GoogleExternalAuthSettings.cs+++ b/src/Plugins/Authentication.Google/GoogleExternalAuthSettings.cs@@ -1,9 +1,8 @@using Grand.Domain.Configuration;-namespace Authentication.Google+namespace Authentication.Google;++public class GoogleExternalAuthSettings : ISettings{- public class GoogleExternalAuthSettings : ISettings- {- public int DisplayOrder { get; set; }- }-}+ public int DisplayOrder { get; set; }+}\ No newline at end of filediff --git a/src/Plugins/Authentication.Google/Infrastructure/GoogleAuthenticationBuilder.cs b/src/Plugins/Authentication.Google/Infrastructure/GoogleAuthenticationBuilder.csindex 24c8945e5..e60d18193 100644--- a/src/Plugins/Authentication.Google/Infrastructure/GoogleAuthenticationBuilder.cs+++ b/src/Plugins/Authentication.Google/Infrastructure/GoogleAuthenticationBuilder.cs@@ -6,46 +6,44 @@ using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;using System.Net;-namespace Authentication.Google.Infrastructure+namespace Authentication.Google.Infrastructure;++/// <summary>+/// Registration of google authentication service (plugin)+/// </summary>+public class GoogleAuthenticationBuilder : IAuthenticationBuilder{/// <summary>- /// Registration of google authentication service (plugin)+ /// Configure/// </summary>- public class GoogleAuthenticationBuilder : IAuthenticationBuilder+ /// <param name="builder">Authentication builder</param>+ /// <param name="configuration">Configuration</param>+ public void AddAuthentication(AuthenticationBuilder builder, IConfiguration configuration){- /// <summary>- /// Configure- /// </summary>- /// <param name="builder">Authentication builder</param>- /// <param name="configuration">Configuration</param>- public void AddAuthentication(AuthenticationBuilder builder, IConfiguration configuration)+ builder.AddGoogle(GoogleDefaults.AuthenticationScheme, options =>{- builder.AddGoogle(GoogleDefaults.AuthenticationScheme, options =>- {- var clientId = configuration["GoogleSettings:ClientId"];- var clientSecret = configuration["GoogleSettings:ClientSecret"];-- options.ClientId = !string.IsNullOrWhiteSpace(clientId) ? clientId : "000";- options.ClientSecret = !string.IsNullOrWhiteSpace(clientSecret) ? clientSecret : "000";- options.SaveTokens = true;+ var clientId = configuration["GoogleSettings:ClientId"];+ var clientSecret = configuration["GoogleSettings:ClientSecret"];- //handles exception thrown by external auth provider- options.Events = new OAuthEvents {- OnRemoteFailure = ctx =>- {- ctx.HandleResponse();- var errorMessage = ctx.Failure?.Message;- var state = ctx.Request.Query["state"].FirstOrDefault();- errorMessage = WebUtility.UrlEncode(errorMessage);- ctx.Response.Redirect($"/google-signin-failed?error_message={errorMessage}");+ options.ClientId = !string.IsNullOrWhiteSpace(clientId) ? clientId : "000";+ options.ClientSecret = !string.IsNullOrWhiteSpace(clientSecret) ? clientSecret : "000";+ options.SaveTokens = true;- return Task.FromResult(0);- }- };- });-- }- public int Priority => 502;+ //handles exception thrown by external auth provider+ options.Events = new OAuthEvents {+ OnRemoteFailure = ctx =>+ {+ ctx.HandleResponse();+ var errorMessage = ctx.Failure?.Message;+ var state = ctx.Request.Query["state"].FirstOrDefault();+ errorMessage = WebUtility.UrlEncode(errorMessage);+ ctx.Response.Redirect($"/google-signin-failed?error_message={errorMessage}");+ return Task.FromResult(0);+ }+ };+ });}-}++ public int Priority => 502;+}\ No newline at end of filediff --git a/src/Plugins/Authentication.Google/Infrastructure/GoogleAuthenticationEventConsumer.cs b/src/Plugins/Authentication.Google/Infrastructure/GoogleAuthenticationEventConsumer.csindex 70fb67cb6..3573e9a34 100644--- a/src/Plugins/Authentication.Google/Infrastructure/GoogleAuthenticationEventConsumer.cs+++ b/src/Plugins/Authentication.Google/Infrastructure/GoogleAuthenticationEventConsumer.cs@@ -6,72 +6,71 @@ using Grand.Infrastructure;using MediatR;using System.Security.Claims;-namespace Authentication.Google.Infrastructure+namespace Authentication.Google.Infrastructure;++/// <summary>+/// Google authentication event consumer (used for saving customer fields on registration)+/// </summary>+public class GoogleAuthenticationEventConsumer : INotificationHandler<RegisteredByExternalMethod>{- /// <summary>- /// Google authentication event consumer (used for saving customer fields on registration)- /// </summary>- public class GoogleAuthenticationEventConsumer : INotificationHandler<RegisteredByExternalMethod>- {- #region Fields+ #region Ctor- private readonly IUserFieldService _userFieldService;- private readonly IMessageProviderService _messageProviderService;- private readonly IWorkContext _workContext;- private readonly CustomerSettings _customerSettings;+ public GoogleAuthenticationEventConsumer(+ IUserFieldService userFieldService,+ IMessageProviderService messageProviderService,+ IWorkContext workContext,+ CustomerSettings customerSettings+ )+ {+ _userFieldService = userFieldService;+ _messageProviderService = messageProviderService;+ _workContext = workContext;+ _customerSettings = customerSettings;+ }- #endregion+ #endregion- #region Ctor+ #region Methods- public GoogleAuthenticationEventConsumer(- IUserFieldService userFieldService,- IMessageProviderService messageProviderService,- IWorkContext workContext,- CustomerSettings customerSettings- )- {- _userFieldService = userFieldService;- _messageProviderService = messageProviderService;- _workContext = workContext;- _customerSettings = customerSettings;- }+ public async Task Handle(RegisteredByExternalMethod eventMessage, CancellationToken cancellationToken)+ {+ if (eventMessage?.Customer == null || eventMessage.AuthenticationParameters == null)+ return;- #endregion+ //handle event only for this authentication method+ if (!eventMessage.AuthenticationParameters.ProviderSystemName.Equals(GoogleAuthenticationDefaults+ .ProviderSystemName))+ return;- #region Methods+ //store some of the customer fields+ var firstName = eventMessage.AuthenticationParameters.Claims+ ?.FirstOrDefault(claim => claim.Type == ClaimTypes.GivenName)?.Value;+ if (!string.IsNullOrEmpty(firstName))+ await _userFieldService.SaveField(eventMessage.Customer, SystemCustomerFieldNames.FirstName, firstName);- public async Task Handle(RegisteredByExternalMethod eventMessage, CancellationToken cancellationToken)- {- if (eventMessage?.Customer == null || eventMessage.AuthenticationParameters == null)- return;+ var lastName = eventMessage.AuthenticationParameters.Claims+ ?.FirstOrDefault(claim => claim.Type == ClaimTypes.Surname)?.Value;+ if (!string.IsNullOrEmpty(lastName))+ await _userFieldService.SaveField(eventMessage.Customer, SystemCustomerFieldNames.LastName, lastName);- //handle event only for this authentication method- if (!eventMessage.AuthenticationParameters.ProviderSystemName.Equals(GoogleAuthenticationDefaults- .ProviderSystemName))- return;+ //notifications for admin+ if (_customerSettings.NotifyNewCustomerRegistration)+ await _messageProviderService.SendCustomerRegisteredMessage(eventMessage.Customer,+ _workContext.CurrentStore, _workContext.WorkingLanguage.Id);- //store some of the customer fields- var firstName = eventMessage.AuthenticationParameters.Claims- ?.FirstOrDefault(claim => claim.Type == ClaimTypes.GivenName)?.Value;- if (!string.IsNullOrEmpty(firstName))- await _userFieldService.SaveField(eventMessage.Customer, SystemCustomerFieldNames.FirstName, firstName);+ //send welcome message+ await _messageProviderService.SendCustomerWelcomeMessage(eventMessage.Customer, _workContext.CurrentStore,+ _workContext.WorkingLanguage.Id);+ }- var lastName = eventMessage.AuthenticationParameters.Claims- ?.FirstOrDefault(claim => claim.Type == ClaimTypes.Surname)?.Value;- if (!string.IsNullOrEmpty(lastName))- await _userFieldService.SaveField(eventMessage.Customer, SystemCustomerFieldNames.LastName, lastName);+ #endregion- //notifications for admin- if (_customerSettings.NotifyNewCustomerRegistration)- await _messageProviderService.SendCustomerRegisteredMessage(eventMessage.Customer,- _workContext.CurrentStore, _workContext.WorkingLanguage.Id);+ #region Fields- //send welcome message- await _messageProviderService.SendCustomerWelcomeMessage(eventMessage.Customer, _workContext.CurrentStore,- _workContext.WorkingLanguage.Id);- }+ private readonly IUserFieldService _userFieldService;+ private readonly IMessageProviderService _messageProviderService;+ private readonly IWorkContext _workContext;+ private readonly CustomerSettings _customerSettings;- #endregion- }+ #endregion}\ No newline at end of filediff --git a/src/Plugins/Authentication.Google/Infrastructure/StartupApplication.cs b/src/Plugins/Authentication.Google/Infrastructure/StartupApplication.csindex 55a67c4d6..53cb41b09 100644--- a/src/Plugins/Authentication.Google/Infrastructure/StartupApplication.cs+++ b/src/Plugins/Authentication.Google/Infrastructure/StartupApplication.cs@@ -5,21 +5,20 @@ using Microsoft.AspNetCore.Hosting;using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;-namespace Authentication.Google.Infrastructure+namespace Authentication.Google.Infrastructure;++public class StartupApplication : IStartupApplication{- public class StartupApplication : IStartupApplication+ public void ConfigureServices(IServiceCollection services, IConfiguration configuration){- public void ConfigureServices(IServiceCollection services, IConfiguration configuration)- {- services.AddScoped<IExternalAuthenticationProvider, GoogleAuthenticationProvider>();- }+ services.AddScoped<IExternalAuthenticationProvider, GoogleAuthenticationProvider>();+ }- public int Priority => 10;- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)- {+ public int Priority => 10;- }- public bool BeforeConfigure => false;+ public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)+ {}-}+ public bool BeforeConfigure => false;+}\ No newline at end of filediff --git a/src/Plugins/Authentication.Google/Models/ConfigurationModel.cs b/src/Plugins/Authentication.Google/Models/ConfigurationModel.csindex 7d7c0b7bc..3ddbff6a2 100644--- a/src/Plugins/Authentication.Google/Models/ConfigurationModel.cs+++ b/src/Plugins/Authentication.Google/Models/ConfigurationModel.cs@@ -1,15 +1,16 @@using Grand.Infrastructure.ModelBinding;using Grand.Infrastructure.Models;-namespace Authentication.Google.Models+namespace Authentication.Google.Models;++public class ConfigurationModel : BaseModel{- public class ConfigurationModel : BaseModel- {- [GrandResourceDisplayName("Plugins.ExternalAuth.Google.ClientKeyIdentifier")]- public string ClientKeyIdentifier { get; set; }- [GrandResourceDisplayName("Plugins.ExternalAuth.Google.ClientSecret")]- public string ClientSecret { get; set; }- [GrandResourceDisplayName("Plugins.ExternalAuth.Google.DisplayOrder")]- public int DisplayOrder { get; set; }- }-}+ [GrandResourceDisplayName("Plugins.ExternalAuth.Google.ClientKeyIdentifier")]+ public string ClientKeyIdentifier { get; set; }++ [GrandResourceDisplayName("Plugins.ExternalAuth.Google.ClientSecret")]+ public string ClientSecret { get; set; }++ [GrandResourceDisplayName("Plugins.ExternalAuth.Google.DisplayOrder")]+ public int DisplayOrder { get; set; }+}\ No newline at end of filediff --git a/src/Plugins/Authentication.Google/Models/FailedModel.cs b/src/Plugins/Authentication.Google/Models/FailedModel.csindex 4c832420e..947536041 100644--- a/src/Plugins/Authentication.Google/Models/FailedModel.cs+++ b/src/Plugins/Authentication.Google/Models/FailedModel.cs@@ -1,9 +1,8 @@using Grand.Infrastructure.Models;-namespace Authentication.Google.Models+namespace Authentication.Google.Models;++public class FailedModel : BaseModel{- public class FailedModel : BaseModel- {- public string ErrorMessage { get; set; }- }-}+ public string ErrorMessage { get; set; }+}\ No newline at end of filediff --git a/src/Plugins/Authentication.Google/Views/GoogleAuthentication/GoogleSignInFailed.cshtml b/src/Plugins/Authentication.Google/Views/GoogleAuthentication/GoogleSignInFailed.cshtmlindex d4efac3f7..ed8b644b8 100644--- a/src/Plugins/Authentication.Google/Views/GoogleAuthentication/GoogleSignInFailed.cshtml+++ b/src/Plugins/Authentication.Google/Views/GoogleAuthentication/GoogleSignInFailed.cshtml@@ -11,4 +11,4 @@@Loc["Plugins.ExternalAuth.Google.Failed.ErrorMessage"]: @Model.ErrorMessage</div></div>-</div>+</div>\ No newline at end of filediff --git a/src/Plugins/Authentication.Google/Views/Shared/Components/GoogleAuthentication/Default.cshtml b/src/Plugins/Authentication.Google/Views/Shared/Components/GoogleAuthentication/Default.cshtmlindex d00254cfe..6ce6dbd04 100644--- a/src/Plugins/Authentication.Google/Views/Shared/Components/GoogleAuthentication/Default.cshtml+++ b/src/Plugins/Authentication.Google/Views/Shared/Components/GoogleAuthentication/Default.cshtml@@ -1,7 +1,7 @@@{Layout = "";}-<link rel="stylesheet" type="text/css" asp-src="/Plugins/Authentication.Google/Assets/googlestyles.css" />+<link rel="stylesheet" type="text/css" asp-src="/Plugins/Authentication.Google/Assets/googlestyles.css"/><div class="google-login-block"><div class="buttons"><a asp-controller="GoogleAuthentication" asp-action="GoogleLogin" asp-route-returnurl="@Context.Request.Query["ReturnUrl"]" class="google-btn"></a>diff --git a/src/Plugins/Authentication.Google/Views/_ViewImports.cshtml b/src/Plugins/Authentication.Google/Views/_ViewImports.cshtmlindex 2fb08c043..fb3b84aa9 100644--- a/src/Plugins/Authentication.Google/Views/_ViewImports.cshtml+++ b/src/Plugins/Authentication.Google/Views/_ViewImports.cshtml@@ -4,5 +4,6 @@@using Microsoft.AspNetCore.Mvc.ViewFeatures@using Grand.Infrastructure.Extensions+@using Grand.Web.Common.Localization-@inject Grand.Web.Common.Localization.LocService Loc+@inject LocService Loc\ No newline at end of filediff --git a/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/CustomerGroupsController.cs b/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/CustomerGroupsController.csindex dcd987680..4499b1942 100644--- a/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/CustomerGroupsController.cs+++ b/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/CustomerGroupsController.cs@@ -8,92 +8,94 @@ using Grand.Web.Common.Controllers;using Microsoft.AspNetCore.Mvc;using Microsoft.AspNetCore.Mvc.Rendering;-namespace DiscountRules.Standard.Areas.Admin.Controllers+namespace DiscountRules.Standard.Areas.Admin.Controllers;++public class CustomerGroupsController : BaseAdminPluginController{- public class CustomerGroupsController : BaseAdminPluginController+ private readonly IDiscountService _discountService;+ private readonly IGroupService _groupService;+ private readonly IPermissionService _permissionService;++ public CustomerGroupsController(+ IDiscountService discountService,+ IGroupService groupService,+ IPermissionService permissionService)+ {+ _discountService = discountService;+ _groupService = groupService;+ _permissionService = permissionService;+ }++ public async Task<IActionResult> Configure(string discountId, string discountRequirementId){- private readonly IDiscountService _discountService;- private readonly IGroupService _groupService;- private readonly IPermissionService _permissionService;+ if (!await _permissionService.Authorize(StandardPermission.ManageDiscounts))+ return Content("Access denied");- public CustomerGroupsController(- IDiscountService discountService,- IGroupService groupService,- IPermissionService permissionService)+ var discount = await _discountService.GetDiscountById(discountId);+ if (discount == null)+ throw new ArgumentException("Discount could not be loaded");++ DiscountRule discountRequirement = null;+ if (!string.IsNullOrEmpty(discountRequirementId)){- _discountService = discountService;- _groupService = groupService;- _permissionService = permissionService;+ discountRequirement = discount.DiscountRules.FirstOrDefault(dr => dr.Id == discountRequirementId);+ if (discountRequirement == null)+ return Content("Failed to load requirement.");}- public async Task<IActionResult> Configure(string discountId, string discountRequirementId)- {- if (!await _permissionService.Authorize(StandardPermission.ManageDiscounts))- return Content("Access denied");+ var model = new RequirementCustomerGroupsModel {+ RequirementId = !string.IsNullOrEmpty(discountRequirementId) ? discountRequirementId : "",+ DiscountId = discountId,+ CustomerGroupId = discountRequirement?.Metadata+ };- var discount = await _discountService.GetDiscountById(discountId);- if (discount == null)- throw new ArgumentException("Discount could not be loaded");+ //customer groups+ model.AvailableCustomerGroups.Add(new SelectListItem { Text = "Select customer group", Value = "" });+ foreach (var cr in await _groupService.GetAllCustomerGroups(showHidden: true))+ model.AvailableCustomerGroups.Add(new SelectListItem {+ Text = cr.Name, Value = cr.Id,+ Selected = discountRequirement != null && cr.Id == discountRequirement?.Metadata+ });- DiscountRule discountRequirement = null;- if (!string.IsNullOrEmpty(discountRequirementId))- {- discountRequirement = discount.DiscountRules.FirstOrDefault(dr => dr.Id == discountRequirementId);- if (discountRequirement == null)- return Content("Failed to load requirement.");- }+ //add a prefix+ ViewData.TemplateInfo.HtmlFieldPrefix =+ $"DiscountRulesCustomerGroups{(!string.IsNullOrEmpty(discountRequirementId) ? discountRequirementId : "")}";- var model = new RequirementCustomerGroupsModel {- RequirementId = !string.IsNullOrEmpty(discountRequirementId) ? discountRequirementId : "",- DiscountId = discountId,- CustomerGroupId = discountRequirement?.Metadata- };+ return View(model);+ }- //customer groups- model.AvailableCustomerGroups.Add(new SelectListItem { Text = "Select customer group", Value = "" });- foreach (var cr in await _groupService.GetAllCustomerGroups(showHidden: true))- model.AvailableCustomerGroups.Add(new SelectListItem { Text = cr.Name, Value = cr.Id, Selected = discountRequirement != null && cr.Id == discountRequirement?.Metadata });+ [HttpPost]+ [AutoValidateAntiforgeryToken]+ public async Task<IActionResult> Configure(string discountId, string discountRequirementId, string customerGroupId)+ {+ if (!await _permissionService.Authorize(StandardPermission.ManageDiscounts))+ return Content("Access denied");- //add a prefix- ViewData.TemplateInfo.HtmlFieldPrefix =- $"DiscountRulesCustomerGroups{(!string.IsNullOrEmpty(discountRequirementId) ? discountRequirementId : "")}";+ var discount = await _discountService.GetDiscountById(discountId);+ if (discount == null)+ throw new ArgumentException("Discount could not be loaded");- return View(model);- }+ DiscountRule discountRequirement = null;+ if (!string.IsNullOrEmpty(discountRequirementId))+ discountRequirement = discount.DiscountRules.FirstOrDefault(dr => dr.Id == discountRequirementId);- [HttpPost]- [AutoValidateAntiforgeryToken]- public async Task<IActionResult> Configure(string discountId, string discountRequirementId, string customerGroupId)+ if (discountRequirement != null){- if (!await _permissionService.Authorize(StandardPermission.ManageDiscounts))- return Content("Access denied");-- var discount = await _discountService.GetDiscountById(discountId);- if (discount == null)- throw new ArgumentException("Discount could not be loaded");-- DiscountRule discountRequirement = null;- if (!string.IsNullOrEmpty(discountRequirementId))- discountRequirement = discount.DiscountRules.FirstOrDefault(dr => dr.Id == discountRequirementId);-- if (discountRequirement != null)- {- //update existing rule- discountRequirement.Metadata = customerGroupId;- await _discountService.UpdateDiscount(discount);- }- else- {- //save new rule- discountRequirement = new DiscountRule {- DiscountRequirementRuleSystemName = "DiscountRules.Standard.MustBeAssignedToCustomerGroup",- Metadata = customerGroupId- };- discount.DiscountRules.Add(discountRequirement);- await _discountService.UpdateDiscount(discount);-- }- return Json(new { Result = true, NewRequirementId = discountRequirement.Id });+ //update existing rule+ discountRequirement.Metadata = customerGroupId;+ await _discountService.UpdateDiscount(discount);}+ else+ {+ //save new rule+ discountRequirement = new DiscountRule {+ DiscountRequirementRuleSystemName = "DiscountRules.Standard.MustBeAssignedToCustomerGroup",+ Metadata = customerGroupId+ };+ discount.DiscountRules.Add(discountRequirement);+ await _discountService.UpdateDiscount(discount);+ }++ return Json(new { Result = true, NewRequirementId = discountRequirement.Id });}}\ No newline at end of filediff --git a/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/HadSpentAmountController.cs b/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/HadSpentAmountController.csindex fcc40fbfa..a421d4b68 100644--- a/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/HadSpentAmountController.cs+++ b/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/HadSpentAmountController.cs@@ -7,86 +7,85 @@ using Grand.Web.Common.Controllers;using Microsoft.AspNetCore.Mvc;using System.Globalization;-namespace DiscountRules.Standard.Areas.Admin.Controllers+namespace DiscountRules.Standard.Areas.Admin.Controllers;++public class HadSpentAmountController : BaseAdminPluginController{- public class HadSpentAmountController : BaseAdminPluginController+ private readonly IDiscountService _discountService;+ private readonly IPermissionService _permissionService;++ public HadSpentAmountController(+ IDiscountService discountService,+ IPermissionService permissionService)+ {+ _discountService = discountService;+ _permissionService = permissionService;+ }++ public async Task<IActionResult> Configure(string discountId, string discountRequirementId){- private readonly IDiscountService _discountService;- private readonly IPermissionService _permissionService;+ if (!await _permissionService.Authorize(StandardPermission.ManageDiscounts))+ return Content("Access denied");- public HadSpentAmountController(- IDiscountService discountService,- IPermissionService permissionService)+ var discount = await _discountService.GetDiscountById(discountId);+ if (discount == null)+ throw new ArgumentException("Discount could not be loaded");++ double spentAmountRequirement = 0;+ if (!string.IsNullOrEmpty(discountRequirementId)){- _discountService = discountService;- _permissionService = permissionService;+ var discountRequirement = discount.DiscountRules.FirstOrDefault(dr => dr.Id == discountRequirementId);+ if (discountRequirement == null)+ return Content("Failed to load requirement.");++ spentAmountRequirement = Convert.ToDouble(discountRequirement.Metadata);}- public async Task<IActionResult> Configure(string discountId, string discountRequirementId)- {- if (!await _permissionService.Authorize(StandardPermission.ManageDiscounts))- return Content("Access denied");+ var model = new RequirementSpentAmountModel {+ RequirementId = !string.IsNullOrEmpty(discountRequirementId) ? discountRequirementId : "",+ DiscountId = discountId,+ SpentAmount = spentAmountRequirement+ };- var discount = await _discountService.GetDiscountById(discountId);- if (discount == null)- throw new ArgumentException("Discount could not be loaded");+ //add a prefix+ ViewData.TemplateInfo.HtmlFieldPrefix =+ $"DiscountRulesHadSpentAmount{discount.Id}-{(!string.IsNullOrEmpty(discountRequirementId) ? discountRequirementId : "")}";- double spentAmountRequirement = 0;- if (!string.IsNullOrEmpty(discountRequirementId))- {- var discountRequirement = discount.DiscountRules.FirstOrDefault(dr => dr.Id == discountRequirementId);- if (discountRequirement == null)- return Content("Failed to load requirement.");+ return View(model);+ }- spentAmountRequirement = Convert.ToDouble(discountRequirement.Metadata);- }+ [HttpPost]+ [AutoValidateAntiforgeryToken]+ public async Task<IActionResult> Configure(string discountId, string discountRequirementId, double spentAmount)+ {+ if (!await _permissionService.Authorize(StandardPermission.ManageDiscounts))+ return Content("Access denied");- var model = new RequirementSpentAmountModel {- RequirementId = !string.IsNullOrEmpty(discountRequirementId) ? discountRequirementId : "",- DiscountId = discountId,- SpentAmount = spentAmountRequirement- };+ var discount = await _discountService.GetDiscountById(discountId);+ if (discount == null)+ throw new ArgumentException("Discount could not be loaded");- //add a prefix- ViewData.TemplateInfo.HtmlFieldPrefix =- $"DiscountRulesHadSpentAmount{discount.Id}-{(!string.IsNullOrEmpty(discountRequirementId) ? discountRequirementId : "")}";+ DiscountRule discountRequirement = null;+ if (!string.IsNullOrEmpty(discountRequirementId))+ discountRequirement = discount.DiscountRules.FirstOrDefault(dr => dr.Id == discountRequirementId);- return View(model);+ if (discountRequirement != null)+ {+ //update existing rule+ discountRequirement.Metadata = spentAmount.ToString(CultureInfo.InvariantCulture);+ await _discountService.UpdateDiscount(discount);}-- [HttpPost]- [AutoValidateAntiforgeryToken]- public async Task<IActionResult> Configure(string discountId, string discountRequirementId, double spentAmount)+ else{- if (!await _permissionService.Authorize(StandardPermission.ManageDiscounts))- return Content("Access denied");-- var discount = await _discountService.GetDiscountById(discountId);- if (discount == null)- throw new ArgumentException("Discount could not be loaded");-- DiscountRule discountRequirement = null;- if (!string.IsNullOrEmpty(discountRequirementId))- discountRequirement = discount.DiscountRules.FirstOrDefault(dr => dr.Id == discountRequirementId);-- if (discountRequirement != null)- {- //update existing rule- discountRequirement.Metadata = spentAmount.ToString(CultureInfo.InvariantCulture);- await _discountService.UpdateDiscount(discount);- }- else- {- //save new rule- discountRequirement = new DiscountRule {- DiscountRequirementRuleSystemName = "DiscountRules.Standard.HadSpentAmount",- Metadata = spentAmount.ToString(CultureInfo.InvariantCulture)- };- discount.DiscountRules.Add(discountRequirement);- await _discountService.UpdateDiscount(discount);- }- return new JsonResult(new { Result = true, NewRequirementId = discountRequirement.Id });+ //save new rule+ discountRequirement = new DiscountRule {+ DiscountRequirementRuleSystemName = "DiscountRules.Standard.HadSpentAmount",+ Metadata = spentAmount.ToString(CultureInfo.InvariantCulture)+ };+ discount.DiscountRules.Add(discountRequirement);+ await _discountService.UpdateDiscount(discount);}+ return new JsonResult(new { Result = true, NewRequirementId = discountRequirement.Id });}}\ No newline at end of filediff --git a/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/HasAllProductsController.cs b/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/HasAllProductsController.csindex 8ad54cf04..21b2ee3a7 100644--- a/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/HasAllProductsController.cs+++ b/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/HasAllProductsController.cs@@ -15,215 +15,216 @@ using Grand.Web.Common.Extensions;using Microsoft.AspNetCore.Mvc;using Microsoft.AspNetCore.Mvc.Rendering;-namespace DiscountRules.Standard.Areas.Admin.Controllers+namespace DiscountRules.Standard.Areas.Admin.Controllers;++public class HasAllProductsController : BaseAdminPluginController{- public class HasAllProductsController : BaseAdminPluginController+ private readonly IDiscountService _discountService;+ private readonly IPermissionService _permissionService;+ private readonly IProductService _productService;+ private readonly IStoreService _storeService;+ private readonly ITranslationService _translationService;+ private readonly IVendorService _vendorService;+ private readonly IWorkContext _workContext;++ public HasAllProductsController(IDiscountService discountService,+ IPermissionService permissionService,+ IWorkContext workContext,+ ITranslationService translationService,+ IStoreService storeService,+ IVendorService vendorService,+ IProductService productService){- private readonly IDiscountService _discountService;- private readonly IPermissionService _permissionService;- private readonly IWorkContext _workContext;- private readonly ITranslationService _translationService;- private readonly IStoreService _storeService;- private readonly IVendorService _vendorService;- private readonly IProductService _productService;-- public HasAllProductsController(IDiscountService discountService,- IPermissionService permissionService,- IWorkContext workContext,- ITranslationService translationService,- IStoreService storeService,- IVendorService vendorService,- IProductService productService)+ _discountService = discountService;+ _permissionService = permissionService;+ _workContext = workContext;+ _translationService = translationService;+ _storeService = storeService;+ _vendorService = vendorService;+ _productService = productService;+ }++ public async Task<IActionResult> Configure(string discountId, string discountRequirementId)+ {+ if (!await _permissionService.Authorize(StandardPermission.ManageDiscounts))+ return Content("Access denied");++ var discount = await _discountService.GetDiscountById(discountId);+ if (discount == null)+ throw new ArgumentException("Discount could not be loaded");++ var restrictedProductIds = string.Empty;++ if (!string.IsNullOrEmpty(discountRequirementId)){- _discountService = discountService;- _permissionService = permissionService;- _workContext = workContext;- _translationService = translationService;- _storeService = storeService;- _vendorService = vendorService;- _productService = productService;+ var discountRequirement = discount.DiscountRules.FirstOrDefault(dr => dr.Id == discountRequirementId);+ if (discountRequirement == null)+ return Content("Failed to load requirement.");++ restrictedProductIds = discountRequirement.Metadata;}- public async Task<IActionResult> Configure(string discountId, string discountRequirementId)- {- if (!await _permissionService.Authorize(StandardPermission.ManageDiscounts))- return Content("Access denied");+ var model = new RequirementAllProductsModel {+ RequirementId = !string.IsNullOrEmpty(discountRequirementId) ? discountRequirementId : "",+ DiscountId = discountId,+ Products = restrictedProductIds+ };- var discount = await _discountService.GetDiscountById(discountId);- if (discount == null)- throw new ArgumentException("Discount could not be loaded");+ //add a prefix+ ViewData.TemplateInfo.HtmlFieldPrefix =+ $"DiscountRulesHasAllProducts{discount.Id}-{(!string.IsNullOrEmpty(discountRequirementId) ? discountRequirementId : "")}";- var restrictedProductIds = string.Empty;+ return View(model);+ }- if (!string.IsNullOrEmpty(discountRequirementId))- {- var discountRequirement = discount.DiscountRules.FirstOrDefault(dr => dr.Id == discountRequirementId);- if (discountRequirement == null)- return Content("Failed to load requirement.");+ [HttpPost]+ [AutoValidateAntiforgeryToken]+ public async Task<IActionResult> Configure(string discountId, string discountRequirementId, string productIds)+ {+ if (!await _permissionService.Authorize(StandardPermission.ManageDiscounts))+ return Content("Access denied");- restrictedProductIds = discountRequirement.Metadata;- }+ var discount = await _discountService.GetDiscountById(discountId);+ if (discount == null)+ throw new ArgumentException("Discount could not be loaded");- var model = new RequirementAllProductsModel {- RequirementId = !string.IsNullOrEmpty(discountRequirementId) ? discountRequirementId : "",- DiscountId = discountId,- Products = restrictedProductIds- };+ DiscountRule discountRequirement = null;- //add a prefix- ViewData.TemplateInfo.HtmlFieldPrefix =- $"DiscountRulesHasAllProducts{discount.Id}-{(!string.IsNullOrEmpty(discountRequirementId) ? discountRequirementId : "")}";+ if (!string.IsNullOrEmpty(discountRequirementId))+ discountRequirement = discount.DiscountRules.FirstOrDefault(dr => dr.Id == discountRequirementId);- return View(model);+ if (discountRequirement != null)+ {+ //update existing rule+ discountRequirement.Metadata = productIds;+ await _discountService.UpdateDiscount(discount);}-- [HttpPost]- [AutoValidateAntiforgeryToken]- public async Task<IActionResult> Configure(string discountId, string discountRequirementId, string productIds)+ else{- if (!await _permissionService.Authorize(StandardPermission.ManageDiscounts))- return Content("Access denied");-- var discount = await _discountService.GetDiscountById(discountId);- if (discount == null)- throw new ArgumentException("Discount could not be loaded");-- DiscountRule discountRequirement = null;-- if (!string.IsNullOrEmpty(discountRequirementId))- discountRequirement = discount.DiscountRules.FirstOrDefault(dr => dr.Id == discountRequirementId);-- if (discountRequirement != null)- {- //update existing rule- discountRequirement.Metadata = productIds;- await _discountService.UpdateDiscount(discount);- }- else- {- //save new rule- discountRequirement = new DiscountRule {- DiscountRequirementRuleSystemName = "DiscountRules.HasAllProducts",- Metadata = productIds- };- discount.DiscountRules.Add(discountRequirement);- await _discountService.UpdateDiscount(discount);- }- return new JsonResult(new { Result = true, NewRequirementId = discountRequirement.Id });+ //save new rule+ discountRequirement = new DiscountRule {+ DiscountRequirementRuleSystemName = "DiscountRules.HasAllProducts",+ Metadata = productIds+ };+ discount.DiscountRules.Add(discountRequirement);+ await _discountService.UpdateDiscount(discount);}- public async Task<IActionResult> ProductAddPopup(string btnId, string productIdsInput)- {- if (!await _permissionService.Authorize(StandardPermission.ManageProducts))- return Content("Access denied");+ return new JsonResult(new { Result = true, NewRequirementId = discountRequirement.Id });+ }- var model = new RequirementAllProductsModel.AddProductModel {- //a vendor should have access only to his products- IsLoggedInAsVendor = _workContext.CurrentVendor != null- };+ public async Task<IActionResult> ProductAddPopup(string btnId, string productIdsInput)+ {+ if (!await _permissionService.Authorize(StandardPermission.ManageProducts))+ return Content("Access denied");- //stores- model.AvailableStores.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });- foreach (var s in await _storeService.GetAllStores())- model.AvailableStores.Add(new SelectListItem { Text = s.Shortcut, Value = s.Id });+ var model = new RequirementAllProductsModel.AddProductModel {+ //a vendor should have access only to his products+ IsLoggedInAsVendor = _workContext.CurrentVendor != null+ };- //vendors- model.AvailableVendors.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });- foreach (var v in await _vendorService.GetAllVendors(showHidden: true))- model.AvailableVendors.Add(new SelectListItem { Text = v.Name, Value = v.Id });+ //stores+ model.AvailableStores.Add(new SelectListItem+ { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });+ foreach (var s in await _storeService.GetAllStores())+ model.AvailableStores.Add(new SelectListItem { Text = s.Shortcut, Value = s.Id });- //product types- model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(HttpContext, false).ToList();- model.AvailableProductTypes.Insert(0, new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });+ //vendors+ model.AvailableVendors.Add(new SelectListItem+ { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });+ foreach (var v in await _vendorService.GetAllVendors(showHidden: true))+ model.AvailableVendors.Add(new SelectListItem { Text = v.Name, Value = v.Id });+ //product types+ model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(HttpContext, false).ToList();+ model.AvailableProductTypes.Insert(0,+ new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });- ViewBag.productIdsInput = productIdsInput;- ViewBag.btnId = btnId;- return View(model);- }+ ViewBag.productIdsInput = productIdsInput;+ ViewBag.btnId = btnId;- [HttpPost]- [AutoValidateAntiforgeryToken]- public async Task<IActionResult> ProductAddPopupList(DataSourceRequest command, RequirementAllProductsModel.AddProductModel model)- {- if (!await _permissionService.Authorize(StandardPermission.ManageProducts))- return Content("Access denied");+ return View(model);+ }- //a vendor should have access only to his products- if (_workContext.CurrentVendor != null)- {- model.SearchVendorId = _workContext.CurrentVendor.Id;- }- var searchCategoryIds = new List<string>();- if (!string.IsNullOrEmpty(model.SearchCategoryId))- searchCategoryIds.Add(model.SearchCategoryId);-- var products = (await _productService.SearchProducts(- categoryIds: searchCategoryIds,- collectionId: model.SearchCollectionId,- storeId: model.SearchStoreId,- vendorId: model.SearchVendorId,- productType: model.SearchProductTypeId > 0 ? (ProductType?)model.SearchProductTypeId : null,- keywords: model.SearchProductName,- pageIndex: command.Page - 1,- pageSize: command.PageSize,- showHidden: true- )).products;- var gridModel = new DataSourceResult {- Data = products.Select(x => new RequirementAllProductsModel.ProductModel {- Id = x.Id,- Name = x.Name,- Published = x.Published- }),- Total = products.TotalCount- };+ [HttpPost]+ [AutoValidateAntiforgeryToken]+ public async Task<IActionResult> ProductAddPopupList(DataSourceRequest command,+ RequirementAllProductsModel.AddProductModel model)+ {+ if (!await _permissionService.Authorize(StandardPermission.ManageProducts))+ return Content("Access denied");++ //a vendor should have access only to his products+ if (_workContext.CurrentVendor != null) model.SearchVendorId = _workContext.CurrentVendor.Id;+ var searchCategoryIds = new List<string>();+ if (!string.IsNullOrEmpty(model.SearchCategoryId))+ searchCategoryIds.Add(model.SearchCategoryId);++ var products = (await _productService.SearchProducts(+ categoryIds: searchCategoryIds,+ collectionId: model.SearchCollectionId,+ storeId: model.SearchStoreId,+ vendorId: model.SearchVendorId,+ productType: model.SearchProductTypeId > 0 ? (ProductType?)model.SearchProductTypeId : null,+ keywords: model.SearchProductName,+ pageIndex: command.Page - 1,+ pageSize: command.PageSize,+ showHidden: true+ )).products;+ var gridModel = new DataSourceResult {+ Data = products.Select(x => new RequirementAllProductsModel.ProductModel {+ Id = x.Id,+ Name = x.Name,+ Published = x.Published+ }),+ Total = products.TotalCount+ };++ return new JsonResult(gridModel);+ }- return new JsonResult(gridModel);- }+ [HttpPost]+ [AutoValidateAntiforgeryToken]+ public async Task<IActionResult> LoadProductFriendlyNames(string productIds)+ {+ var result = "";- [HttpPost]- [AutoValidateAntiforgeryToken]- public async Task<IActionResult> LoadProductFriendlyNames(string productIds)+ if (!await _permissionService.Authorize(StandardPermission.ManageProducts))+ return new JsonResult(new { Text = result });++ if (string.IsNullOrWhiteSpace(productIds)) return new JsonResult(new { Text = result });+ var ids = new List<string>();+ var rangeArray = productIds+ .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Select(x => x.Trim())+ .ToList();++ //we support three ways of specifying products:+ //1. The comma-separated list of product identifiers (e.g. 77, 123, 156).+ //2. The comma-separated list of product identifiers with quantities.+ // {Product ID}:{Quantity}. For example, 77:1, 123:2, 156:3+ //3. The comma-separated list of product identifiers with quantity range.+ // {Product ID}:{Min quantity}-{Max quantity}. For example, 77:1-3, 123:2-5, 156:3-8+ foreach (var str1 in rangeArray){- var result = "";-- if (!await _permissionService.Authorize(StandardPermission.ManageProducts))- return new JsonResult(new { Text = result });-- if (string.IsNullOrWhiteSpace(productIds)) return new JsonResult(new { Text = result });- var ids = new List<string>();- var rangeArray = productIds- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)- .Select(x => x.Trim())- .ToList();-- //we support three ways of specifying products:- //1. The comma-separated list of product identifiers (e.g. 77, 123, 156).- //2. The comma-separated list of product identifiers with quantities.- // {Product ID}:{Quantity}. For example, 77:1, 123:2, 156:3- //3. The comma-separated list of product identifiers with quantity range.- // {Product ID}:{Min quantity}-{Max quantity}. For example, 77:1-3, 123:2-5, 156:3-8- foreach (var str1 in rangeArray)- {- var str2 = str1;- //we do not display specified quantities and ranges- //parse only product names- if (str2.Contains(':'))- str2 = str2[..str2.IndexOf(":", StringComparison.Ordinal)];-- ids.Add(str2);- }-- var products = await _productService.GetProductsByIds(ids.ToArray(), true);- for (var i = 0; i <= products.Count - 1; i++)- {- result += products[i].Name;- if (i != products.Count - 1)- result += ", ";- }+ var str2 = str1;+ //we do not display specified quantities and ranges+ //parse only product names+ if (str2.Contains(':'))+ str2 = str2[..str2.IndexOf(":", StringComparison.Ordinal)];- return new JsonResult(new { Text = result });+ ids.Add(str2);}++ var products = await _productService.GetProductsByIds(ids.ToArray(), true);+ for (var i = 0; i <= products.Count - 1; i++)+ {+ result += products[i].Name;+ if (i != products.Count - 1)+ result += ", ";+ }++ return new JsonResult(new { Text = result });}}\ No newline at end of filediff --git a/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/HasOneProductController.cs b/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/HasOneProductController.csindex 3e0b8bdbc..d28d7a19b 100644--- a/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/HasOneProductController.cs+++ b/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/HasOneProductController.cs@@ -15,215 +15,215 @@ using Grand.Web.Common.Extensions;using Microsoft.AspNetCore.Mvc;using Microsoft.AspNetCore.Mvc.Rendering;-namespace DiscountRules.Standard.Areas.Admin.Controllers+namespace DiscountRules.Standard.Areas.Admin.Controllers;++public class HasOneProductController : BaseAdminPluginController{- public class HasOneProductController : BaseAdminPluginController+ private readonly IDiscountService _discountService;+ private readonly IPermissionService _permissionService;+ private readonly IProductService _productService;+ private readonly IStoreService _storeService;+ private readonly ITranslationService _translationService;+ private readonly IVendorService _vendorService;+ private readonly IWorkContext _workContext;++ public HasOneProductController(IDiscountService discountService,+ IPermissionService permissionService,+ IWorkContext workContext,+ ITranslationService translationService,+ IStoreService storeService,+ IVendorService vendorService,+ IProductService productService){- private readonly IDiscountService _discountService;- private readonly IPermissionService _permissionService;- private readonly IWorkContext _workContext;- private readonly ITranslationService _translationService;- private readonly IStoreService _storeService;- private readonly IVendorService _vendorService;- private readonly IProductService _productService;-- public HasOneProductController(IDiscountService discountService,- IPermissionService permissionService,- IWorkContext workContext,- ITranslationService translationService,- IStoreService storeService,- IVendorService vendorService,- IProductService productService)+ _discountService = discountService;+ _permissionService = permissionService;+ _workContext = workContext;+ _translationService = translationService;+ _storeService = storeService;+ _vendorService = vendorService;+ _productService = productService;+ }++ public async Task<IActionResult> Configure(string discountId, string discountRequirementId)+ {+ if (!await _permissionService.Authorize(StandardPermission.ManageDiscounts))+ return Content("Access denied");++ var discount = await _discountService.GetDiscountById(discountId);+ if (discount == null)+ throw new ArgumentException("Discount could not be loaded");++ var restrictedProductIds = string.Empty;+ if (!string.IsNullOrEmpty(discountRequirementId)){- _discountService = discountService;- _permissionService = permissionService;- _workContext = workContext;- _translationService = translationService;- _storeService = storeService;- _vendorService = vendorService;- _productService = productService;+ var discountRequirement = discount.DiscountRules.FirstOrDefault(dr => dr.Id == discountRequirementId);+ if (discountRequirement == null)+ return Content("Failed to load requirement.");++ restrictedProductIds = discountRequirement.Metadata;}- public async Task<IActionResult> Configure(string discountId, string discountRequirementId)- {- if (!await _permissionService.Authorize(StandardPermission.ManageDiscounts))- return Content("Access denied");-- var discount = await _discountService.GetDiscountById(discountId);- if (discount == null)- throw new ArgumentException("Discount could not be loaded");-- var restrictedProductIds = string.Empty;- if (!string.IsNullOrEmpty(discountRequirementId))- {- var discountRequirement = discount.DiscountRules.FirstOrDefault(dr => dr.Id == discountRequirementId);- if (discountRequirement == null)- return Content("Failed to load requirement.");-- restrictedProductIds = discountRequirement.Metadata;- }-- var model = new RequirementOneProductModel {- RequirementId = !string.IsNullOrEmpty(discountRequirementId) ? discountRequirementId : "",- DiscountId = discountId,- Products = restrictedProductIds- };+ var model = new RequirementOneProductModel {+ RequirementId = !string.IsNullOrEmpty(discountRequirementId) ? discountRequirementId : "",+ DiscountId = discountId,+ Products = restrictedProductIds+ };- //add a prefix- ViewData.TemplateInfo.HtmlFieldPrefix =- $"DiscountRulesHasOneProduct{discount.Id}-{(!string.IsNullOrEmpty(discountRequirementId) ? discountRequirementId : "")}";+ //add a prefix+ ViewData.TemplateInfo.HtmlFieldPrefix =+ $"DiscountRulesHasOneProduct{discount.Id}-{(!string.IsNullOrEmpty(discountRequirementId) ? discountRequirementId : "")}";- return View(model);- }+ return View(model);+ }++ [HttpPost]+ [AutoValidateAntiforgeryToken]+ public async Task<IActionResult> Configure(string discountId, string discountRequirementId, string productIds)+ {+ if (!await _permissionService.Authorize(StandardPermission.ManageDiscounts))+ return Content("Access denied");++ var discount = await _discountService.GetDiscountById(discountId);+ if (discount == null)+ throw new ArgumentException("Discount could not be loaded");++ DiscountRule discountRequirement = null;+ if (!string.IsNullOrEmpty(discountRequirementId))+ discountRequirement = discount.DiscountRules.FirstOrDefault(dr => dr.Id == discountRequirementId);- [HttpPost]- [AutoValidateAntiforgeryToken]- public async Task<IActionResult> Configure(string discountId, string discountRequirementId, string productIds)+ if (discountRequirement != null){- if (!await _permissionService.Authorize(StandardPermission.ManageDiscounts))- return Content("Access denied");-- var discount = await _discountService.GetDiscountById(discountId);- if (discount == null)- throw new ArgumentException("Discount could not be loaded");-- DiscountRule discountRequirement = null;- if (!string.IsNullOrEmpty(discountRequirementId))- discountRequirement = discount.DiscountRules.FirstOrDefault(dr => dr.Id == discountRequirementId);-- if (discountRequirement != null)- {- //update existing rule- discountRequirement.Metadata = productIds;- await _discountService.UpdateDiscount(discount);- }- else- {- //save new rule- discountRequirement = new DiscountRule {- DiscountRequirementRuleSystemName = "DiscountRules.HasOneProduct",- Metadata = productIds- };- discount.DiscountRules.Add(discountRequirement);- await _discountService.UpdateDiscount(discount);- }-- return new JsonResult(new { Result = true, NewRequirementId = discountRequirement.Id });+ //update existing rule+ discountRequirement.Metadata = productIds;+ await _discountService.UpdateDiscount(discount);}-- public async Task<IActionResult> ProductAddPopup(string btnId, string productIdsInput)+ else{- if (!await _permissionService.Authorize(StandardPermission.ManageProducts))- return Content("Access denied");-- var model = new RequirementOneProductModel.AddProductModel {- //a vendor should have access only to his products- IsLoggedInAsVendor = _workContext.CurrentVendor != null+ //save new rule+ discountRequirement = new DiscountRule {+ DiscountRequirementRuleSystemName = "DiscountRules.HasOneProduct",+ Metadata = productIds};+ discount.DiscountRules.Add(discountRequirement);+ await _discountService.UpdateDiscount(discount);+ }- //stores- model.AvailableStores.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });- foreach (var s in await _storeService.GetAllStores())- model.AvailableStores.Add(new SelectListItem { Text = s.Shortcut, Value = s.Id });+ return new JsonResult(new { Result = true, NewRequirementId = discountRequirement.Id });+ }- //vendors- model.AvailableVendors.Add(new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });- foreach (var v in await _vendorService.GetAllVendors(showHidden: true))- model.AvailableVendors.Add(new SelectListItem { Text = v.Name, Value = v.Id });+ public async Task<IActionResult> ProductAddPopup(string btnId, string productIdsInput)+ {+ if (!await _permissionService.Authorize(StandardPermission.ManageProducts))+ return Content("Access denied");- //product types- model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(HttpContext, false).ToList();- model.AvailableProductTypes.Insert(0, new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });+ var model = new RequirementOneProductModel.AddProductModel {+ //a vendor should have access only to his products+ IsLoggedInAsVendor = _workContext.CurrentVendor != null+ };+ //stores+ model.AvailableStores.Add(new SelectListItem+ { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });+ foreach (var s in await _storeService.GetAllStores())+ model.AvailableStores.Add(new SelectListItem { Text = s.Shortcut, Value = s.Id });- ViewBag.productIdsInput = productIdsInput;- ViewBag.btnId = btnId;+ //vendors+ model.AvailableVendors.Add(new SelectListItem+ { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });+ foreach (var v in await _vendorService.GetAllVendors(showHidden: true))+ model.AvailableVendors.Add(new SelectListItem { Text = v.Name, Value = v.Id });- return View(model);- }+ //product types+ model.AvailableProductTypes = ProductType.SimpleProduct.ToSelectList(HttpContext, false).ToList();+ model.AvailableProductTypes.Insert(0,+ new SelectListItem { Text = _translationService.GetResource("Admin.Common.All"), Value = "" });- [HttpPost]- [AutoValidateAntiforgeryToken]- public async Task<IActionResult> ProductAddPopupList(DataSourceRequest command, RequirementOneProductModel.AddProductModel model)- {- if (!await _permissionService.Authorize(StandardPermission.ManageProducts))- return Content("Access denied");- //a vendor should have access only to his products- if (_workContext.CurrentVendor != null)- {- model.SearchVendorId = _workContext.CurrentVendor.Id;- }-- var searchCategoryIds = new List<string>();- if (!string.IsNullOrEmpty(model.SearchCategoryId))- searchCategoryIds.Add(model.SearchCategoryId);-- var products = (await _productService.SearchProducts(- categoryIds: searchCategoryIds,- collectionId: model.SearchCollectionId,- storeId: model.SearchStoreId,- vendorId: model.SearchVendorId,- productType: model.SearchProductTypeId > 0 ? (ProductType?)model.SearchProductTypeId : null,- keywords: model.SearchProductName,- pageIndex: command.Page - 1,- pageSize: command.PageSize,- showHidden: true- )).products;- var gridModel = new DataSourceResult {- Data = products.Select(x => new RequirementOneProductModel.ProductModel {- Id = x.Id,- Name = x.Name,- Published = x.Published- }),- Total = products.TotalCount- };+ ViewBag.productIdsInput = productIdsInput;+ ViewBag.btnId = btnId;- return new JsonResult(gridModel);- }+ return View(model);+ }- [HttpPost]- [AutoValidateAntiforgeryToken]- public async Task<IActionResult> LoadProductFriendlyNames(string productIds)- {- var result = "";-- if (!await _permissionService.Authorize(StandardPermission.ManageProducts))- return new JsonResult(new { Text = result });-- if (string.IsNullOrWhiteSpace(productIds)) return new JsonResult(new { Text = result });- var ids = new List<string>();- var rangeArray = productIds- .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)- .Select(x => x.Trim())- .ToList();-- //we support three ways of specifying products:- //1. The comma-separated list of product identifiers (e.g. 77, 123, 156).- //2. The comma-separated list of product identifiers with quantities.- // {Product ID}:{Quantity}. For example, 77:1, 123:2, 156:3- //3. The comma-separated list of product identifiers with quantity range.- // {Product ID}:{Min quantity}-{Max quantity}. For example, 77:1-3, 123:2-5, 156:3-8- foreach (var str1 in rangeArray)- {- var str2 = str1;- //we do not display specified quantities and ranges- //parse only product names (before : sign)- if (str2.Contains(':'))- str2 = str2[..str2.IndexOf(":", StringComparison.Ordinal)];-- ids.Add(str2);- }-- var products = await _productService.GetProductsByIds(ids.ToArray(), true);- for (var i = 0; i <= products.Count - 1; i++)- {- result += products[i].Name;- if (i != products.Count - 1)- result += ", ";- }+ [HttpPost]+ [AutoValidateAntiforgeryToken]+ public async Task<IActionResult> ProductAddPopupList(DataSourceRequest command,+ RequirementOneProductModel.AddProductModel model)+ {+ if (!await _permissionService.Authorize(StandardPermission.ManageProducts))+ return Content("Access denied");++ //a vendor should have access only to his products+ if (_workContext.CurrentVendor != null) model.SearchVendorId = _workContext.CurrentVendor.Id;++ var searchCategoryIds = new List<string>();+ if (!string.IsNullOrEmpty(model.SearchCategoryId))+ searchCategoryIds.Add(model.SearchCategoryId);++ var products = (await _productService.SearchProducts(+ categoryIds: searchCategoryIds,+ collectionId: model.SearchCollectionId,+ storeId: model.SearchStoreId,+ vendorId: model.SearchVendorId,+ productType: model.SearchProductTypeId > 0 ? (ProductType?)model.SearchProductTypeId : null,+ keywords: model.SearchProductName,+ pageIndex: command.Page - 1,+ pageSize: command.PageSize,+ showHidden: true+ )).products;+ var gridModel = new DataSourceResult {+ Data = products.Select(x => new RequirementOneProductModel.ProductModel {+ Id = x.Id,+ Name = x.Name,+ Published = x.Published+ }),+ Total = products.TotalCount+ };++ return new JsonResult(gridModel);+ }+ [HttpPost]+ [AutoValidateAntiforgeryToken]+ public async Task<IActionResult> LoadProductFriendlyNames(string productIds)+ {+ var result = "";++ if (!await _permissionService.Authorize(StandardPermission.ManageProducts))return new JsonResult(new { Text = result });++ if (string.IsNullOrWhiteSpace(productIds)) return new JsonResult(new { Text = result });+ var ids = new List<string>();+ var rangeArray = productIds+ .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Select(x => x.Trim())+ .ToList();++ //we support three ways of specifying products:+ //1. The comma-separated list of product identifiers (e.g. 77, 123, 156).+ //2. The comma-separated list of product identifiers with quantities.+ // {Product ID}:{Quantity}. For example, 77:1, 123:2, 156:3+ //3. The comma-separated list of product identifiers with quantity range.+ // {Product ID}:{Min quantity}-{Max quantity}. For example, 77:1-3, 123:2-5, 156:3-8+ foreach (var str1 in rangeArray)+ {+ var str2 = str1;+ //we do not display specified quantities and ranges+ //parse only product names (before : sign)+ if (str2.Contains(':'))+ str2 = str2[..str2.IndexOf(":", StringComparison.Ordinal)];++ ids.Add(str2);}++ var products = await _productService.GetProductsByIds(ids.ToArray(), true);+ for (var i = 0; i <= products.Count - 1; i++)+ {+ result += products[i].Name;+ if (i != products.Count - 1)+ result += ", ";+ }++ return new JsonResult(new { Text = result });}}\ No newline at end of filediff --git a/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/ShoppingCartAmountController.cs b/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/ShoppingCartAmountController.csindex cfce15806..c3fcc6be6 100644--- a/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/ShoppingCartAmountController.cs+++ b/src/Plugins/DiscountRules.Standard/Areas/Admin/Controllers/ShoppingCartAmountController.cs@@ -7,85 +7,84 @@ using Grand.Web.Common.Controllers;using Microsoft.AspNetCore.Mvc;using System.Globalization;-namespace DiscountRules.Standard.Areas.Admin.Controllers+namespace DiscountRules.Standard.Areas.Admin.Controllers;++public class ShoppingCartAmountController : BaseAdminPluginController{- public class ShoppingCartAmountController : BaseAdminPluginController+ private readonly IDiscountService _discountService;+ private readonly IPermissionService _permissionService;++ public ShoppingCartAmountController(IDiscountService discountService,+ IPermissionService permissionService)+ {+ _discountService = discountService;+ _permissionService = permissionService;+ }++ public async Task<IActionResult> Configure(string discountId, string discountRequirementId){- private readonly IDiscountService _discountService;- private readonly IPermissionService _permissionService;+ if (!await _permissionService.Authorize(StandardPermission.ManageDiscounts))+ return Content("Access denied");- public ShoppingCartAmountController(IDiscountService discountService,- IPermissionService permissionService)+ var discount = await _discountService.GetDiscountById(discountId);+ if (discount == null)+ throw new ArgumentException("Discount could not be loaded");++ double spentAmountRequirement = 0;+ if (!string.IsNullOrEmpty(discountRequirementId)){- _discountService = discountService;- _permissionService = permissionService;+ var discountRequirement = discount.DiscountRules.FirstOrDefault(dr => dr.Id == discountRequirementId);+ if (discountRequirement == null)+ return Content("Failed to load requirement.");++ spentAmountRequirement = Convert.ToDouble(discountRequirement.Metadata);}- public async Task<IActionResult> Configure(string discountId, string discountRequirementId)- {- if (!await _permissionService.Authorize(StandardPermission.ManageDiscounts))- return Content("Access denied");-- var discount = await _discountService.GetDiscountById(discountId);- if (discount == null)- throw new ArgumentException("Discount could not be loaded");-- double spentAmountRequirement = 0;- if (!string.IsNullOrEmpty(discountRequirementId))- {- var discountRequirement = discount.DiscountRules.FirstOrDefault(dr => dr.Id == discountRequirementId);- if (discountRequirement == null)- return Content("Failed to load requirement.");-- spentAmountRequirement = Convert.ToDouble(discountRequirement.Metadata);- }-- var model = new RequirementShoppingCartModel {- RequirementId = !string.IsNullOrEmpty(discountRequirementId) ? discountRequirementId : "",- DiscountId = discountId,- SpentAmount = spentAmountRequirement- };+ var model = new RequirementShoppingCartModel {+ RequirementId = !string.IsNullOrEmpty(discountRequirementId) ? discountRequirementId : "",+ DiscountId = discountId,+ SpentAmount = spentAmountRequirement+ };- //add a prefix- ViewData.TemplateInfo.HtmlFieldPrefix =- $"DiscountRulesShoppingCart{(!string.IsNullOrEmpty(discountRequirementId) ? discountRequirementId : "")}";+ //add a prefix+ ViewData.TemplateInfo.HtmlFieldPrefix =+ $"DiscountRulesShoppingCart{(!string.IsNullOrEmpty(discountRequirementId) ? discountRequirementId : "")}";- return View(model);- }+ return View(model);+ }+++ [HttpPost]+ public async Task<IActionResult> Configure(string discountId, string discountRequirementId, double spentAmount)+ {+ if (!await _permissionService.Authorize(StandardPermission.ManageDiscounts))+ return Content("Access denied");++ var discount = await _discountService.GetDiscountById(discountId);+ if (discount == null)+ throw new ArgumentException("Discount could not be loaded");+ DiscountRule discountRequirement = null;+ if (!string.IsNullOrEmpty(discountRequirementId))+ discountRequirement = discount.DiscountRules.FirstOrDefault(dr => dr.Id == discountRequirementId);- [HttpPost]- public async Task<IActionResult> Configure(string discountId, string discountRequirementId, double spentAmount)+ if (discountRequirement != null){- if (!await _permissionService.Authorize(StandardPermission.ManageDiscounts))- return Content("Access denied");-- var discount = await _discountService.GetDiscountById(discountId);- if (discount == null)- throw new ArgumentException("Discount could not be loaded");-- DiscountRule discountRequirement = null;- if (!string.IsNullOrEmpty(discountRequirementId))- discountRequirement = discount.DiscountRules.FirstOrDefault(dr => dr.Id == discountRequirementId);-- if (discountRequirement != null)- {- //update existing rule- discountRequirement.Metadata = spentAmount.ToString(CultureInfo.InvariantCulture);- await _discountService.UpdateDiscount(discount);- }- else- {- //save new rule- discountRequirement = new DiscountRule- {- DiscountRequirementRuleSystemName = "DiscountRequirement.ShoppingCart",- Metadata = spentAmount.ToString(CultureInfo.InvariantCulture)- };- discount.DiscountRules.Add(discountRequirement);- await _discountService.UpdateDiscount(discount);- }- return Json(new { Result = true, NewRequirementId = discountRequirement.Id });+ //update existing rule+ discountRequirement.Metadata = spentAmount.ToString(CultureInfo.InvariantCulture);+ await _discountService.UpdateDiscount(discount);}+ else+ {+ //save new rule+ discountRequirement = new DiscountRule {+ DiscountRequirementRuleSystemName = "DiscountRequirement.ShoppingCart",+ Metadata = spentAmount.ToString(CultureInfo.InvariantCulture)+ };+ discount.DiscountRules.Add(discountRequirement);+ await _discountService.UpdateDiscount(discount);+ }++ return Json(new { Result = true, NewRequirementId = discountRequirement.Id });}-}+}\ No newline at end of filediff --git a/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/CustomerGroups/Configure.cshtml b/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/CustomerGroups/Configure.cshtmlindex edf0c0d12..6625a1b6f 100644--- a/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/CustomerGroups/Configure.cshtml+++ b/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/CustomerGroups/Configure.cshtml@@ -1,6 +1,7 @@@{Layout = "";}+@using System.Text.Encodings.Web@model DiscountRules.Standard.Models.RequirementCustomerGroupsModel<script>@@ -27,13 +28,13 @@success: function (data) {$('#pnl-save-requirement-result@(Model.RequirementId)').fadeIn("slow").delay(1000).fadeOut("slow");//notify parent if it's a new requirement- @if (String.IsNullOrEmpty(Model.RequirementId))+ @if (string.IsNullOrEmpty(Model.RequirementId)){<text>$("#discountRequirementContainer").trigger('grandnewdiscountruleadded', [data.NewRequirementId]);</text>}},error:function (xhr, ajaxOptions, thrownError){- alert('@Html.Raw(System.Text.Encodings.Web.JavaScriptEncoder.Default.Encode(Loc["admin.marketing.Discounts.Requirements.FailedToSave"]))');+ alert('@Html.Raw(JavaScriptEncoder.Default.Encode(Loc["admin.marketing.Discounts.Requirements.FailedToSave"]))');}});});@@ -41,11 +42,11 @@</script><div class="form-horizontal"><div class="form-group">- <admin-label asp-for="CustomerGroupId" />+ <admin-label asp-for="CustomerGroupId"/><div class="col-md-9 col-sm-9">- <admin-select asp-for="CustomerGroupId" asp-items="Model.AvailableCustomerGroups" />+ <admin-select asp-for="CustomerGroupId" asp-items="Model.AvailableCustomerGroups"/><div class="group-btn btn-group-devided margin-top-10">- <input type="button" id="savecustomergroupsrequirement@(Model.RequirementId)" class="btn default" value="@Loc["Admin.Common.Save"]" />+ <input type="button" id="savecustomergroupsrequirement@(Model.RequirementId)" class="btn default" value="@Loc["Admin.Common.Save"]"/></div><div id="pnl-save-requirement-result@(Model.RequirementId)" style="display:none;">@Loc["admin.marketing.Discounts.Requirements.Saved"]</div></div>diff --git a/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/HadSpentAmount/Configure.cshtml b/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/HadSpentAmount/Configure.cshtmlindex e1c9a0658..1ac04e3dc 100644--- a/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/HadSpentAmount/Configure.cshtml+++ b/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/HadSpentAmount/Configure.cshtml@@ -1,6 +1,7 @@@{Layout = "";}+@using System.Text.Encodings.Web@model DiscountRules.Standard.Models.RequirementSpentAmountModel<script>@@ -25,27 +26,28 @@success: function (data) {$('#pnl-save-requirement-result@(Model.RequirementId)').fadeIn("slow").delay(1000).fadeOut("slow");//notify parent if it's a new requirement- @if (String.IsNullOrEmpty(Model.RequirementId))+ @if (string.IsNullOrEmpty(Model.RequirementId)){<text>$("#discountRequirementContainer").trigger('grandnewdiscountruleadded', [data.NewRequirementId]);</text>}},error:function (xhr, ajaxOptions, thrownError){- alert('@Html.Raw(System.Text.Encodings.Web.JavaScriptEncoder.Default.Encode(Loc["admin.marketing.Discounts.Requirements.FailedToSave"]))');+ alert('@Html.Raw(JavaScriptEncoder.Default.Encode(Loc["admin.marketing.Discounts.Requirements.FailedToSave"]))');}});});});</script>-+<div class="form-horizontal">- <div class="form-group">- <admin-label asp-for="SpentAmount" />- <div class="col-md-9 col-sm-9">- <div>- <admin-input asp-for="SpentAmount" />- <input type="button" id="savehadspentamountrequirement@(Model.RequirementId)" class="btn default" value="@Loc["Admin.Common.Save"]" /></div>- <div id="pnl-save-requirement-result@(Model.RequirementId)" style="display:none;">@Loc["admin.marketing.Discounts.Requirements.Saved"]</div>+ <div class="form-group">+ <admin-label asp-for="SpentAmount"/>+ <div class="col-md-9 col-sm-9">+ <div>+ <admin-input asp-for="SpentAmount"/>+ <input type="button" id="savehadspentamountrequirement@(Model.RequirementId)" class="btn default" value="@Loc["Admin.Common.Save"]"/></div>+ <div id="pnl-save-requirement-result@(Model.RequirementId)" style="display:none;">@Loc["admin.marketing.Discounts.Requirements.Saved"]</div></div>+ </div></div>\ No newline at end of filediff --git a/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/HasAllProducts/Configure.cshtml b/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/HasAllProducts/Configure.cshtmlindex 1a353e8e9..4dc95039a 100644--- a/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/HasAllProducts/Configure.cshtml+++ b/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/HasAllProducts/Configure.cshtml@@ -1,6 +1,7 @@@{Layout = "";}+@using System.Text.Encodings.Web@model DiscountRules.Standard.Models.RequirementAllProductsModel<script>@@ -25,13 +26,13 @@success: function (data) {$('#pnl-save-requirement-result@(Model.RequirementId)').fadeIn("slow").delay(1000).fadeOut("slow");//notify parent if it's a new requirement- @if (String.IsNullOrEmpty(Model.RequirementId))+ @if (string.IsNullOrEmpty(Model.RequirementId)){<text>$("#discountRequirementContainer").trigger('grandnewdiscountruleadded', [data.NewRequirementId]);</text>}},error:function (xhr, ajaxOptions, thrownError){- alert('@Html.Raw(System.Text.Encodings.Web.JavaScriptEncoder.Default.Encode(Loc["admin.marketing.Discounts.Requirements.FailedToSave"]))');+ alert('@Html.Raw(JavaScriptEncoder.Default.Encode(Loc["admin.marketing.Discounts.Requirements.FailedToSave"]))');}});});@@ -39,12 +40,12 @@</script><div class="form-body">- <admin-label asp-for="Products" />+ <admin-label asp-for="Products"/><div class="col-md-8 col-sm-8">- <admin-input asp-for="Products" />+ <admin-input asp-for="Products"/><span class="control-label" style="text-align:left" id="discountrequirement-product-names@(Model.RequirementId)"></span><div class="group-btn btn-group-devided margin-top-10">- <input type="button" id="saveHasAllProductsrequirement@(Model.RequirementId)" class="btn default" value="@Loc["Admin.Common.Save"]" />+ <input type="button" id="saveHasAllProductsrequirement@(Model.RequirementId)" class="btn default" value="@Loc["Admin.Common.Save"]"/><a id="btnAddNewDiscountRequirementProduct@(Model.RequirementId)" href="@(Url.RouteUrl("Plugin.DiscountRules.HasAllProducts.ProductAddPopup", new { btnId = "btnRefreshDiscountRequirementProducts" + Model.RequirementId, productIdsInput = Html.IdFor(model => model.Products) }))" class="btn default">@Loc["Plugins.DiscountRules.HasAllProducts.Fields.Products.AddNew"]</a>@@ -53,7 +54,7 @@<span id="discountrequirement-products-check-progress@(Model.RequirementId)" style="display: none;" class="please-wait">@Loc["Common.Wait..."]</span>- <input type="submit" id="btnRefreshDiscountRequirementProducts@(Model.RequirementId)" style="display: none" />+ <input type="submit" id="btnRefreshDiscountRequirementProducts@(Model.RequirementId)" style="display: none"/><script>$(document).ready(function () {$('#btnAddNewDiscountRequirementProduct@(Model.RequirementId)').magnificPopup({@@ -122,4 +123,4 @@}</script></div>-</div>+</div>\ No newline at end of filediff --git a/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/HasAllProducts/ProductAddPopup.cshtml b/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/HasAllProducts/ProductAddPopup.cshtmlindex a4d865596..f8626c1cb 100644--- a/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/HasAllProducts/ProductAddPopup.cshtml+++ b/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/HasAllProducts/ProductAddPopup.cshtml@@ -1,8 +1,8 @@@{Layout = "";}+@using Grand.Domain.Common@model DiscountRules.Standard.Models.RequirementAllProductsModel.AddProductModel-@using Grand.Domain.Common;@inject AdminAreaSettings adminAreaSettings@{//page title@@ -23,46 +23,46 @@<div class="form-horizontal"><div class="form-body"><div class="form-group">- <admin-label asp-for="SearchProductName" class="col-sm-3" />+ <admin-label asp-for="SearchProductName" class="col-sm-3"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="SearchProductName" />+ <admin-input asp-for="SearchProductName"/></div></div><div class="form-group">- <admin-label asp-for="SearchCategoryId" class="col-sm-3" />+ <admin-label asp-for="SearchCategoryId" class="col-sm-3"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="SearchCategoryId" />+ <admin-input asp-for="SearchCategoryId"/></div></div><div class="form-group">- <admin-label asp-for="SearchCollectionId" class="col-sm-3" />+ <admin-label asp-for="SearchCollectionId" class="col-sm-3"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="SearchCollectionId" />+ <admin-input asp-for="SearchCollectionId"/></div></div><div class="form-group">- <admin-label asp-for="SearchStoreId" class="col-sm-3" />+ <admin-label asp-for="SearchStoreId" class="col-sm-3"/><div class="col-md-9 col-sm-9">- <admin-select asp-for="SearchStoreId" asp-items="Model.AvailableStores" />+ <admin-select asp-for="SearchStoreId" asp-items="Model.AvailableStores"/></div></div><div class="form-group">- <admin-label asp-for="SearchVendorId" class="col-sm-3" />+ <admin-label asp-for="SearchVendorId" class="col-sm-3"/><div class="col-md-9 col-sm-9">- <admin-select asp-for="SearchVendorId" asp-items="Model.AvailableVendors" />+ <admin-select asp-for="SearchVendorId" asp-items="Model.AvailableVendors"/></div></div><div class="form-group">- <admin-label asp-for="SearchProductTypeId" class="col-sm-3" />+ <admin-label asp-for="SearchProductTypeId" class="col-sm-3"/><div class="col-md-9 col-sm-9">- <admin-select asp-for="SearchProductTypeId" asp-items="Model.AvailableProductTypes" />+ <admin-select asp-for="SearchProductTypeId" asp-items="Model.AvailableProductTypes"/></div></div><div class="form-actions"><div class="row"><div class="col-md-offset-1 col-md-11 col-sm-11 btn-group btn-group-devided">- <input type="button" id="search-products" class="btn default" value="@Loc["Admin.Common.Search"]" />- <input type="submit" name="save" class="btn green" value="@Loc["Admin.Common.Save"]" />+ <input type="button" id="search-products" class="btn default" value="@Loc["Admin.Common.Search"]"/>+ <input type="submit" name="save" class="btn green" value="@Loc["Admin.Common.Save"]"/></div></div></div>diff --git a/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/HasOneProduct/Configure.cshtml b/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/HasOneProduct/Configure.cshtmlindex 18048f56a..55b30a880 100644--- a/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/HasOneProduct/Configure.cshtml+++ b/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/HasOneProduct/Configure.cshtml@@ -1,6 +1,7 @@@{Layout = "";}+@using System.Text.Encodings.Web@model DiscountRules.Standard.Models.RequirementOneProductModel<script>@@ -25,13 +26,13 @@success: function (data) {$('#pnl-save-requirement-result@(Model.RequirementId)').fadeIn("slow").delay(1000).fadeOut("slow");//notify parent if it's a new requirement- @if (String.IsNullOrEmpty(Model.RequirementId))+ @if (string.IsNullOrEmpty(Model.RequirementId)){<text>$("#discountRequirementContainer").trigger('grandnewdiscountruleadded', [data.NewRequirementId]);</text>}},error:function (xhr, ajaxOptions, thrownError){- alert('@Html.Raw(System.Text.Encodings.Web.JavaScriptEncoder.Default.Encode(Loc["admin.marketing.Discounts.Requirements.FailedToSave"]))');+ alert('@Html.Raw(JavaScriptEncoder.Default.Encode(Loc["admin.marketing.Discounts.Requirements.FailedToSave"]))');}});});@@ -39,12 +40,12 @@</script><div class="form-body">- <admin-label asp-for="Products" />+ <admin-label asp-for="Products"/><div class="col-md-8 col-sm-8">- <admin-input asp-for="Products" />+ <admin-input asp-for="Products"/><label class="control-label" style="text-align:left" id="discountrequirement-product-names@(Model.RequirementId)"></label><div class="group-btn btn-group-devided margin-top-10">- <input type="button" id="saveHasOneProductrequirement@(Model.RequirementId)" class="btn default" value="@Loc["Admin.Common.Save"]" />+ <input type="button" id="saveHasOneProductrequirement@(Model.RequirementId)" class="btn default" value="@Loc["Admin.Common.Save"]"/><a id="btnAddNewDiscountRequirementProduct@(Model.RequirementId)" href="@(Url.RouteUrl("Plugin.DiscountRules.HasOneProduct.ProductAddPopup", new { btnId = "btnRefreshDiscountRequirementProducts" + Model.RequirementId, productIdsInput = Html.IdFor(model => model.Products) }))" class="btn default">@Loc["Plugins.DiscountRules.HasOneProduct.Fields.Products.AddNew"]</a>@@ -53,7 +54,7 @@<div id="pnl-save-requirement-result@(Model.RequirementId)" style="display:none;">@Loc["admin.marketing.Discounts.Requirements.Saved"]</div><span id="discountrequirement-products-check-progress@(Model.RequirementId)" style="display: none;" class="please-wait">@Loc["Common.Wait..."]</span>- <input type="submit" id="btnRefreshDiscountRequirementProducts@(Model.RequirementId)" style="display: none" />+ <input type="submit" id="btnRefreshDiscountRequirementProducts@(Model.RequirementId)" style="display: none"/></div><script>@@ -121,4 +122,4 @@}}</script>-</div>+</div>\ No newline at end of filediff --git a/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/HasOneProduct/ProductAddPopup.cshtml b/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/HasOneProduct/ProductAddPopup.cshtmlindex d768aeb97..fc917a7ee 100644--- a/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/HasOneProduct/ProductAddPopup.cshtml+++ b/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/HasOneProduct/ProductAddPopup.cshtml@@ -1,15 +1,15 @@@{Layout = "";}+@using Grand.Domain.Common@model DiscountRules.Standard.Models.RequirementOneProductModel.AddProductModel-@using Grand.Domain.Common;@inject AdminAreaSettings adminAreaSettings@{//page titleViewBag.Title = Loc["Plugins.DiscountRules.HasOneProduct.Fields.Products.Choose"];}<form id="ProductAddPopup" asp-controller="HasOneProduct" asp-action="ProductAddPopup" method="post">-+<div class="row"><div class="col-md-12"><div class="x_panel light form-fit">@@ -23,46 +23,46 @@<div class="form-horizontal"><div class="form-body"><div class="form-group">- <admin-label asp-for="SearchProductName" class="col-sm-3" />+ <admin-label asp-for="SearchProductName" class="col-sm-3"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="SearchProductName" />+ <admin-input asp-for="SearchProductName"/></div></div><div class="form-group">- <admin-label asp-for="SearchCategoryId" class="col-sm-3" />+ <admin-label asp-for="SearchCategoryId" class="col-sm-3"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="SearchCategoryId" />+ <admin-input asp-for="SearchCategoryId"/></div></div><div class="form-group">- <admin-label asp-for="SearchCollectionId" class="col-sm-3" />+ <admin-label asp-for="SearchCollectionId" class="col-sm-3"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="SearchCollectionId" />+ <admin-input asp-for="SearchCollectionId"/></div></div><div class="form-group">- <admin-label asp-for="SearchStoreId" class="col-sm-3" />+ <admin-label asp-for="SearchStoreId" class="col-sm-3"/><div class="col-md-9 col-sm-9">- <admin-select asp-for="SearchStoreId" asp-items="Model.AvailableStores" />+ <admin-select asp-for="SearchStoreId" asp-items="Model.AvailableStores"/></div></div><div class="form-group">- <admin-label asp-for="SearchVendorId" class="col-sm-3" />+ <admin-label asp-for="SearchVendorId" class="col-sm-3"/><div class="col-md-9 col-sm-9">- <admin-select asp-for="SearchVendorId" asp-items="Model.AvailableVendors" />+ <admin-select asp-for="SearchVendorId" asp-items="Model.AvailableVendors"/></div></div><div class="form-group">- <admin-label asp-for="SearchProductTypeId" class="col-sm-3" />+ <admin-label asp-for="SearchProductTypeId" class="col-sm-3"/><div class="col-md-9 col-sm-9">- <admin-select asp-for="SearchProductTypeId" asp-items="Model.AvailableProductTypes" />+ <admin-select asp-for="SearchProductTypeId" asp-items="Model.AvailableProductTypes"/></div></div><div class="form-actions"><div class="row"><div class="col-md-offset-1 col-md-11 col-sm-11 btn-group btn-group-devided">- <input type="button" id="search-products" class="btn default" value="@Loc["Admin.Common.Search"]" />- <input type="submit" name="save" class="btn green" value="@Loc["Admin.Common.Save"]" />+ <input type="button" id="search-products" class="btn default" value="@Loc["Admin.Common.Search"]"/>+ <input type="submit" name="save" class="btn green" value="@Loc["Admin.Common.Save"]"/></div></div></div>diff --git a/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/ShoppingCartAmount/Configure.cshtml b/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/ShoppingCartAmount/Configure.cshtmlindex d66dbe636..3b7e2f03e 100644--- a/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/ShoppingCartAmount/Configure.cshtml+++ b/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/ShoppingCartAmount/Configure.cshtml@@ -1,6 +1,7 @@@{Layout = "";}+@using System.Text.Encodings.Web@model DiscountRules.Standard.Models.RequirementShoppingCartModel<script>$(document).ready(function () {@@ -16,13 +17,13 @@success: function (data) {$('#pnl-save-requirement-result@(Model.RequirementId)').fadeIn("slow").delay(1000).fadeOut("slow");//notify parent if it's a new requirement- @if (String.IsNullOrEmpty(Model.RequirementId))+ @if (string.IsNullOrEmpty(Model.RequirementId)){- <text>$("#discountRequirementContainer").trigger('grandnewdiscountruleadded', [data.NewRequirementId]);</text>+ <text>$("#discountRequirementContainer").trigger('grandnewdiscountruleadded', [data.NewRequirementId]);</text>}},error:function (xhr, ajaxOptions, thrownError){- alert('@Html.Raw(System.Text.Encodings.Web.JavaScriptEncoder.Default.Encode(Loc["admin.marketing.Discounts.Requirements.FailedToSave"]))');+ alert('@Html.Raw(JavaScriptEncoder.Default.Encode(Loc["admin.marketing.Discounts.Requirements.FailedToSave"]))');}});});@@ -31,11 +32,12 @@<div class="form-horizontal"><div class="form-group">- <admin-label asp-for="SpentAmount" />+ <admin-label asp-for="SpentAmount"/><div class="col-md-9 col-sm-9"><div>- @Html.EditorFor(model => model.SpentAmount) <input type="button" id="saveShoppingCartrequirement@(Model.RequirementId)" class="k-button"- value="@Loc["Admin.Common.Save"]" />+ @Html.EditorFor(model => model.SpentAmount)+ <input type="button" id="saveShoppingCartrequirement@(Model.RequirementId)" class="k-button"+ value="@Loc["Admin.Common.Save"]"/></div><div id="pnl-save-requirement-result@(Model.RequirementId)" style="display:none;">@Loc["admin.marketing.Discounts.Requirements.Saved"]</div></div>diff --git a/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/_ViewImports.cshtml b/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/_ViewImports.cshtmlindex f235fe878..44d7f0eae 100644--- a/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/_ViewImports.cshtml+++ b/src/Plugins/DiscountRules.Standard/Areas/Admin/Views/_ViewImports.cshtml@@ -5,6 +5,7 @@@using Microsoft.AspNetCore.Mvc.ViewFeatures@using Grand.Infrastructure.Extensions@using Grand.Web.Common+@using Grand.Web.Common.Localization@using Grand.Web.Common.Page-@inject Grand.Web.Common.Localization.LocService Loc+@inject LocService Loc\ No newline at end of filediff --git a/src/Plugins/DiscountRules.Standard/DiscountPlugin.cs b/src/Plugins/DiscountRules.Standard/DiscountPlugin.csindex 0a64108f2..7842a1ca0 100644--- a/src/Plugins/DiscountRules.Standard/DiscountPlugin.cs+++ b/src/Plugins/DiscountRules.Standard/DiscountPlugin.cs@@ -2,75 +2,104 @@ using Grand.Business.Core.Extensions;using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Infrastructure.Plugins;-namespace DiscountRules.Standard-{- public class DiscountPlugin : BasePlugin, IPlugin- {- private readonly ITranslationService _translationService;- private readonly ILanguageService _languageService;+namespace DiscountRules.Standard;+public class DiscountPlugin : BasePlugin, IPlugin+{+ private readonly ILanguageService _languageService;+ private readonly ITranslationService _translationService;- public DiscountPlugin(- ITranslationService translationService,- ILanguageService languageService)- {- _translationService = translationService;- _languageService = languageService;- }+ public DiscountPlugin(+ ITranslationService translationService,+ ILanguageService languageService)+ {+ _translationService = translationService;+ _languageService = languageService;+ }- public override async Task Install()- {- //CustomerGroup- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.DiscountRules.CustomerGroups.Fields.CustomerGroup", "Required customer group");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.DiscountRules.CustomerGroups.Fields.CustomerGroup.Hint", "Discount will be applied if customer is in the selected customer group.");+ public override async Task Install()+ {+ //CustomerGroup+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.DiscountRules.CustomerGroups.Fields.CustomerGroup", "Required customer group");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.DiscountRules.CustomerGroups.Fields.CustomerGroup.Hint",+ "Discount will be applied if customer is in the selected customer group.");- //HadSpentAmount- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.DiscountRules.Standard.HadSpentAmount.Fields.Amount", "Required spent amount");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.DiscountRules.Standard.HadSpentAmount.Fields.Amount.Hint", "Discount will be applied if customer has spent/purchased x.xx amount.");+ //HadSpentAmount+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.DiscountRules.Standard.HadSpentAmount.Fields.Amount", "Required spent amount");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.DiscountRules.Standard.HadSpentAmount.Fields.Amount.Hint",+ "Discount will be applied if customer has spent/purchased x.xx amount.");- //HasAllProducts- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.DiscountRules.HasAllProducts.Fields.Products", "Restricted products");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.DiscountRules.HasAllProducts.Fields.Products.Hint", "The comma-separated list of product identifiers (e.g. 77, 123, 156). You can find a product ID on its details page. You can also specify the comma-separated list of product identifiers with quantities ({Product ID}:{Quantity}. for example, 77:1, 123:2, 156:3). And you can also specify the comma-separated list of product identifiers with quantity range ({Product ID}:{Min quantity}-{Max quantity}. for example, 77:1-3, 123:2-5, 156:3-8).");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.DiscountRules.HasAllProducts.Fields.Products.AddNew", "Add product");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.DiscountRules.HasAllProducts.Fields.Products.Choose", "Choose");+ //HasAllProducts+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.DiscountRules.HasAllProducts.Fields.Products", "Restricted products");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.DiscountRules.HasAllProducts.Fields.Products.Hint",+ "The comma-separated list of product identifiers (e.g. 77, 123, 156). You can find a product ID on its details page. You can also specify the comma-separated list of product identifiers with quantities ({Product ID}:{Quantity}. for example, 77:1, 123:2, 156:3). And you can also specify the comma-separated list of product identifiers with quantity range ({Product ID}:{Min quantity}-{Max quantity}. for example, 77:1-3, 123:2-5, 156:3-8).");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.DiscountRules.HasAllProducts.Fields.Products.AddNew", "Add product");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.DiscountRules.HasAllProducts.Fields.Products.Choose", "Choose");- //HasOneProduct- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.DiscountRules.HasOneProduct.Fields.Products", "Restricted products");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.DiscountRules.HasOneProduct.Fields.Products.Hint", "The comma-separated list of product identifiers (e.g. 77, 123, 156). You can find a product ID on its details page. You can also specify the comma-separated list of product identifiers with quantities ({Product ID}:{Quantity}. for example, 77:1, 123:2, 156:3). And you can also specify the comma-separated list of product identifiers with quantity range ({Product ID}:{Min quantity}-{Max quantity}. for example, 77:1-3, 123:2-5, 156:3-8).");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.DiscountRules.HasOneProduct.Fields.Products.AddNew", "Add product");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.DiscountRules.HasOneProduct.Fields.Products.Choose", "Choose");+ //HasOneProduct+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.DiscountRules.HasOneProduct.Fields.Products", "Restricted products");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.DiscountRules.HasOneProduct.Fields.Products.Hint",+ "The comma-separated list of product identifiers (e.g. 77, 123, 156). You can find a product ID on its details page. You can also specify the comma-separated list of product identifiers with quantities ({Product ID}:{Quantity}. for example, 77:1, 123:2, 156:3). And you can also specify the comma-separated list of product identifiers with quantity range ({Product ID}:{Min quantity}-{Max quantity}. for example, 77:1-3, 123:2-5, 156:3-8).");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.DiscountRules.HasOneProduct.Fields.Products.AddNew", "Add product");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.DiscountRules.HasOneProduct.Fields.Products.Choose", "Choose");- //Shipping cart- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.DiscountRules.ShoppingCart.Fields.Amount", "Required spent amount");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.DiscountRules.ShoppingCart.Fields.Amount.Hint", "Discount will be applied if the subtotal in shopping cart is x.xx.");+ //Shipping cart+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.DiscountRules.ShoppingCart.Fields.Amount", "Required spent amount");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.DiscountRules.ShoppingCart.Fields.Amount.Hint",+ "Discount will be applied if the subtotal in shopping cart is x.xx.");- await base.Install();- }+ await base.Install();+ }- public override async Task Uninstall()- {- //CustomerGroup- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.DiscountRules.CustomerGroups.Fields.CustomerGroup");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.DiscountRules.CustomerGroups.Fields.CustomerGroup.Hint");+ public override async Task Uninstall()+ {+ //CustomerGroup+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.DiscountRules.CustomerGroups.Fields.CustomerGroup");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.DiscountRules.CustomerGroups.Fields.CustomerGroup.Hint");- //HadSpentAmount- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.DiscountRules.Standard.HadSpentAmount.Fields.Amount");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.DiscountRules.Standard.HadSpentAmount.Fields.Amount.Hint");+ //HadSpentAmount+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.DiscountRules.Standard.HadSpentAmount.Fields.Amount");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.DiscountRules.Standard.HadSpentAmount.Fields.Amount.Hint");- //HasAllProducts- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.DiscountRules.HasAllProducts.Fields.Products");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.DiscountRules.HasAllProducts.Fields.Products.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.DiscountRules.HasAllProducts.Fields.Products.AddNew");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.DiscountRules.HasAllProducts.Fields.Products.Choose");+ //HasAllProducts+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.DiscountRules.HasAllProducts.Fields.Products");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.DiscountRules.HasAllProducts.Fields.Products.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.DiscountRules.HasAllProducts.Fields.Products.AddNew");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.DiscountRules.HasAllProducts.Fields.Products.Choose");- //HasOneProduct- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.DiscountRules.HasOneProduct.Fields.Products");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.DiscountRules.HasOneProduct.Fields.Products.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.DiscountRules.HasOneProduct.Fields.Products.AddNew");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.DiscountRules.HasOneProduct.Fields.Products.Choose");+ //HasOneProduct+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.DiscountRules.HasOneProduct.Fields.Products");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.DiscountRules.HasOneProduct.Fields.Products.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.DiscountRules.HasOneProduct.Fields.Products.AddNew");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.DiscountRules.HasOneProduct.Fields.Products.Choose");- await base.Uninstall();- }+ await base.Uninstall();}}\ No newline at end of filediff --git a/src/Plugins/DiscountRules.Standard/DiscountProvider.cs b/src/Plugins/DiscountRules.Standard/DiscountProvider.csindex 45d1151f6..fc0508b23 100644--- a/src/Plugins/DiscountRules.Standard/DiscountProvider.cs+++ b/src/Plugins/DiscountRules.Standard/DiscountProvider.cs@@ -1,54 +1,52 @@using DiscountRules.Standard.Providers;using Grand.Business.Core.Interfaces.Catalog.Discounts;-namespace DiscountRules.Standard+namespace DiscountRules.Standard;++public class DiscountProvider : IDiscountProvider{- public class DiscountProvider : IDiscountProvider- {- private readonly CustomerGroupDiscountRule _customerGroupDiscountRequirementRule;- private readonly HadSpentAmountDiscountRule _hadSpentAmountDiscountRequirementRule;- private readonly HasAllProductsDiscountRule _hasAllProductsDiscountRequirementRule;- private readonly HasOneProductDiscountRule _hasOneProductDiscountRequirementRule;- private readonly ShoppingCartDiscountRule _shoppingCartDiscountRequirementRule;+ private readonly CustomerGroupDiscountRule _customerGroupDiscountRequirementRule;+ private readonly HadSpentAmountDiscountRule _hadSpentAmountDiscountRequirementRule;+ private readonly HasAllProductsDiscountRule _hasAllProductsDiscountRequirementRule;+ private readonly HasOneProductDiscountRule _hasOneProductDiscountRequirementRule;+ private readonly ShoppingCartDiscountRule _shoppingCartDiscountRequirementRule;- public DiscountProvider(+ public DiscountProvider(CustomerGroupDiscountRule customerGroupDiscountRequirementRule,- HadSpentAmountDiscountRule hadSpentAmountDiscountRequirementRule,- HasAllProductsDiscountRule hasAllProductsDiscountRequirementRule,- HasOneProductDiscountRule hasOneProductDiscountRequirementRule,- ShoppingCartDiscountRule shoppingCartDiscountRequirementRule)- {- _customerGroupDiscountRequirementRule = customerGroupDiscountRequirementRule;- _hadSpentAmountDiscountRequirementRule = hadSpentAmountDiscountRequirementRule;- _hasAllProductsDiscountRequirementRule = hasAllProductsDiscountRequirementRule;- _hasOneProductDiscountRequirementRule = hasOneProductDiscountRequirementRule;- _shoppingCartDiscountRequirementRule = shoppingCartDiscountRequirementRule;- }--- public string ConfigurationUrl => "";-- public string SystemName => "DiscountRules.Standard";-- public string FriendlyName => "Standard discount requirements";-- public int Priority => 0;-- public IList<string> LimitedToStores => new List<string>();-- public IList<string> LimitedToGroups => new List<string>();-- public IList<IDiscountRule> GetRequirementRules()- {- var rules = new List<IDiscountRule>- {- _customerGroupDiscountRequirementRule,- _hadSpentAmountDiscountRequirementRule,- _hasAllProductsDiscountRequirementRule,- _hasOneProductDiscountRequirementRule,- _shoppingCartDiscountRequirementRule- };- return rules;- }+ HadSpentAmountDiscountRule hadSpentAmountDiscountRequirementRule,+ HasAllProductsDiscountRule hasAllProductsDiscountRequirementRule,+ HasOneProductDiscountRule hasOneProductDiscountRequirementRule,+ ShoppingCartDiscountRule shoppingCartDiscountRequirementRule)+ {+ _customerGroupDiscountRequirementRule = customerGroupDiscountRequirementRule;+ _hadSpentAmountDiscountRequirementRule = hadSpentAmountDiscountRequirementRule;+ _hasAllProductsDiscountRequirementRule = hasAllProductsDiscountRequirementRule;+ _hasOneProductDiscountRequirementRule = hasOneProductDiscountRequirementRule;+ _shoppingCartDiscountRequirementRule = shoppingCartDiscountRequirementRule;+ }+++ public string ConfigurationUrl => "";++ public string SystemName => "DiscountRules.Standard";++ public string FriendlyName => "Standard discount requirements";++ public int Priority => 0;++ public IList<string> LimitedToStores => new List<string>();++ public IList<string> LimitedToGroups => new List<string>();++ public IList<IDiscountRule> GetRequirementRules()+ {+ var rules = new List<IDiscountRule> {+ _customerGroupDiscountRequirementRule,+ _hadSpentAmountDiscountRequirementRule,+ _hasAllProductsDiscountRequirementRule,+ _hasOneProductDiscountRequirementRule,+ _shoppingCartDiscountRequirementRule+ };+ return rules;}-}+}\ No newline at end of filediff --git a/src/Plugins/DiscountRules.Standard/EndpointProvider.cs b/src/Plugins/DiscountRules.Standard/EndpointProvider.csindex 95a3a9ff2..47cbed67c 100644--- a/src/Plugins/DiscountRules.Standard/EndpointProvider.cs+++ b/src/Plugins/DiscountRules.Standard/EndpointProvider.cs@@ -2,60 +2,60 @@using Microsoft.AspNetCore.Builder;using Microsoft.AspNetCore.Routing;-namespace DiscountRules.Standard+namespace DiscountRules.Standard;++public class EndpointProvider : IEndpointProvider{- public class EndpointProvider : IEndpointProvider+ public void RegisterEndpoint(IEndpointRouteBuilder endpointRouteBuilder){- public void RegisterEndpoint(IEndpointRouteBuilder endpointRouteBuilder)- {- //CustomerGroups- endpointRouteBuilder.MapControllerRoute("Plugin.DiscountRules.CustomerGroups.Configure",- "Admin/CustomerGroups/Configure",- new { controller = "CustomerGroups", action = "Configure" }- );+ //CustomerGroups+ endpointRouteBuilder.MapControllerRoute("Plugin.DiscountRules.CustomerGroups.Configure",+ "Admin/CustomerGroups/Configure",+ new { controller = "CustomerGroups", action = "Configure" }+ );- //HadSpentAmount- endpointRouteBuilder.MapControllerRoute("Plugin.DiscountRules.HadSpentAmount.Configure",- "Admin/HadSpentAmount/Configure",- new { controller = "HadSpentAmount", action = "Configure" }- );+ //HadSpentAmount+ endpointRouteBuilder.MapControllerRoute("Plugin.DiscountRules.HadSpentAmount.Configure",+ "Admin/HadSpentAmount/Configure",+ new { controller = "HadSpentAmount", action = "Configure" }+ );- //HasAllProducts- endpointRouteBuilder.MapControllerRoute("Plugin.DiscountRules.HasAllProducts.Configure",- "Admin/HasAllProducts/Configure",- new { controller = "HasAllProducts", action = "Configure" }- );- endpointRouteBuilder.MapControllerRoute("Plugin.DiscountRules.HasAllProducts.ProductAddPopup",- "Admin/HasAllProducts/ProductAddPopup",- new { controller = "HasAllProducts", action = "ProductAddPopup" }- );- endpointRouteBuilder.MapControllerRoute("Plugin.DiscountRules.HasAllProducts.ProductAddPopupList",- "Admin/HasAllProducts/ProductAddPopupList",- new { controller = "HasAllProducts", action = "ProductAddPopupList" }- );- endpointRouteBuilder.MapControllerRoute("Plugin.DiscountRules.HasAllProducts.LoadProductFriendlyNames",- "Admin/HasAllProducts/LoadProductFriendlyNames",- new { controller = "HasAllProducts", action = "LoadProductFriendlyNames" }- );+ //HasAllProducts+ endpointRouteBuilder.MapControllerRoute("Plugin.DiscountRules.HasAllProducts.Configure",+ "Admin/HasAllProducts/Configure",+ new { controller = "HasAllProducts", action = "Configure" }+ );+ endpointRouteBuilder.MapControllerRoute("Plugin.DiscountRules.HasAllProducts.ProductAddPopup",+ "Admin/HasAllProducts/ProductAddPopup",+ new { controller = "HasAllProducts", action = "ProductAddPopup" }+ );+ endpointRouteBuilder.MapControllerRoute("Plugin.DiscountRules.HasAllProducts.ProductAddPopupList",+ "Admin/HasAllProducts/ProductAddPopupList",+ new { controller = "HasAllProducts", action = "ProductAddPopupList" }+ );+ endpointRouteBuilder.MapControllerRoute("Plugin.DiscountRules.HasAllProducts.LoadProductFriendlyNames",+ "Admin/HasAllProducts/LoadProductFriendlyNames",+ new { controller = "HasAllProducts", action = "LoadProductFriendlyNames" }+ );- //HasOneProduct- endpointRouteBuilder.MapControllerRoute("Plugin.DiscountRules.HasOneProduct.Configure",- "Admin/HasOneProduct/Configure",- new { controller = "HasOneProduct", action = "Configure" }- );- endpointRouteBuilder.MapControllerRoute("Plugin.DiscountRules.HasOneProduct.ProductAddPopup",- "Admin/HasOneProduct/ProductAddPopup",- new { controller = "HasOneProduct", action = "ProductAddPopup" }- );- endpointRouteBuilder.MapControllerRoute("Plugin.DiscountRules.HasOneProduct.ProductAddPopupList",- "Admin/HasOneProduct/ProductAddPopupList",- new { controller = "HasOneProduct", action = "ProductAddPopupList" }- );- endpointRouteBuilder.MapControllerRoute("Plugin.DiscountRules.HasOneProduct.LoadProductFriendlyNames",- "Admin/HasOneProduct/LoadProductFriendlyNames",- new { controller = "HasOneProduct", action = "LoadProductFriendlyNames" }- );- }- public int Priority => 0;+ //HasOneProduct+ endpointRouteBuilder.MapControllerRoute("Plugin.DiscountRules.HasOneProduct.Configure",+ "Admin/HasOneProduct/Configure",+ new { controller = "HasOneProduct", action = "Configure" }+ );+ endpointRouteBuilder.MapControllerRoute("Plugin.DiscountRules.HasOneProduct.ProductAddPopup",+ "Admin/HasOneProduct/ProductAddPopup",+ new { controller = "HasOneProduct", action = "ProductAddPopup" }+ );+ endpointRouteBuilder.MapControllerRoute("Plugin.DiscountRules.HasOneProduct.ProductAddPopupList",+ "Admin/HasOneProduct/ProductAddPopupList",+ new { controller = "HasOneProduct", action = "ProductAddPopupList" }+ );+ endpointRouteBuilder.MapControllerRoute("Plugin.DiscountRules.HasOneProduct.LoadProductFriendlyNames",+ "Admin/HasOneProduct/LoadProductFriendlyNames",+ new { controller = "HasOneProduct", action = "LoadProductFriendlyNames" }+ );}-}++ public int Priority => 0;+}\ No newline at end of filediff --git a/src/Plugins/DiscountRules.Standard/Manifest.cs b/src/Plugins/DiscountRules.Standard/Manifest.csindex f46292c58..fcef2ea8f 100644--- a/src/Plugins/DiscountRules.Standard/Manifest.cs+++ b/src/Plugins/DiscountRules.Standard/Manifest.cs@@ -6,4 +6,4 @@SystemName = "DiscountRules.Standard",Author = "grandnode team",Version = "2.1.1"-)]+)]\ No newline at end of filediff --git a/src/Plugins/DiscountRules.Standard/Models/RequirementModel.cs b/src/Plugins/DiscountRules.Standard/Models/RequirementModel.csindex 73ce10547..ac8eb78fd 100644--- a/src/Plugins/DiscountRules.Standard/Models/RequirementModel.cs+++ b/src/Plugins/DiscountRules.Standard/Models/RequirementModel.cs@@ -42,20 +42,25 @@ public class RequirementAllProductsModel{[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductName")]public string SearchProductName { get; set; }+[UIHint("Category")][GrandResourceDisplayName("Admin.Catalog.Products.List.SearchCategory")]public string SearchCategoryId { get; set; }+[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchCollection")][UIHint("Collection")]public string SearchCollectionId { get; set; }+[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchStore")]public string SearchStoreId { get; set; }+[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchVendor")]public string SearchVendorId { get; set; }+[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductType")]public int SearchProductTypeId { get; set; }-+public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();public IList<SelectListItem> AvailableVendors { get; set; } = new List<SelectListItem>();public IList<SelectListItem> AvailableProductTypes { get; set; } = new List<SelectListItem>();@@ -70,6 +75,7 @@ public class RequirementAllProductsModelpublic bool Published { get; set; }}+#endregion}@@ -88,16 +94,21 @@ public class RequirementOneProductModel{[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductName")]public string SearchProductName { get; set; }+[UIHint("Category")][GrandResourceDisplayName("Admin.Catalog.Products.List.SearchCategory")]public string SearchCategoryId { get; set; }+[UIHint("Collection")][GrandResourceDisplayName("Admin.Catalog.Products.List.SearchCollection")]public string SearchCollectionId { get; set; }+[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchStore")]public string SearchStoreId { get; set; }+[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchVendor")]public string SearchVendorId { get; set; }+[GrandResourceDisplayName("Admin.Catalog.Products.List.SearchProductType")]public int SearchProductTypeId { get; set; }diff --git a/src/Plugins/DiscountRules.Standard/Providers/CustomerGroupDiscountRule.cs b/src/Plugins/DiscountRules.Standard/Providers/CustomerGroupDiscountRule.csindex 0fd5bebcf..ed6a6293c 100644--- a/src/Plugins/DiscountRules.Standard/Providers/CustomerGroupDiscountRule.cs+++ b/src/Plugins/DiscountRules.Standard/Providers/CustomerGroupDiscountRule.cs@@ -1,52 +1,53 @@using Grand.Business.Core.Interfaces.Catalog.Discounts;using Grand.Business.Core.Utilities.Catalog;-namespace DiscountRules.Standard.Providers+namespace DiscountRules.Standard.Providers;++public class CustomerGroupDiscountRule : IDiscountRule{- public class CustomerGroupDiscountRule : IDiscountRule+ /// <summary>+ /// Check discount requirement+ /// </summary>+ /// <param name="request">+ /// Object that contains all information required to check the requirement (Current customer,+ /// discount, etc)+ /// </param>+ /// <returns>true - requirement is met; otherwise, false</returns>+ public async Task<DiscountRuleValidationResult> CheckRequirement(DiscountRuleValidationRequest request){- /// <summary>- /// Check discount requirement- /// </summary>- /// <param name="request">Object that contains all information required to check the requirement (Current customer, discount, etc)</param>- /// <returns>true - requirement is met; otherwise, false</returns>- public async Task<DiscountRuleValidationResult> CheckRequirement(DiscountRuleValidationRequest request)- {- ArgumentNullException.ThrowIfNull(request);-- //invalid by default- var result = new DiscountRuleValidationResult();-- if (request.Customer == null)- return result;-- if (string.IsNullOrEmpty(request.DiscountRule.Metadata))- return result;-- if (request.Customer.Groups.ToList().All(customerGroup => request.DiscountRule.Metadata != customerGroup))- return await Task.FromResult(result);- result.IsValid = true;+ ArgumentNullException.ThrowIfNull(request);++ //invalid by default+ var result = new DiscountRuleValidationResult();++ if (request.Customer == null)return result;- }-- /// <summary>- /// Get URL for rule configuration- /// </summary>- /// <param name="discountId">Discount identifier</param>- /// <param name="discountRequirementId">Discount requirement identifier (if editing)</param>- /// <returns>URL</returns>- public string GetConfigurationUrl(string discountId, string discountRequirementId)- {- //configured- var result = "Admin/CustomerGroups/Configure/?discountId=" + discountId;- if (!string.IsNullOrEmpty(discountRequirementId))- result += $"&discountRequirementId={discountRequirementId}";+ if (string.IsNullOrEmpty(request.DiscountRule.Metadata))return result;- }- public string FriendlyName => "Must be assigned to customer group";+ if (request.Customer.Groups.ToList().All(customerGroup => request.DiscountRule.Metadata != customerGroup))+ return await Task.FromResult(result);+ result.IsValid = true;+ return result;+ }- public string SystemName => "DiscountRules.Standard.MustBeAssignedToCustomerGroup";+ /// <summary>+ /// Get URL for rule configuration+ /// </summary>+ /// <param name="discountId">Discount identifier</param>+ /// <param name="discountRequirementId">Discount requirement identifier (if editing)</param>+ /// <returns>URL</returns>+ public string GetConfigurationUrl(string discountId, string discountRequirementId)+ {+ //configured+ var result = "Admin/CustomerGroups/Configure/?discountId=" + discountId;+ if (!string.IsNullOrEmpty(discountRequirementId))+ result += $"&discountRequirementId={discountRequirementId}";+ return result;}++ public string FriendlyName => "Must be assigned to customer group";++ public string SystemName => "DiscountRules.Standard.MustBeAssignedToCustomerGroup";}\ No newline at end of filediff --git a/src/Plugins/DiscountRules.Standard/Providers/HadSpentAmountDiscountRule.cs b/src/Plugins/DiscountRules.Standard/Providers/HadSpentAmountDiscountRule.csindex 0f85cd95e..0e70c5ba8 100644--- a/src/Plugins/DiscountRules.Standard/Providers/HadSpentAmountDiscountRule.cs+++ b/src/Plugins/DiscountRules.Standard/Providers/HadSpentAmountDiscountRule.cs@@ -4,75 +4,74 @@ using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Business.Core.Utilities.Catalog;using Grand.Domain.Orders;-namespace DiscountRules.Standard.Providers-{- public class HadSpentAmountDiscountRule : IDiscountRule- {- private readonly IOrderService _orderService;- private readonly ITranslationService _translationService;+namespace DiscountRules.Standard.Providers;- public HadSpentAmountDiscountRule(IOrderService orderService, ITranslationService translationService)- {- _orderService = orderService;- _translationService = translationService;- }+public class HadSpentAmountDiscountRule : IDiscountRule+{+ private readonly IOrderService _orderService;+ private readonly ITranslationService _translationService;- /// <summary>- /// Check discount requirement- /// </summary>- /// <param name="request">Object that contains all information required to check the requirement (Current customer, discount, etc)</param>- /// <returns>true - requirement is met; otherwise, false</returns>- public async Task<DiscountRuleValidationResult> CheckRequirement(DiscountRuleValidationRequest request)- {- ArgumentNullException.ThrowIfNull(request);+ public HadSpentAmountDiscountRule(IOrderService orderService, ITranslationService translationService)+ {+ _orderService = orderService;+ _translationService = translationService;+ }- //invalid by default- var result = new DiscountRuleValidationResult();+ /// <summary>+ /// Check discount requirement+ /// </summary>+ /// <param name="request">+ /// Object that contains all information required to check the requirement (Current customer,+ /// discount, etc)+ /// </param>+ /// <returns>true - requirement is met; otherwise, false</returns>+ public async Task<DiscountRuleValidationResult> CheckRequirement(DiscountRuleValidationRequest request)+ {+ ArgumentNullException.ThrowIfNull(request);- if (!double.TryParse(request.DiscountRule.Metadata, out var spentAmountRequirement)) return result;-- if (spentAmountRequirement == 0)- {- //valid- result.IsValid = true;- return result;- }+ //invalid by default+ var result = new DiscountRuleValidationResult();- if (request.Customer == null)- return result;+ if (!double.TryParse(request.DiscountRule.Metadata, out var spentAmountRequirement)) return result;- var orders = await _orderService.SearchOrders(storeId: request.Store.Id,- customerId: request.Customer.Id,- os: (int)OrderStatusSystem.Complete);- var spentAmount = orders.Sum(o => o.OrderTotal);- if (spentAmount > spentAmountRequirement)- {- result.IsValid = true;- }- else- {- result.UserError = _translationService.GetResource("Plugins.DiscountRules.Standard.HadSpentAmount.NotEnough");- }+ if (spentAmountRequirement == 0)+ {+ //valid+ result.IsValid = true;return result;}- /// <summary>- /// Get URL for rule configuration- /// </summary>- /// <param name="discountId">Discount identifier</param>- /// <param name="discountRequirementId">Discount requirement identifier (if editing)</param>- /// <returns>URL</returns>- public string GetConfigurationUrl(string discountId, string discountRequirementId)- {- //configured- var result = "Admin/HadSpentAmount/Configure/?discountId=" + discountId;- if (!string.IsNullOrEmpty(discountRequirementId))- result += $"&discountRequirementId={discountRequirementId}";+ if (request.Customer == null)return result;- }- public string FriendlyName => "Customer had spent x.xx amount";+ var orders = await _orderService.SearchOrders(request.Store.Id,+ customerId: request.Customer.Id,+ os: (int)OrderStatusSystem.Complete);+ var spentAmount = orders.Sum(o => o.OrderTotal);+ if (spentAmount > spentAmountRequirement)+ result.IsValid = true;+ else+ result.UserError =+ _translationService.GetResource("Plugins.DiscountRules.Standard.HadSpentAmount.NotEnough");+ return result;+ }- public string SystemName => "DiscountRules.Standard.HadSpentAmount";+ /// <summary>+ /// Get URL for rule configuration+ /// </summary>+ /// <param name="discountId">Discount identifier</param>+ /// <param name="discountRequirementId">Discount requirement identifier (if editing)</param>+ /// <returns>URL</returns>+ public string GetConfigurationUrl(string discountId, string discountRequirementId)+ {+ //configured+ var result = "Admin/HadSpentAmount/Configure/?discountId=" + discountId;+ if (!string.IsNullOrEmpty(discountRequirementId))+ result += $"&discountRequirementId={discountRequirementId}";+ return result;}++ public string FriendlyName => "Customer had spent x.xx amount";++ public string SystemName => "DiscountRules.Standard.HadSpentAmount";}\ No newline at end of filediff --git a/src/Plugins/DiscountRules.Standard/Providers/HasAllProductsDiscountRule.cs b/src/Plugins/DiscountRules.Standard/Providers/HasAllProductsDiscountRule.csindex 9f6883fbd..d8942dadb 100644--- a/src/Plugins/DiscountRules.Standard/Providers/HasAllProductsDiscountRule.cs+++ b/src/Plugins/DiscountRules.Standard/Providers/HasAllProductsDiscountRule.cs@@ -2,129 +2,135 @@ using Grand.Business.Core.Interfaces.Catalog.Discounts;using Grand.Business.Core.Utilities.Catalog;using Grand.Domain.Orders;-namespace DiscountRules.Standard.Providers+namespace DiscountRules.Standard.Providers;++public class HasAllProductsDiscountRule : IDiscountRule{- public class HasAllProductsDiscountRule : IDiscountRule- {- private readonly ShoppingCartSettings _shoppingCartSettings;+ private readonly ShoppingCartSettings _shoppingCartSettings;- public HasAllProductsDiscountRule(ShoppingCartSettings shoppingCartSettings)- {- _shoppingCartSettings = shoppingCartSettings;- }+ public HasAllProductsDiscountRule(ShoppingCartSettings shoppingCartSettings)+ {+ _shoppingCartSettings = shoppingCartSettings;+ }- /// <summary>- /// Check discount requirement- /// </summary>- /// <param name="request">Object that contains all information required to check the requirement (Current customer, discount, etc)</param>- /// <returns>true - requirement is met; otherwise, false</returns>- public async Task<DiscountRuleValidationResult> CheckRequirement(DiscountRuleValidationRequest request)- {- ArgumentNullException.ThrowIfNull(request);+ /// <summary>+ /// Check discount requirement+ /// </summary>+ /// <param name="request">+ /// Object that contains all information required to check the requirement (Current customer,+ /// discount, etc)+ /// </param>+ /// <returns>true - requirement is met; otherwise, false</returns>+ public async Task<DiscountRuleValidationResult> CheckRequirement(DiscountRuleValidationRequest request)+ {+ ArgumentNullException.ThrowIfNull(request);- //invalid by default- var result = new DiscountRuleValidationResult();+ //invalid by default+ var result = new DiscountRuleValidationResult();- var restrictedProductIds = string.IsNullOrEmpty(request.DiscountRule.Metadata) ? [] : request.DiscountRule.Metadata.Split(',').ToList();+ var restrictedProductIds = string.IsNullOrEmpty(request.DiscountRule.Metadata)+ ? []+ : request.DiscountRule.Metadata.Split(',').ToList();- if (!restrictedProductIds.Any())- {- //valid- result.IsValid = true;- return result;- }+ if (!restrictedProductIds.Any())+ {+ //valid+ result.IsValid = true;+ return result;+ }- if (request.Customer == null)- return result;+ if (request.Customer == null)+ return result;- //group products in the cart by product ID- //it could be the same product with distinct product attributes- //that's why we get the total quantity of this product- var cartQuery = from sci in request.Customer.ShoppingCartItems.LimitPerStore(_shoppingCartSettings.SharedCartBetweenStores, request.Store.Id)- where sci.ShoppingCartTypeId == ShoppingCartType.ShoppingCart- group sci by sci.ProductId into g- select new { ProductId = g.Key, TotalQuantity = g.Sum(x => x.Quantity) };- var cart = cartQuery.ToList();+ //group products in the cart by product ID+ //it could be the same product with distinct product attributes+ //that's why we get the total quantity of this product+ var cartQuery =+ from sci in request.Customer.ShoppingCartItems.LimitPerStore(_shoppingCartSettings.SharedCartBetweenStores,+ request.Store.Id)+ where sci.ShoppingCartTypeId == ShoppingCartType.ShoppingCart+ group sci by sci.ProductId+ into g+ select new { ProductId = g.Key, TotalQuantity = g.Sum(x => x.Quantity) };+ var cart = cartQuery.ToList();++ var allFound = true;+ foreach (var restrictedProduct in restrictedProductIds.Select(x => x.Trim()))+ {+ if (string.IsNullOrWhiteSpace(restrictedProduct))+ continue;- var allFound = true;- foreach (var restrictedProduct in restrictedProductIds.Select(x => x.Trim()))+ var found1 = false;+ foreach (var sci in cart){- if (string.IsNullOrWhiteSpace(restrictedProduct))- continue;-- var found1 = false;- foreach (var sci in cart)+ if (restrictedProduct.Contains(':')){- if (restrictedProduct.Contains(':'))+ if (restrictedProduct.Contains('-')){- if (restrictedProduct.Contains('-'))- {- //the third way (the quantity rage specified)- //{Product ID}:{Min quantity}-{Max quantity}. For example, 77:1-3, 123:2-5, 156:3-8- var restrictedProductId = restrictedProduct.Split([':'])[0];- if (!int.TryParse(restrictedProduct.Split([':'])[1].Split(['-'])[0], out var quantityMin))- //parsing error; exit;- return result;- if (!int.TryParse(restrictedProduct.Split([':'])[1].Split(['-'])[1], out var quantityMax))- //parsing error; exit;- return result;-- if (sci.ProductId != restrictedProductId || quantityMin > sci.TotalQuantity ||- sci.TotalQuantity > quantityMax) continue;- found1 = true;- break;- }- else- {- //the second way (the quantity specified)- //{Product ID}:{Quantity}. For example, 77:1, 123:2, 156:3- var restrictedProductId = restrictedProduct.Split([':'])[0];- if (!int.TryParse(restrictedProduct.Split([':'])[1], out var quantity))- //parsing error; exit;- return result;-- if (sci.ProductId != restrictedProductId || sci.TotalQuantity != quantity) continue;- found1 = true;- break;- }+ //the third way (the quantity rage specified)+ //{Product ID}:{Min quantity}-{Max quantity}. For example, 77:1-3, 123:2-5, 156:3-8+ var restrictedProductId = restrictedProduct.Split([':'])[0];+ if (!int.TryParse(restrictedProduct.Split([':'])[1].Split(['-'])[0], out var quantityMin))+ //parsing error; exit;+ return result;+ if (!int.TryParse(restrictedProduct.Split([':'])[1].Split(['-'])[1], out var quantityMax))+ //parsing error; exit;+ return result;++ if (sci.ProductId != restrictedProductId || quantityMin > sci.TotalQuantity ||+ sci.TotalQuantity > quantityMax) continue;+ found1 = true;+ break;+ }+ else+ {+ //the second way (the quantity specified)+ //{Product ID}:{Quantity}. For example, 77:1, 123:2, 156:3+ var restrictedProductId = restrictedProduct.Split([':'])[0];+ if (!int.TryParse(restrictedProduct.Split([':'])[1], out var quantity))+ //parsing error; exit;+ return result;++ if (sci.ProductId != restrictedProductId || sci.TotalQuantity != quantity) continue;+ found1 = true;+ break;}-- //the first way (the quantity is not specified)- if (sci.ProductId != restrictedProduct) continue;- found1 = true;- break;}- if (found1) continue;- allFound = false;+ //the first way (the quantity is not specified)+ if (sci.ProductId != restrictedProduct) continue;+ found1 = true;break;}- if (!allFound) return await Task.FromResult(result);- //valid- result.IsValid = true;- return result;-+ if (found1) continue;+ allFound = false;+ break;}- /// <summary>- /// Get URL for rule configuration- /// </summary>- /// <param name="discountId">Discount identifier</param>- /// <param name="discountRequirementId">Discount requirement identifier (if editing)</param>- /// <returns>URL</returns>- public string GetConfigurationUrl(string discountId, string discountRequirementId)- {- //configured- var result = "Admin/HasAllProducts/Configure/?discountId=" + discountId;- if (!string.IsNullOrEmpty(discountRequirementId))- result += $"&discountRequirementId={discountRequirementId}";- return result;- }-- public string FriendlyName => "Customer has all of these products in";+ if (!allFound) return await Task.FromResult(result);+ //valid+ result.IsValid = true;+ return result;+ }- public string SystemName => "DiscountRules.HasAllProducts";+ /// <summary>+ /// Get URL for rule configuration+ /// </summary>+ /// <param name="discountId">Discount identifier</param>+ /// <param name="discountRequirementId">Discount requirement identifier (if editing)</param>+ /// <returns>URL</returns>+ public string GetConfigurationUrl(string discountId, string discountRequirementId)+ {+ //configured+ var result = "Admin/HasAllProducts/Configure/?discountId=" + discountId;+ if (!string.IsNullOrEmpty(discountRequirementId))+ result += $"&discountRequirementId={discountRequirementId}";+ return result;}++ public string FriendlyName => "Customer has all of these products in";++ public string SystemName => "DiscountRules.HasAllProducts";}\ No newline at end of filediff --git a/src/Plugins/DiscountRules.Standard/Providers/HasOneProductDiscountRule.cs b/src/Plugins/DiscountRules.Standard/Providers/HasOneProductDiscountRule.csindex 6e6dd1019..0ed59bd6f 100644--- a/src/Plugins/DiscountRules.Standard/Providers/HasOneProductDiscountRule.cs+++ b/src/Plugins/DiscountRules.Standard/Providers/HasOneProductDiscountRule.cs@@ -2,132 +2,134 @@ using Grand.Business.Core.Interfaces.Catalog.Discounts;using Grand.Business.Core.Utilities.Catalog;using Grand.Domain.Orders;-namespace DiscountRules.Standard.Providers+namespace DiscountRules.Standard.Providers;++public class HasOneProductDiscountRule : IDiscountRule{- public class HasOneProductDiscountRule : IDiscountRule+ private readonly ShoppingCartSettings _shoppingCartSettings;++ public HasOneProductDiscountRule(ShoppingCartSettings shoppingCartSettings){- private readonly ShoppingCartSettings _shoppingCartSettings;+ _shoppingCartSettings = shoppingCartSettings;+ }- public HasOneProductDiscountRule(ShoppingCartSettings shoppingCartSettings)- {- _shoppingCartSettings = shoppingCartSettings;- }+ /// <summary>+ /// Check discount requirement+ /// </summary>+ /// <param name="request">+ /// Object that contains all information required to check the requirement (Current customer,+ /// discount, etc)+ /// </param>+ /// <returns>true - requirement is met; otherwise, false</returns>+ public async Task<DiscountRuleValidationResult> CheckRequirement(DiscountRuleValidationRequest request)+ {+ ArgumentNullException.ThrowIfNull(request);- /// <summary>- /// Check discount requirement- /// </summary>- /// <param name="request">Object that contains all information required to check the requirement (Current customer, discount, etc)</param>- /// <returns>true - requirement is met; otherwise, false</returns>- public async Task<DiscountRuleValidationResult> CheckRequirement(DiscountRuleValidationRequest request)- {- ArgumentNullException.ThrowIfNull(request);+ //invalid by default+ var result = new DiscountRuleValidationResult();- //invalid by default- var result = new DiscountRuleValidationResult();+ var restrictedProductIds = string.IsNullOrEmpty(request.DiscountRule.Metadata)+ ? []+ : request.DiscountRule.Metadata.Split(',').ToList();- var restrictedProductIds = string.IsNullOrEmpty(request.DiscountRule.Metadata) ? [] : request.DiscountRule.Metadata.Split(',').ToList();+ if (!restrictedProductIds.Any())+ {+ //valid+ result.IsValid = true;+ return result;+ }- if (!restrictedProductIds.Any())- {- //valid- result.IsValid = true;- return result;- }+ if (request.Customer == null)+ return result;- if (request.Customer == null)- return result;-- //group products in the cart by product ID- //it could be the same product with distinct product attributes- //that's why we get the total quantity of this product- var cartQuery = from sci in request.Customer.ShoppingCartItems.LimitPerStore(_shoppingCartSettings.SharedCartBetweenStores, request.Store.Id)- where sci.ShoppingCartTypeId == ShoppingCartType.ShoppingCart- group sci by sci.ProductId into g- select new { ProductId = g.Key, TotalQuantity = g.Sum(x => x.Quantity) };- var cart = cartQuery.ToList();-- //process- var found = false;- foreach (var restrictedProduct in restrictedProductIds)- {- if (string.IsNullOrWhiteSpace(restrictedProduct))- continue;+ //group products in the cart by product ID+ //it could be the same product with distinct product attributes+ //that's why we get the total quantity of this product+ var cartQuery =+ from sci in request.Customer.ShoppingCartItems.LimitPerStore(_shoppingCartSettings.SharedCartBetweenStores,+ request.Store.Id)+ where sci.ShoppingCartTypeId == ShoppingCartType.ShoppingCart+ group sci by sci.ProductId+ into g+ select new { ProductId = g.Key, TotalQuantity = g.Sum(x => x.Quantity) };+ var cart = cartQuery.ToList();++ //process+ var found = false;+ foreach (var restrictedProduct in restrictedProductIds)+ {+ if (string.IsNullOrWhiteSpace(restrictedProduct))+ continue;- foreach (var sci in cart)+ foreach (var sci in cart)+ {+ if (restrictedProduct.Contains(':')){- if (restrictedProduct.Contains(':'))+ if (restrictedProduct.Contains('-')){- if (restrictedProduct.Contains('-'))- {- //the third way (the quantity rage specified)- //{Product ID}:{Min quantity}-{Max quantity}. For example, 77:1-3, 123:2-5, 156:3-8- var restrictedProductId = restrictedProduct.Split([':'])[0];-- if (!int.TryParse(restrictedProduct.Split([':'])[1].Split(['-'])[0], out var quantityMin))- //parsing error; exit;- return result;- if (!int.TryParse(restrictedProduct.Split([':'])[1].Split(['-'])[1], out var quantityMax))- //parsing error; exit;- return result;-- if (sci.ProductId != restrictedProductId || quantityMin > sci.TotalQuantity ||- sci.TotalQuantity > quantityMax) continue;- found = true;- break;- }- else- {- //the second way (the quantity specified)- //{Product ID}:{Quantity}. For example, 77:1, 123:2, 156:3- var restrictedProductId = restrictedProduct.Split([':'])[0];-- if (!int.TryParse(restrictedProduct.Split([':'])[1], out var quantity))- //parsing error; exit;- return result;-- if (sci.ProductId != restrictedProductId || sci.TotalQuantity != quantity) continue;- found = true;- break;- }+ //the third way (the quantity rage specified)+ //{Product ID}:{Min quantity}-{Max quantity}. For example, 77:1-3, 123:2-5, 156:3-8+ var restrictedProductId = restrictedProduct.Split([':'])[0];++ if (!int.TryParse(restrictedProduct.Split([':'])[1].Split(['-'])[0], out var quantityMin))+ //parsing error; exit;+ return result;+ if (!int.TryParse(restrictedProduct.Split([':'])[1].Split(['-'])[1], out var quantityMax))+ //parsing error; exit;+ return result;++ if (sci.ProductId != restrictedProductId || quantityMin > sci.TotalQuantity ||+ sci.TotalQuantity > quantityMax) continue;+ found = true;+ break;}+ else+ {+ //the second way (the quantity specified)+ //{Product ID}:{Quantity}. For example, 77:1, 123:2, 156:3+ var restrictedProductId = restrictedProduct.Split([':'])[0];- //the first way (the quantity is not specified)- if (sci.ProductId != restrictedProduct) continue;- found = true;- break;- }+ if (!int.TryParse(restrictedProduct.Split([':'])[1], out var quantity))+ //parsing error; exit;+ return result;- if (found)- {- break;+ if (sci.ProductId != restrictedProductId || sci.TotalQuantity != quantity) continue;+ found = true;+ break;+ }}- }- if (!found) return await Task.FromResult(result);- //valid- result.IsValid = true;- return result;+ //the first way (the quantity is not specified)+ if (sci.ProductId != restrictedProduct) continue;+ found = true;+ break;+ }+ if (found) break;}- /// <summary>- /// Get URL for rule configuration- /// </summary>- /// <param name="discountId">Discount identifier</param>- /// <param name="discountRequirementId">Discount requirement identifier (if editing)</param>- /// <returns>URL</returns>- public string GetConfigurationUrl(string discountId, string discountRequirementId)- {- //configured- var result = "Admin/HasOneProduct/Configure/?discountId=" + discountId;- if (!string.IsNullOrEmpty(discountRequirementId))- result += $"&discountRequirementId={discountRequirementId}";- return result;- }+ if (!found) return await Task.FromResult(result);+ //valid+ result.IsValid = true;+ return result;+ }- public string FriendlyName => "Customer has one of these products in the cart";+ /// <summary>+ /// Get URL for rule configuration+ /// </summary>+ /// <param name="discountId">Discount identifier</param>+ /// <param name="discountRequirementId">Discount requirement identifier (if editing)</param>+ /// <returns>URL</returns>+ public string GetConfigurationUrl(string discountId, string discountRequirementId)+ {+ //configured+ var result = "Admin/HasOneProduct/Configure/?discountId=" + discountId;+ if (!string.IsNullOrEmpty(discountRequirementId))+ result += $"&discountRequirementId={discountRequirementId}";+ return result;+ }- public string SystemName => "DiscountRules.HasOneProduct";+ public string FriendlyName => "Customer has one of these products in the cart";- }+ public string SystemName => "DiscountRules.HasOneProduct";}\ No newline at end of filediff --git a/src/Plugins/DiscountRules.Standard/Providers/ShoppingCartDiscountRule.cs b/src/Plugins/DiscountRules.Standard/Providers/ShoppingCartDiscountRule.csindex 0de79ba08..1a4cf53be 100644--- a/src/Plugins/DiscountRules.Standard/Providers/ShoppingCartDiscountRule.cs+++ b/src/Plugins/DiscountRules.Standard/Providers/ShoppingCartDiscountRule.cs@@ -7,87 +7,91 @@ using Grand.Infrastructure;using Microsoft.AspNetCore.Http;using Microsoft.Extensions.DependencyInjection;-namespace DiscountRules.Standard.Providers-{- public class ShoppingCartDiscountRule : IDiscountRule- {- private readonly IWorkContext _workContext;- private readonly IProductService _productService;- private readonly IHttpContextAccessor _httpContextAccessor;- private readonly ShoppingCartSettings _shoppingCartSettings;-- public ShoppingCartDiscountRule(- IWorkContext workContext,- IProductService productService,- IHttpContextAccessor httpContextAccessor,- ShoppingCartSettings shoppingCartSettings)- {- _workContext = workContext;- _productService = productService;- _httpContextAccessor = httpContextAccessor;- _shoppingCartSettings = shoppingCartSettings;- }+namespace DiscountRules.Standard.Providers;- /// <summary>- /// Check discount requirement- /// </summary>- /// <param name="request">Object that contains all information required to check the requirement (Current customer, discount, etc)</param>- /// <returns>true - requirement is met; otherwise, false</returns>- public async Task<DiscountRuleValidationResult> CheckRequirement(DiscountRuleValidationRequest request)- {- ArgumentNullException.ThrowIfNull(request);+public class ShoppingCartDiscountRule : IDiscountRule+{+ private readonly IHttpContextAccessor _httpContextAccessor;+ private readonly IProductService _productService;+ private readonly ShoppingCartSettings _shoppingCartSettings;+ private readonly IWorkContext _workContext;- var result = new DiscountRuleValidationResult();+ public ShoppingCartDiscountRule(+ IWorkContext workContext,+ IProductService productService,+ IHttpContextAccessor httpContextAccessor,+ ShoppingCartSettings shoppingCartSettings)+ {+ _workContext = workContext;+ _productService = productService;+ _httpContextAccessor = httpContextAccessor;+ _shoppingCartSettings = shoppingCartSettings;+ }- if (!double.TryParse(request.DiscountRule.Metadata, out var spentAmountRequirement)) return result;-- if (spentAmountRequirement == 0)- {- result.IsValid = true;- return result;- }+ /// <summary>+ /// Check discount requirement+ /// </summary>+ /// <param name="request">+ /// Object that contains all information required to check the requirement (Current customer,+ /// discount, etc)+ /// </param>+ /// <returns>true - requirement is met; otherwise, false</returns>+ public async Task<DiscountRuleValidationResult> CheckRequirement(DiscountRuleValidationRequest request)+ {+ ArgumentNullException.ThrowIfNull(request);- var cart = _workContext.CurrentCustomer.ShoppingCartItems- .Where(sci => sci.ShoppingCartTypeId == ShoppingCartType.ShoppingCart)- .LimitPerStore(_shoppingCartSettings.SharedCartBetweenStores, request.Store.Id)- .ToList();+ var result = new DiscountRuleValidationResult();- if (cart.Count == 0)- {- result.IsValid = false;- return result;- }- double spentAmount = 0;+ if (!double.TryParse(request.DiscountRule.Metadata, out var spentAmountRequirement)) return result;- var priceCalculationService = _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<IPricingService>();+ if (spentAmountRequirement == 0)+ {+ result.IsValid = true;+ return result;+ }- foreach (var ca in cart)- {- var product = await _productService.GetProductById(ca.ProductId);- if (product != null)- spentAmount += (await priceCalculationService.GetSubTotal(ca, product, false)).subTotal;- }+ var cart = _workContext.CurrentCustomer.ShoppingCartItems+ .Where(sci => sci.ShoppingCartTypeId == ShoppingCartType.ShoppingCart)+ .LimitPerStore(_shoppingCartSettings.SharedCartBetweenStores, request.Store.Id)+ .ToList();- result.IsValid = spentAmount > spentAmountRequirement;+ if (cart.Count == 0)+ {+ result.IsValid = false;return result;}- /// <summary>- /// Get URL for rule configuration- /// </summary>- /// <param name="discountId">Discount identifier</param>- /// <param name="discountRequirementId">Discount requirement identifier (if editing)</param>- /// <returns>URL</returns>- public string GetConfigurationUrl(string discountId, string discountRequirementId)+ double spentAmount = 0;++ var priceCalculationService =+ _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<IPricingService>();++ foreach (var ca in cart){- //configured- var result = "Admin/ShoppingCartAmount/Configure/?discountId=" + discountId;- if (!string.IsNullOrEmpty(discountRequirementId))- result += $"&discountRequirementId={discountRequirementId}";- return result;+ var product = await _productService.GetProductById(ca.ProductId);+ if (product != null)+ spentAmount += (await priceCalculationService.GetSubTotal(ca, product, false)).subTotal;}- public string FriendlyName => "SubTotal in Shopping Cart x.xx ";- public string SystemName => "DiscountRequirement.ShoppingCart";+ result.IsValid = spentAmount > spentAmountRequirement;+ return result;}++ /// <summary>+ /// Get URL for rule configuration+ /// </summary>+ /// <param name="discountId">Discount identifier</param>+ /// <param name="discountRequirementId">Discount requirement identifier (if editing)</param>+ /// <returns>URL</returns>+ public string GetConfigurationUrl(string discountId, string discountRequirementId)+ {+ //configured+ var result = "Admin/ShoppingCartAmount/Configure/?discountId=" + discountId;+ if (!string.IsNullOrEmpty(discountRequirementId))+ result += $"&discountRequirementId={discountRequirementId}";+ return result;+ }++ public string FriendlyName => "SubTotal in Shopping Cart x.xx ";+ public string SystemName => "DiscountRequirement.ShoppingCart";}\ No newline at end of filediff --git a/src/Plugins/DiscountRules.Standard/StartupApplication.cs b/src/Plugins/DiscountRules.Standard/StartupApplication.csindex 629998e3f..718adfca7 100644--- a/src/Plugins/DiscountRules.Standard/StartupApplication.cs+++ b/src/Plugins/DiscountRules.Standard/StartupApplication.cs@@ -6,25 +6,25 @@ using Microsoft.AspNetCore.Hosting;using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;-namespace DiscountRules.Standard+namespace DiscountRules.Standard;++public class StartupApplication : IStartupApplication{- public class StartupApplication : IStartupApplication+ public void ConfigureServices(IServiceCollection services, IConfiguration configuration){- public void ConfigureServices(IServiceCollection services, IConfiguration configuration)- {- services.AddScoped<IDiscountProvider, DiscountProvider>();- services.AddScoped<CustomerGroupDiscountRule>();- services.AddScoped<HadSpentAmountDiscountRule>();- services.AddScoped<HasAllProductsDiscountRule>();- services.AddScoped<HasOneProductDiscountRule>();- services.AddScoped<ShoppingCartDiscountRule>();- }+ services.AddScoped<IDiscountProvider, DiscountProvider>();+ services.AddScoped<CustomerGroupDiscountRule>();+ services.AddScoped<HadSpentAmountDiscountRule>();+ services.AddScoped<HasAllProductsDiscountRule>();+ services.AddScoped<HasOneProductDiscountRule>();+ services.AddScoped<ShoppingCartDiscountRule>();+ }- public int Priority => 10;- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)- {+ public int Priority => 10;- }- public bool BeforeConfigure => false;+ public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)+ {}-}++ public bool BeforeConfigure => false;+}\ No newline at end of filediff --git a/src/Plugins/ExchangeRate.McExchange/Constant.cs b/src/Plugins/ExchangeRate.McExchange/Constant.csindex 1df5239cb..55fa9ceac 100644--- a/src/Plugins/ExchangeRate.McExchange/Constant.cs+++ b/src/Plugins/ExchangeRate.McExchange/Constant.cs@@ -1,9 +1,8 @@-namespace ExchangeRate.McExchange+namespace ExchangeRate.McExchange;++public static class Constant{- public static class Constant- {- public static string DefaultHttpClientName => "ExchangeRateHttpClient";- public static string EcbUrl => "http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml";- public static string NbpUrl => "http://api.nbp.pl/api/exchangerates/tables/A/";- }-}+ public static string DefaultHttpClientName => "ExchangeRateHttpClient";+ public static string EcbUrl => "http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml";+ public static string NbpUrl => "http://api.nbp.pl/api/exchangerates/tables/A/";+}\ No newline at end of filediff --git a/src/Plugins/ExchangeRate.McExchange/EcbExchange.cs b/src/Plugins/ExchangeRate.McExchange/EcbExchange.csindex ddafdd6eb..b1d6767dc 100644--- a/src/Plugins/ExchangeRate.McExchange/EcbExchange.cs+++ b/src/Plugins/ExchangeRate.McExchange/EcbExchange.cs@@ -2,46 +2,43 @@ using System.Globalization;using System.Net.Http;using System.Xml;-namespace ExchangeRate.McExchange+namespace ExchangeRate.McExchange;++internal class EcbExchange : IRateProvider{- internal class EcbExchange : IRateProvider- {- private readonly IHttpClientFactory _httpClientFactory;+ private readonly IHttpClientFactory _httpClientFactory;- public EcbExchange(IHttpClientFactory httpClientFactory)- {- _httpClientFactory = httpClientFactory;- }+ public EcbExchange(IHttpClientFactory httpClientFactory)+ {+ _httpClientFactory = httpClientFactory;+ }- public async Task<IList<Grand.Domain.Directory.ExchangeRate>> GetCurrencyLiveRates()- {- var httpClient = _httpClientFactory.CreateClient(Constant.DefaultHttpClientName);- await using var response = await httpClient.GetStreamAsync(Constant.EcbUrl);- var document = new XmlDocument();- document.Load(response);- var nameTable = new XmlNamespaceManager(document.NameTable);- nameTable.AddNamespace("ns", "http://www.ecb.int/vocabulary/2002-08-01/eurofxref");- nameTable.AddNamespace("gesmes", "http://www.gesmes.org/xml/2002-08-01");+ public async Task<IList<Grand.Domain.Directory.ExchangeRate>> GetCurrencyLiveRates()+ {+ var httpClient = _httpClientFactory.CreateClient(Constant.DefaultHttpClientName);+ await using var response = await httpClient.GetStreamAsync(Constant.EcbUrl);+ var document = new XmlDocument();+ document.Load(response);+ var nameTable = new XmlNamespaceManager(document.NameTable);+ nameTable.AddNamespace("ns", "http://www.ecb.int/vocabulary/2002-08-01/eurofxref");+ nameTable.AddNamespace("gesmes", "http://www.gesmes.org/xml/2002-08-01");- var node = document.SelectSingleNode("gesmes:Envelope/ns:Cube/ns:Cube", nameTable);- var updateDate = DateTime.ParseExact(node.Attributes["time"].Value, "yyyy-MM-dd", null);+ var node = document.SelectSingleNode("gesmes:Envelope/ns:Cube/ns:Cube", nameTable);+ var updateDate = DateTime.ParseExact(node.Attributes["time"].Value, "yyyy-MM-dd", null);- var provider = new NumberFormatInfo {- NumberDecimalSeparator = ".",- NumberGroupSeparator = ""- };+ var provider = new NumberFormatInfo {+ NumberDecimalSeparator = ".",+ NumberGroupSeparator = ""+ };- var exchangeRates = new List<Grand.Domain.Directory.ExchangeRate>();- foreach (XmlNode node2 in node.ChildNodes)- {- exchangeRates.Add(new Grand.Domain.Directory.ExchangeRate {+ var exchangeRates = new List<Grand.Domain.Directory.ExchangeRate>();+ foreach (XmlNode node2 in node.ChildNodes)+ exchangeRates.Add(new Grand.Domain.Directory.ExchangeRate {CurrencyCode = node2.Attributes["currency"].Value,Rate = double.Parse(node2.Attributes["rate"].Value, provider),UpdatedOn = updateDate}- );- }- return exchangeRates;- }+ );+ return exchangeRates;}-}+}\ No newline at end of filediff --git a/src/Plugins/ExchangeRate.McExchange/IRateProvider.cs b/src/Plugins/ExchangeRate.McExchange/IRateProvider.csindex 20c15c720..8449796e2 100644--- a/src/Plugins/ExchangeRate.McExchange/IRateProvider.cs+++ b/src/Plugins/ExchangeRate.McExchange/IRateProvider.cs@@ -1,7 +1,6 @@-namespace ExchangeRate.McExchange+namespace ExchangeRate.McExchange;++internal interface IRateProvider{- internal interface IRateProvider- {- Task<IList<Grand.Domain.Directory.ExchangeRate>> GetCurrencyLiveRates();- }-}+ Task<IList<Grand.Domain.Directory.ExchangeRate>> GetCurrencyLiveRates();+}\ No newline at end of filediff --git a/src/Plugins/ExchangeRate.McExchange/McExchangeRatePlugin.cs b/src/Plugins/ExchangeRate.McExchange/McExchangeRatePlugin.csindex 404e3d9b6..6d5f62161 100644--- a/src/Plugins/ExchangeRate.McExchange/McExchangeRatePlugin.cs+++ b/src/Plugins/ExchangeRate.McExchange/McExchangeRatePlugin.cs@@ -3,9 +3,8 @@ using System.Runtime.CompilerServices;[assembly: InternalsVisibleTo("Grand.Plugin.Tests")]-namespace ExchangeRate.McExchange+namespace ExchangeRate.McExchange;++public class McExchangeRatePlugin : BasePlugin{- public class McExchangeRatePlugin : BasePlugin- {- }-}+}\ No newline at end of filediff --git a/src/Plugins/ExchangeRate.McExchange/McExchangeRateProvider.cs b/src/Plugins/ExchangeRate.McExchange/McExchangeRateProvider.csindex 482004eea..5f3a84f92 100644--- a/src/Plugins/ExchangeRate.McExchange/McExchangeRateProvider.cs+++ b/src/Plugins/ExchangeRate.McExchange/McExchangeRateProvider.cs@@ -2,55 +2,51 @@using Grand.SharedKernel;using System.Net.Http;-namespace ExchangeRate.McExchange-{- public class McExchangeRateProvider : IExchangeRateProvider- {- private readonly IHttpClientFactory _httpClientFactory;+namespace ExchangeRate.McExchange;- private readonly IDictionary<string, IRateProvider> _providers;+public class McExchangeRateProvider : IExchangeRateProvider+{+ private readonly IHttpClientFactory _httpClientFactory;- public McExchangeRateProvider(IHttpClientFactory httpClientFactory)- {- _httpClientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory));+ private readonly IDictionary<string, IRateProvider> _providers;- _providers = new Dictionary<string, IRateProvider> {- {"eur", new EcbExchange(_httpClientFactory)},- {"pln", new NbpExchange(_httpClientFactory)}- };- }+ public McExchangeRateProvider(IHttpClientFactory httpClientFactory)+ {+ _httpClientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory));- public string ConfigurationUrl => "";+ _providers = new Dictionary<string, IRateProvider> {+ { "eur", new EcbExchange(_httpClientFactory) },+ { "pln", new NbpExchange(_httpClientFactory) }+ };+ }- public string SystemName => "CurrencyExchange.MoneyConverter";+ public string ConfigurationUrl => "";- public string FriendlyName => "Money converter exchange rate provider";+ public string SystemName => "CurrencyExchange.MoneyConverter";- public int Priority => 0;+ public string FriendlyName => "Money converter exchange rate provider";- public IList<string> LimitedToStores => new List<string>();+ public int Priority => 0;- public IList<string> LimitedToGroups => new List<string>();+ public IList<string> LimitedToStores => new List<string>();- /// <summary>- /// Gets currency live rates- /// </summary>- /// <param name="exchangeRateCurrencyCode">Exchange rate currency code</param>- /// <returns>Exchange rates</returns>- public Task<IList<Grand.Domain.Directory.ExchangeRate>> GetCurrencyLiveRates(string exchangeRateCurrencyCode)- {- if (string.IsNullOrEmpty(exchangeRateCurrencyCode))- throw new ArgumentNullException(nameof(exchangeRateCurrencyCode));+ public IList<string> LimitedToGroups => new List<string>();- exchangeRateCurrencyCode = exchangeRateCurrencyCode.ToLowerInvariant();+ /// <summary>+ /// Gets currency live rates+ /// </summary>+ /// <param name="exchangeRateCurrencyCode">Exchange rate currency code</param>+ /// <returns>Exchange rates</returns>+ public Task<IList<Grand.Domain.Directory.ExchangeRate>> GetCurrencyLiveRates(string exchangeRateCurrencyCode)+ {+ if (string.IsNullOrEmpty(exchangeRateCurrencyCode))+ throw new ArgumentNullException(nameof(exchangeRateCurrencyCode));- if (_providers.TryGetValue(exchangeRateCurrencyCode, out var provider))- {- return provider.GetCurrencyLiveRates();- }+ exchangeRateCurrencyCode = exchangeRateCurrencyCode.ToLowerInvariant();- throw new GrandException("You can use ECB (European central bank) exchange rate provider only when the primary exchange rate currency is set to EURO");- }+ if (_providers.TryGetValue(exchangeRateCurrencyCode, out var provider)) return provider.GetCurrencyLiveRates();+ throw new GrandException(+ "You can use ECB (European central bank) exchange rate provider only when the primary exchange rate currency is set to EURO");}-}+}\ No newline at end of filediff --git a/src/Plugins/ExchangeRate.McExchange/NbpExchange.cs b/src/Plugins/ExchangeRate.McExchange/NbpExchange.csindex 8d8787d15..0fcd922a8 100644--- a/src/Plugins/ExchangeRate.McExchange/NbpExchange.cs+++ b/src/Plugins/ExchangeRate.McExchange/NbpExchange.cs@@ -4,51 +4,53 @@ using System.Net.Http;using System.Net.Mime;using System.Xml;-namespace ExchangeRate.McExchange+namespace ExchangeRate.McExchange;++internal class NbpExchange : IRateProvider{- internal class NbpExchange : IRateProvider+ private readonly IHttpClientFactory _httpClientFactory;++ public NbpExchange(IHttpClientFactory httpClientFactory)+ {+ _httpClientFactory = httpClientFactory;+ }++ public async Task<IList<Grand.Domain.Directory.ExchangeRate>> GetCurrencyLiveRates(){- private readonly IHttpClientFactory _httpClientFactory;+ var currentDate = DateTime.Today.AddDays(-1);+ var httpClient = _httpClientFactory.CreateClient(Constant.DefaultHttpClientName);+ httpClient.DefaultRequestHeaders.Add("Accept", MediaTypeNames.Application.Xml);+ await using var response =+ await httpClient.GetStreamAsync(+ $"{Constant.NbpUrl}{currentDate.AddDays(-7):yyyy-MM-dd}/{currentDate:yyyy-MM-dd}");+ var document = new XmlDocument();+ document.Load(response);- public NbpExchange(IHttpClientFactory httpClientFactory)+ var node = document.SelectNodes("//EffectiveDate")+ .Cast<XmlElement>()+ .OrderByDescending(x => x.InnerText)+ .First();++ var updateDate = DateTime.ParseExact(node.InnerText, "yyyy-MM-dd", null);+ Debug.Assert(node.ParentNode != null, "node.ParentNode != null");+ var ratesNode = node.ParentNode.SelectSingleNode("Rates");++ var provider = new NumberFormatInfo {+ CurrencyDecimalSeparator = ".",+ NumberGroupSeparator = ""+ };++ var exchangeRates = new List<Grand.Domain.Directory.ExchangeRate>();+ foreach (XmlNode node2 in ratesNode.ChildNodes){- _httpClientFactory = httpClientFactory;+ var rate = double.Parse(node2.SelectSingleNode("Mid").InnerText, provider);+ exchangeRates.Add(new Grand.Domain.Directory.ExchangeRate {+ CurrencyCode = node2.SelectSingleNode("Code").InnerText,+ Rate = Math.Round(1 / rate, 4, MidpointRounding.AwayFromZero),+ UpdatedOn = updateDate+ });}- public async Task<IList<Grand.Domain.Directory.ExchangeRate>> GetCurrencyLiveRates()- {- var currentDate = DateTime.Today.AddDays(-1);- var httpClient = _httpClientFactory.CreateClient(Constant.DefaultHttpClientName);- httpClient.DefaultRequestHeaders.Add("Accept", MediaTypeNames.Application.Xml);- await using var response = await httpClient.GetStreamAsync($"{Constant.NbpUrl}{currentDate.AddDays(-7):yyyy-MM-dd}/{currentDate:yyyy-MM-dd}");- var document = new XmlDocument();- document.Load(response);-- var node = document.SelectNodes("//EffectiveDate")- .Cast<XmlElement>()- .OrderByDescending(x => x.InnerText)- .First();-- var updateDate = DateTime.ParseExact(node.InnerText, "yyyy-MM-dd", null);- Debug.Assert(node.ParentNode != null, "node.ParentNode != null");- var ratesNode = node.ParentNode.SelectSingleNode("Rates");-- var provider = new NumberFormatInfo {- CurrencyDecimalSeparator = ".",- NumberGroupSeparator = ""- };-- var exchangeRates = new List<Grand.Domain.Directory.ExchangeRate>();- foreach (XmlNode node2 in ratesNode.ChildNodes)- {- var rate = double.Parse(node2.SelectSingleNode("Mid").InnerText, provider);- exchangeRates.Add(new Grand.Domain.Directory.ExchangeRate {- CurrencyCode = node2.SelectSingleNode("Code").InnerText,- Rate = Math.Round(1 / rate, 4, MidpointRounding.AwayFromZero),- UpdatedOn = updateDate- });- }- return exchangeRates;- }+ return exchangeRates;}-}+}\ No newline at end of filediff --git a/src/Plugins/ExchangeRate.McExchange/StartupApplication.cs b/src/Plugins/ExchangeRate.McExchange/StartupApplication.csindex 9a7ba9062..128cd7968 100644--- a/src/Plugins/ExchangeRate.McExchange/StartupApplication.cs+++ b/src/Plugins/ExchangeRate.McExchange/StartupApplication.cs@@ -5,20 +5,20 @@ using Microsoft.AspNetCore.Hosting;using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;-namespace ExchangeRate.McExchange+namespace ExchangeRate.McExchange;++public class StartupApplication : IStartupApplication{- public class StartupApplication : IStartupApplication+ public void ConfigureServices(IServiceCollection services, IConfiguration configuration){- public void ConfigureServices(IServiceCollection services, IConfiguration configuration)- {- services.AddScoped<IExchangeRateProvider, McExchangeRateProvider>();- }+ services.AddScoped<IExchangeRateProvider, McExchangeRateProvider>();+ }- public int Priority => 10;- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)- {+ public int Priority => 10;- }- public bool BeforeConfigure => false;+ public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)+ {}-}++ public bool BeforeConfigure => false;+}\ No newline at end of filediff --git a/src/Plugins/Payments.BrainTree/Areas/Admin/Controllers/PaymentBrainTreeController.cs b/src/Plugins/Payments.BrainTree/Areas/Admin/Controllers/PaymentBrainTreeController.csindex 65d440e88..f02da02c5 100644--- a/src/Plugins/Payments.BrainTree/Areas/Admin/Controllers/PaymentBrainTreeController.cs+++ b/src/Plugins/Payments.BrainTree/Areas/Admin/Controllers/PaymentBrainTreeController.cs@@ -7,76 +7,74 @@ using Grand.Web.Common.Security.Authorization;using Microsoft.AspNetCore.Mvc;using Payments.BrainTree.Models;-namespace Payments.BrainTree.Areas.Admin.Controllers+namespace Payments.BrainTree.Areas.Admin.Controllers;++[AuthorizeAdmin]+[Area("Admin")]+[PermissionAuthorize(PermissionSystemName.PaymentMethods)]+public class PaymentBrainTreeController : BasePaymentController{- [AuthorizeAdmin]- [Area("Admin")]- [PermissionAuthorize(PermissionSystemName.PaymentMethods)]- public class PaymentBrainTreeController : BasePaymentController+ #region Ctor++ public PaymentBrainTreeController(ISettingService settingService,+ ITranslationService translationService,+ BrainTreePaymentSettings brainTreePaymentSettings){- #region Fields-- private readonly ISettingService _settingService;- private readonly ITranslationService _translationService;- private readonly BrainTreePaymentSettings _brainTreePaymentSettings;-- #endregion-- #region Ctor-- public PaymentBrainTreeController(ISettingService settingService,- ITranslationService translationService,- BrainTreePaymentSettings brainTreePaymentSettings)- {- _settingService = settingService;- _translationService = translationService;- _brainTreePaymentSettings = brainTreePaymentSettings;- }-- #endregion-- #region Methods-- public IActionResult Configure()- {- var model = new ConfigurationModel- {- Use3DS = _brainTreePaymentSettings.Use3DS,- UseSandBox = _brainTreePaymentSettings.UseSandBox,- PublicKey = _brainTreePaymentSettings.PublicKey,- PrivateKey = _brainTreePaymentSettings.PrivateKey,- MerchantId = _brainTreePaymentSettings.MerchantId,- AdditionalFee = _brainTreePaymentSettings.AdditionalFee,- AdditionalFeePercentage = _brainTreePaymentSettings.AdditionalFeePercentage,- DisplayOrder = _brainTreePaymentSettings.DisplayOrder- };-- return View(model);- }-- [HttpPost]- public async Task<IActionResult> Configure(ConfigurationModel model)- {- if (!ModelState.IsValid)- return Configure();-- //save settings- _brainTreePaymentSettings.Use3DS = model.Use3DS;- _brainTreePaymentSettings.UseSandBox = model.UseSandBox;- _brainTreePaymentSettings.PublicKey = model.PublicKey;- _brainTreePaymentSettings.PrivateKey = model.PrivateKey;- _brainTreePaymentSettings.MerchantId = model.MerchantId;- _brainTreePaymentSettings.AdditionalFee = model.AdditionalFee;- _brainTreePaymentSettings.AdditionalFeePercentage = model.AdditionalFeePercentage;- _brainTreePaymentSettings.DisplayOrder = model.DisplayOrder;-- await _settingService.SaveSetting(_brainTreePaymentSettings);-- Success(_translationService.GetResource("Admin.Plugins.Saved"));+ _settingService = settingService;+ _translationService = translationService;+ _brainTreePaymentSettings = brainTreePaymentSettings;+ }++ #endregion++ #region Fields+ private readonly ISettingService _settingService;+ private readonly ITranslationService _translationService;+ private readonly BrainTreePaymentSettings _brainTreePaymentSettings;++ #endregion++ #region Methods++ public IActionResult Configure()+ {+ var model = new ConfigurationModel {+ Use3DS = _brainTreePaymentSettings.Use3DS,+ UseSandBox = _brainTreePaymentSettings.UseSandBox,+ PublicKey = _brainTreePaymentSettings.PublicKey,+ PrivateKey = _brainTreePaymentSettings.PrivateKey,+ MerchantId = _brainTreePaymentSettings.MerchantId,+ AdditionalFee = _brainTreePaymentSettings.AdditionalFee,+ AdditionalFeePercentage = _brainTreePaymentSettings.AdditionalFeePercentage,+ DisplayOrder = _brainTreePaymentSettings.DisplayOrder+ };++ return View(model);+ }++ [HttpPost]+ public async Task<IActionResult> Configure(ConfigurationModel model)+ {+ if (!ModelState.IsValid)return Configure();- }- #endregion+ //save settings+ _brainTreePaymentSettings.Use3DS = model.Use3DS;+ _brainTreePaymentSettings.UseSandBox = model.UseSandBox;+ _brainTreePaymentSettings.PublicKey = model.PublicKey;+ _brainTreePaymentSettings.PrivateKey = model.PrivateKey;+ _brainTreePaymentSettings.MerchantId = model.MerchantId;+ _brainTreePaymentSettings.AdditionalFee = model.AdditionalFee;+ _brainTreePaymentSettings.AdditionalFeePercentage = model.AdditionalFeePercentage;+ _brainTreePaymentSettings.DisplayOrder = model.DisplayOrder;++ await _settingService.SaveSetting(_brainTreePaymentSettings);++ Success(_translationService.GetResource("Admin.Plugins.Saved"));++ return Configure();}++ #endregion}\ No newline at end of filediff --git a/src/Plugins/Payments.BrainTree/Areas/Admin/Views/PaymentBrainTree/Configure.cshtml b/src/Plugins/Payments.BrainTree/Areas/Admin/Views/PaymentBrainTree/Configure.cshtmlindex d48d9dfaf..e760990fc 100644--- a/src/Plugins/Payments.BrainTree/Areas/Admin/Views/PaymentBrainTree/Configure.cshtml+++ b/src/Plugins/Payments.BrainTree/Areas/Admin/Views/PaymentBrainTree/Configure.cshtml@@ -1,92 +1,91 @@@{Layout = "_ConfigurePlugin";}-@model ConfigurationModel-@using Payments.BrainTree.Models;-<input id="active-menu-item" type="hidden" value="/Admin/Payment/Methods" />+@model Payments.BrainTree.Models.ConfigurationModel+<input id="active-menu-item" type="hidden" value="/Admin/Payment/Methods"/><form asp-controller="PaymentBrainTree" asp-action="Configure" method="post">-+<div class="form-horizontal"><div class="form-body"><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="Use3DS" class="control-label" />+ <admin-label asp-for="Use3DS" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="Use3DS" />+ <admin-input asp-for="Use3DS"/><span asp-validation-for="Use3DS"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="UseSandBox" class="control-label" />+ <admin-label asp-for="UseSandBox" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="UseSandBox" />+ <admin-input asp-for="UseSandBox"/><span asp-validation-for="UseSandBox"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="MerchantId" class="control-label" />+ <admin-label asp-for="MerchantId" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="MerchantId" />+ <admin-input asp-for="MerchantId"/><span asp-validation-for="MerchantId"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="PrivateKey" class="control-label" />+ <admin-label asp-for="PrivateKey" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="PrivateKey" />+ <admin-input asp-for="PrivateKey"/><span asp-validation-for="PrivateKey"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="PublicKey" class="control-label" />+ <admin-label asp-for="PublicKey" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="PublicKey" />+ <admin-input asp-for="PublicKey"/><span asp-validation-for="PublicKey"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="AdditionalFee" class="control-label" />+ <admin-label asp-for="AdditionalFee" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="AdditionalFee" />+ <admin-input asp-for="AdditionalFee"/><span asp-validation-for="AdditionalFee"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="AdditionalFeePercentage" class="control-label" />+ <admin-label asp-for="AdditionalFeePercentage" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="AdditionalFeePercentage" />+ <admin-input asp-for="AdditionalFeePercentage"/><span asp-validation-for="AdditionalFeePercentage"></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" />+ <admin-label asp-for="DisplayOrder" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="DisplayOrder" />+ <admin-input asp-for="DisplayOrder"/><span asp-validation-for="DisplayOrder"></span></div></div><div class="form-actions"><div class="row"><div class="offset-md-3 offset-sm-3 col-md-9 col-sm-9">- <input type="submit" name="save" class="btn green" value="@Loc["Admin.Common.Save"]" />+ <input type="submit" name="save" class="btn green" value="@Loc["Admin.Common.Save"]"/></div></div></div></div></div>-</form>+</form>\ No newline at end of filediff --git a/src/Plugins/Payments.BrainTree/Areas/Admin/Views/_ViewImports.cshtml b/src/Plugins/Payments.BrainTree/Areas/Admin/Views/_ViewImports.cshtmlindex 2fb08c043..fb3b84aa9 100644--- a/src/Plugins/Payments.BrainTree/Areas/Admin/Views/_ViewImports.cshtml+++ b/src/Plugins/Payments.BrainTree/Areas/Admin/Views/_ViewImports.cshtml@@ -4,5 +4,6 @@@using Microsoft.AspNetCore.Mvc.ViewFeatures@using Grand.Infrastructure.Extensions+@using Grand.Web.Common.Localization-@inject Grand.Web.Common.Localization.LocService Loc+@inject LocService Loc\ No newline at end of filediff --git a/src/Plugins/Payments.BrainTree/BrainTreeDefaults.cs b/src/Plugins/Payments.BrainTree/BrainTreeDefaults.csindex 5f51239a3..0019fa65e 100644--- a/src/Plugins/Payments.BrainTree/BrainTreeDefaults.cs+++ b/src/Plugins/Payments.BrainTree/BrainTreeDefaults.cs@@ -1,9 +1,8 @@-namespace Payments.BrainTree+namespace Payments.BrainTree;++public static class BrainTreeDefaults{- public static class BrainTreeDefaults- {- public const string ProviderSystemName = "Payments.BrainTree";- public const string FriendlyName = "Payments.BrainTree.FriendlyName";- public const string ConfigurationUrl = "/Admin/PaymentBrainTree/Configure";- }-}+ public const string ProviderSystemName = "Payments.BrainTree";+ public const string FriendlyName = "Payments.BrainTree.FriendlyName";+ public const string ConfigurationUrl = "/Admin/PaymentBrainTree/Configure";+}\ No newline at end of filediff --git a/src/Plugins/Payments.BrainTree/BrainTreePaymentPlugin.cs b/src/Plugins/Payments.BrainTree/BrainTreePaymentPlugin.csindex a3cb38c4a..bc30ffa01 100644--- a/src/Plugins/Payments.BrainTree/BrainTreePaymentPlugin.cs+++ b/src/Plugins/Payments.BrainTree/BrainTreePaymentPlugin.cs@@ -3,100 +3,128 @@ using Grand.Business.Core.Interfaces.Common.Configuration;using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Infrastructure.Plugins;-namespace Payments.BrainTree+namespace Payments.BrainTree;++public class BrainTreePaymentPlugin : BasePlugin, IPlugin{- public class BrainTreePaymentPlugin : BasePlugin, IPlugin+ #region Ctor++ public BrainTreePaymentPlugin(+ ISettingService settingService,+ ILanguageService languageService,+ ITranslationService translationService)+ {+ _settingService = settingService;+ _translationService = translationService;+ _languageService = languageService;+ }++ #endregion++ #region Fields++ private readonly ITranslationService _translationService;+ private readonly ILanguageService _languageService;+ private readonly ISettingService _settingService;++ #endregion++ #region Methods++ public override string ConfigurationUrl()+ {+ return BrainTreeDefaults.ConfigurationUrl;+ }++ public override async Task Install(){- #region Fields-- private readonly ITranslationService _translationService;- private readonly ILanguageService _languageService;- private readonly ISettingService _settingService;-- #endregion-- #region Ctor-- public BrainTreePaymentPlugin(- ISettingService settingService,- ILanguageService languageService,- ITranslationService translationService)- {- _settingService = settingService;- _translationService = translationService;- _languageService = languageService;- }-- #endregion-- #region Methods--- public override string ConfigurationUrl()- {- return BrainTreeDefaults.ConfigurationUrl;- }-- public override async Task Install()- {- //settings- var settings = new BrainTreePaymentSettings- {- UseSandBox = true,- MerchantId = "",- PrivateKey = "",- PublicKey = ""- };- await _settingService.SaveSetting(settings);-- //locales- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Payments.BrainTree.FriendlyName", "BrainTree payment");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.Use3DS", "Use the 3D secure");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.Use3DS.Hint", "Check to enable the 3D secure integration");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.UseSandbox", "Use Sandbox");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.UseSandbox.Hint", "Check to enable Sandbox (testing environment).");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.MerchantId", "Merchant ID");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.MerchantId.Hint", "Enter Merchant ID");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.PublicKey", "Public Key");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.PublicKey.Hint", "Enter Public key");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.PrivateKey", "Private Key");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.PrivateKey.Hint", "Enter Private key");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.AdditionalFee", "Additional fee");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.AdditionalFee.Hint", "Enter additional fee to charge your customers.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.AdditionalFeePercentage", "Additional fee. Use percentage");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.DisplayOrder", "Display order");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.AdditionalFeePercentage.Hint", "Determines whether to apply a percentage additional fee to the order total. If not enabled, a fixed value is used.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payments.BrainTree.PaymentMethodDescription", "Pay by credit / debit card");--- await base.Install();- }-- public override async Task Uninstall()- {- //settings- await _settingService.DeleteSetting<BrainTreePaymentSettings>();-- //locales- await this.DeletePluginTranslationResource(_translationService, _languageService, "Payments.BrainTree.FriendlyName");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.UseSandbox");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.UseSandbox.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.MerchantId");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.MerchantId.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.PublicKey");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.PublicKey.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.PrivateKey");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.PrivateKey.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.AdditionalFee");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.AdditionalFee.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.AdditionalFeePercentage");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payments.BrainTree.Fields.AdditionalFeePercentage.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payments.BrainTree.PaymentMethodDescription");-- await base.Uninstall();- }-- #endregion+ //settings+ var settings = new BrainTreePaymentSettings {+ UseSandBox = true,+ MerchantId = "",+ PrivateKey = "",+ PublicKey = ""+ };+ await _settingService.SaveSetting(settings);++ //locales+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Payments.BrainTree.FriendlyName", "BrainTree payment");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.Use3DS", "Use the 3D secure");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.Use3DS.Hint", "Check to enable the 3D secure integration");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.UseSandbox", "Use Sandbox");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.UseSandbox.Hint", "Check to enable Sandbox (testing environment).");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.MerchantId", "Merchant ID");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.MerchantId.Hint", "Enter Merchant ID");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.PublicKey", "Public Key");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.PublicKey.Hint", "Enter Public key");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.PrivateKey", "Private Key");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.PrivateKey.Hint", "Enter Private key");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.AdditionalFee", "Additional fee");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.AdditionalFee.Hint", "Enter additional fee to charge your customers.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.AdditionalFeePercentage", "Additional fee. Use percentage");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.DisplayOrder", "Display order");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.AdditionalFeePercentage.Hint",+ "Determines whether to apply a percentage additional fee to the order total. If not enabled, a fixed value is used.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.PaymentMethodDescription", "Pay by credit / debit card");+++ await base.Install();+ }+ public override async Task Uninstall()+ {+ //settings+ await _settingService.DeleteSetting<BrainTreePaymentSettings>();++ //locales+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Payments.BrainTree.FriendlyName");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.UseSandbox");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.UseSandbox.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.MerchantId");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.MerchantId.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.PublicKey");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.PublicKey.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.PrivateKey");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.PrivateKey.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.AdditionalFee");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.AdditionalFee.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.AdditionalFeePercentage");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.Fields.AdditionalFeePercentage.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payments.BrainTree.PaymentMethodDescription");++ await base.Uninstall();}-}++ #endregion+}\ No newline at end of filediff --git a/src/Plugins/Payments.BrainTree/BrainTreePaymentProvider.cs b/src/Plugins/Payments.BrainTree/BrainTreePaymentProvider.csindex 6d894cd1a..1fa351cfd 100644--- a/src/Plugins/Payments.BrainTree/BrainTreePaymentProvider.cs+++ b/src/Plugins/Payments.BrainTree/BrainTreePaymentProvider.cs@@ -2,10 +2,10 @@using Grand.Business.Core.Enums.Checkout;using Grand.Business.Core.Interfaces.Checkout.Orders;using Grand.Business.Core.Interfaces.Checkout.Payments;-using Grand.Business.Core.Utilities.Checkout;using Grand.Business.Core.Interfaces.Common.Directory;using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Business.Core.Interfaces.Customers;+using Grand.Business.Core.Utilities.Checkout;using Grand.Domain.Orders;using Grand.Domain.Payments;using Grand.Infrastructure;@@ -14,360 +14,363 @@ using Microsoft.Extensions.DependencyInjection;using Microsoft.Extensions.Primitives;using Payments.BrainTree.Models;using Payments.BrainTree.Validators;+using Environment = Braintree.Environment;+using TransactionStatus = Grand.Domain.Payments.TransactionStatus;++namespace Payments.BrainTree;-namespace Payments.BrainTree+public class BrainTreePaymentProvider : IPaymentProvider{- public class BrainTreePaymentProvider : IPaymentProvider+ private readonly BrainTreePaymentSettings _brainTreePaymentSettings;+ private readonly ICustomerService _customerService;+ private readonly IHttpContextAccessor _httpContextAccessor;+ private readonly ITranslationService _translationService;++ public BrainTreePaymentProvider(+ ITranslationService translationService,+ ICustomerService customerService,+ IHttpContextAccessor httpContextAccessor,+ BrainTreePaymentSettings brainTreePaymentSettings){- private readonly ITranslationService _translationService;- private readonly ICustomerService _customerService;- private readonly IHttpContextAccessor _httpContextAccessor;- private readonly BrainTreePaymentSettings _brainTreePaymentSettings;-- public BrainTreePaymentProvider(- ITranslationService translationService,- ICustomerService customerService,- IHttpContextAccessor httpContextAccessor,- BrainTreePaymentSettings brainTreePaymentSettings)- {- _translationService = translationService;- _customerService = customerService;- _httpContextAccessor = httpContextAccessor;- _brainTreePaymentSettings = brainTreePaymentSettings;- }+ _translationService = translationService;+ _customerService = customerService;+ _httpContextAccessor = httpContextAccessor;+ _brainTreePaymentSettings = brainTreePaymentSettings;+ }- public Task<string> GetControllerRouteName()- {- return Task.FromResult("Plugin.PaymentBrainTree");- }+ public Task<string> GetControllerRouteName()+ {+ return Task.FromResult("Plugin.PaymentBrainTree");+ }- /// <summary>- /// Init a process a payment transaction- /// </summary>- /// <returns>Payment transaction</returns>- public async Task<PaymentTransaction> InitPaymentTransaction()- {- return await Task.FromResult<PaymentTransaction>(null);- }+ /// <summary>+ /// Init a process a payment transaction+ /// </summary>+ /// <returns>Payment transaction</returns>+ public async Task<PaymentTransaction> InitPaymentTransaction()+ {+ return await Task.FromResult<PaymentTransaction>(null);+ }- public async Task<IList<string>> ValidatePaymentForm(IDictionary<string, string> model)- {- var warnings = new List<string>();- //validate- var validator = new PaymentInfoValidator(_brainTreePaymentSettings, _translationService);- var paymentInfoModel = new PaymentInfoModel();- if (model.TryGetValue("CardholderName", out var cardholderName))- paymentInfoModel.CardholderName = cardholderName;- if (model.TryGetValue("CardNumber", out var cardNumber))- paymentInfoModel.CardNumber = cardNumber;- if (model.TryGetValue("CardCode", out var cardCode))- paymentInfoModel.CardCode = cardCode;- if (model.TryGetValue("ExpireMonth", out var expireMonth))- paymentInfoModel.ExpireMonth = expireMonth;- if (model.TryGetValue("ExpireYear", out var expireYear))- paymentInfoModel.ExpireYear = expireYear;- if (model.TryGetValue("CardNonce", out var cardNonce))- paymentInfoModel.CardNonce = cardNonce;-- var validationResult = await validator.ValidateAsync(paymentInfoModel);- if (validationResult.IsValid) return await Task.FromResult(warnings);- warnings.AddRange(validationResult.Errors.Select(error => error.ErrorMessage));- return await Task.FromResult(warnings);- }+ public async Task<IList<string>> ValidatePaymentForm(IDictionary<string, string> model)+ {+ var warnings = new List<string>();+ //validate+ var validator = new PaymentInfoValidator(_brainTreePaymentSettings, _translationService);+ var paymentInfoModel = new PaymentInfoModel();+ if (model.TryGetValue("CardholderName", out var cardholderName))+ paymentInfoModel.CardholderName = cardholderName;+ if (model.TryGetValue("CardNumber", out var cardNumber))+ paymentInfoModel.CardNumber = cardNumber;+ if (model.TryGetValue("CardCode", out var cardCode))+ paymentInfoModel.CardCode = cardCode;+ if (model.TryGetValue("ExpireMonth", out var expireMonth))+ paymentInfoModel.ExpireMonth = expireMonth;+ if (model.TryGetValue("ExpireYear", out var expireYear))+ paymentInfoModel.ExpireYear = expireYear;+ if (model.TryGetValue("CardNonce", out var cardNonce))+ paymentInfoModel.CardNonce = cardNonce;++ var validationResult = await validator.ValidateAsync(paymentInfoModel);+ if (validationResult.IsValid) return await Task.FromResult(warnings);+ warnings.AddRange(validationResult.Errors.Select(error => error.ErrorMessage));+ return await Task.FromResult(warnings);+ }- public async Task<PaymentTransaction> SavePaymentInfo(IDictionary<string, string> model)- {- if (model.TryGetValue("CardNonce", out var cardNonce) && !StringValues.IsNullOrEmpty(cardNonce))- _httpContextAccessor.HttpContext!.Session.SetString("CardNonce", cardNonce);+ public async Task<PaymentTransaction> SavePaymentInfo(IDictionary<string, string> model)+ {+ if (model.TryGetValue("CardNonce", out var cardNonce) && !StringValues.IsNullOrEmpty(cardNonce))+ _httpContextAccessor.HttpContext!.Session.SetString("CardNonce", cardNonce);- if (model.TryGetValue("CardholderName", out var cardholderName) &&- !StringValues.IsNullOrEmpty(cardholderName))- _httpContextAccessor.HttpContext!.Session.SetString("CardholderName", cardholderName);+ if (model.TryGetValue("CardholderName", out var cardholderName) &&+ !StringValues.IsNullOrEmpty(cardholderName))+ _httpContextAccessor.HttpContext!.Session.SetString("CardholderName", cardholderName);- if (model.TryGetValue("CardNumber", out var cardNumber) && !StringValues.IsNullOrEmpty(cardNumber))- _httpContextAccessor.HttpContext!.Session.SetString("CardNumber", cardNumber);+ if (model.TryGetValue("CardNumber", out var cardNumber) && !StringValues.IsNullOrEmpty(cardNumber))+ _httpContextAccessor.HttpContext!.Session.SetString("CardNumber", cardNumber);- if (model.TryGetValue("ExpireMonth", out var expireMonth) && !StringValues.IsNullOrEmpty(expireMonth))- _httpContextAccessor.HttpContext!.Session.SetString("ExpireMonth", expireMonth);+ if (model.TryGetValue("ExpireMonth", out var expireMonth) && !StringValues.IsNullOrEmpty(expireMonth))+ _httpContextAccessor.HttpContext!.Session.SetString("ExpireMonth", expireMonth);- if (model.TryGetValue("ExpireYear", out var expireYear) && !StringValues.IsNullOrEmpty(expireYear))- _httpContextAccessor.HttpContext!.Session.SetString("ExpireYear", expireYear);+ if (model.TryGetValue("ExpireYear", out var expireYear) && !StringValues.IsNullOrEmpty(expireYear))+ _httpContextAccessor.HttpContext!.Session.SetString("ExpireYear", expireYear);- if (model.TryGetValue("CardCode", out var creditCardCvv2) && !StringValues.IsNullOrEmpty(creditCardCvv2))- _httpContextAccessor.HttpContext!.Session.SetString("CardCode", creditCardCvv2);+ if (model.TryGetValue("CardCode", out var creditCardCvv2) && !StringValues.IsNullOrEmpty(creditCardCvv2))+ _httpContextAccessor.HttpContext!.Session.SetString("CardCode", creditCardCvv2);- return await Task.FromResult<PaymentTransaction>(null);- }+ return await Task.FromResult<PaymentTransaction>(null);+ }- /// <summary>- /// Process a payment- /// </summary>- /// <returns>Process payment result</returns>- public async Task<ProcessPaymentResult> ProcessPayment(PaymentTransaction paymentTransaction)+ /// <summary>+ /// Process a payment+ /// </summary>+ /// <returns>Process payment result</returns>+ public async Task<ProcessPaymentResult> ProcessPayment(PaymentTransaction paymentTransaction)+ {+ var processPaymentResult = new ProcessPaymentResult();++ //get customer+ var customer = await _customerService.GetCustomerById(paymentTransaction.CustomerId);++ //get settings+ var useSandBox = _brainTreePaymentSettings.UseSandBox;+ var merchantId = _brainTreePaymentSettings.MerchantId;+ var publicKey = _brainTreePaymentSettings.PublicKey;+ var privateKey = _brainTreePaymentSettings.PrivateKey;++ //new gateway+ var gateway = new BraintreeGateway {+ Environment = useSandBox ? Environment.SANDBOX : Environment.PRODUCTION,+ MerchantId = merchantId,+ PublicKey = publicKey,+ PrivateKey = privateKey+ };++ //new transaction request+ var transactionRequest = new TransactionRequest {+ Amount = Convert.ToDecimal(paymentTransaction.TransactionAmount)+ };++ if (_brainTreePaymentSettings.Use3DS){- var processPaymentResult = new ProcessPaymentResult();-- //get customer- var customer = await _customerService.GetCustomerById(paymentTransaction.CustomerId);-- //get settings- var useSandBox = _brainTreePaymentSettings.UseSandBox;- var merchantId = _brainTreePaymentSettings.MerchantId;- var publicKey = _brainTreePaymentSettings.PublicKey;- var privateKey = _brainTreePaymentSettings.PrivateKey;-- //new gateway- var gateway = new BraintreeGateway {- Environment = useSandBox ? Braintree.Environment.SANDBOX : Braintree.Environment.PRODUCTION,- MerchantId = merchantId,- PublicKey = publicKey,- PrivateKey = privateKey- };-- //new transaction request- var transactionRequest = new TransactionRequest {- Amount = Convert.ToDecimal(paymentTransaction.TransactionAmount)- };-- if (_brainTreePaymentSettings.Use3DS)- {- transactionRequest.PaymentMethodNonce =- _httpContextAccessor.HttpContext!.Session.GetString("CardNonce")!;- }- else- {- //transaction credit card request- var transactionCreditCardRequest = new TransactionCreditCardRequest {- Number = _httpContextAccessor.HttpContext!.Session.GetString("CardNumber")!,- CVV = _httpContextAccessor.HttpContext.Session.GetString("CardCode")!,- ExpirationDate = _httpContextAccessor.HttpContext.Session.GetString("ExpireMonth")! + "/" +- _httpContextAccessor.HttpContext.Session.GetString("ExpireYear")!- };- transactionRequest.CreditCard = transactionCreditCardRequest;- }-- //address request- var addressRequest = new AddressRequest {- FirstName = customer.BillingAddress.FirstName,- LastName = customer.BillingAddress.LastName,- StreetAddress = customer.BillingAddress.Address1,- PostalCode = customer.BillingAddress.ZipPostalCode- };- transactionRequest.BillingAddress = addressRequest;-- //transaction options request- var transactionOptionsRequest = new TransactionOptionsRequest {- SubmitForSettlement = true- };- transactionRequest.Options = transactionOptionsRequest;-- //sending a request- var result = await gateway.Transaction.SaleAsync(transactionRequest);-- //result- if (result.IsSuccess())- {- processPaymentResult.PaidAmount = paymentTransaction.TransactionAmount;- processPaymentResult.NewPaymentTransactionStatus = Grand.Domain.Payments.TransactionStatus.Paid;- }- else- {- processPaymentResult.AddError("Error processing payment." + result.Message);- }-- return processPaymentResult;+ transactionRequest.PaymentMethodNonce =+ _httpContextAccessor.HttpContext!.Session.GetString("CardNonce")!;}-- /// <summary>- /// Post process payment- /// </summary>- public Task PostProcessPayment(PaymentTransaction paymentTransaction)+ else{- //nothing- return Task.CompletedTask;+ //transaction credit card request+ var transactionCreditCardRequest = new TransactionCreditCardRequest {+ Number = _httpContextAccessor.HttpContext!.Session.GetString("CardNumber")!,+ CVV = _httpContextAccessor.HttpContext.Session.GetString("CardCode")!,+ ExpirationDate = _httpContextAccessor.HttpContext.Session.GetString("ExpireMonth")! + "/" ++ _httpContextAccessor.HttpContext.Session.GetString("ExpireYear")!+ };+ transactionRequest.CreditCard = transactionCreditCardRequest;}- /// <summary>- /// Post redirect payment (used by payment gateways that redirecting to a another URL)- /// </summary>- /// <param name="paymentTransaction">Payment transaction</param>- public Task PostRedirectPayment(PaymentTransaction paymentTransaction)+ //address request+ var addressRequest = new AddressRequest {+ FirstName = customer.BillingAddress.FirstName,+ LastName = customer.BillingAddress.LastName,+ StreetAddress = customer.BillingAddress.Address1,+ PostalCode = customer.BillingAddress.ZipPostalCode+ };+ transactionRequest.BillingAddress = addressRequest;++ //transaction options request+ var transactionOptionsRequest = new TransactionOptionsRequest {+ SubmitForSettlement = true+ };+ transactionRequest.Options = transactionOptionsRequest;++ //sending a request+ var result = await gateway.Transaction.SaleAsync(transactionRequest);++ //result+ if (result.IsSuccess()){- //nothing- return Task.CompletedTask;+ processPaymentResult.PaidAmount = paymentTransaction.TransactionAmount;+ processPaymentResult.NewPaymentTransactionStatus = TransactionStatus.Paid;}-- /// <summary>- /// Returns a value indicating whether payment method should be hidden during checkout- /// </summary>- /// <param name="cart">Shopping cart</param>- /// <returns>true - hide; false - display.</returns>- public async Task<bool> HidePaymentMethod(IList<ShoppingCartItem> cart)+ else{- //you can put any logic here- //for example, hide this payment method if all products in the cart are downloadable- //or hide this payment method if current customer is from certain country- //return false;- return await Task.FromResult(false);+ processPaymentResult.AddError("Error processing payment." + result.Message);}- /// <summary>- /// Gets additional handling fee- /// </summary>- /// <param name="cart">Shopping cart</param>- /// <returns>Additional handling fee</returns>- public async Task<double> GetAdditionalHandlingFee(IList<ShoppingCartItem> cart)- {- if (_brainTreePaymentSettings.AdditionalFee <= 0)- return _brainTreePaymentSettings.AdditionalFee;-- double result;- if (_brainTreePaymentSettings.AdditionalFeePercentage)- {- //percentage- var orderTotalCalculationService = _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<IOrderCalculationService>();- var subtotal = await orderTotalCalculationService.GetShoppingCartSubTotal(cart, true);- result = (float)subtotal.subTotalWithDiscount *- (float)_brainTreePaymentSettings.AdditionalFee / 100f;- }- else- {- //fixed value- result = _brainTreePaymentSettings.AdditionalFee;- }-- if (!(result > 0)) return await Task.FromResult(result);- var currencyService = _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<ICurrencyService>();- var workContext = _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<IWorkContext>();- result = await currencyService.ConvertFromPrimaryStoreCurrency(result, workContext.WorkingCurrency);-- //return result;- return await Task.FromResult(result);- }+ return processPaymentResult;+ }- /// <summary>- /// Captures payment- /// </summary>- /// <returns>Capture payment result</returns>- public async Task<CapturePaymentResult> Capture(PaymentTransaction paymentTransaction)- {- var result = new CapturePaymentResult();- result.AddError("Capture method not supported");- return await Task.FromResult(result);- }+ /// <summary>+ /// Post process payment+ /// </summary>+ public Task PostProcessPayment(PaymentTransaction paymentTransaction)+ {+ //nothing+ return Task.CompletedTask;+ }- /// <summary>- /// Refunds a payment- /// </summary>- /// <param name="refundPaymentRequest">Request</param>- /// <returns>Result</returns>- public async Task<RefundPaymentResult> Refund(RefundPaymentRequest refundPaymentRequest)- {- var result = new RefundPaymentResult();- result.AddError("Refund method not supported");- return await Task.FromResult(result);- }+ /// <summary>+ /// Post redirect payment (used by payment gateways that redirecting to a another URL)+ /// </summary>+ /// <param name="paymentTransaction">Payment transaction</param>+ public Task PostRedirectPayment(PaymentTransaction paymentTransaction)+ {+ //nothing+ return Task.CompletedTask;+ }++ /// <summary>+ /// Returns a value indicating whether payment method should be hidden during checkout+ /// </summary>+ /// <param name="cart">Shopping cart</param>+ /// <returns>true - hide; false - display.</returns>+ public async Task<bool> HidePaymentMethod(IList<ShoppingCartItem> cart)+ {+ //you can put any logic here+ //for example, hide this payment method if all products in the cart are downloadable+ //or hide this payment method if current customer is from certain country+ //return false;+ return await Task.FromResult(false);+ }++ /// <summary>+ /// Gets additional handling fee+ /// </summary>+ /// <param name="cart">Shopping cart</param>+ /// <returns>Additional handling fee</returns>+ public async Task<double> GetAdditionalHandlingFee(IList<ShoppingCartItem> cart)+ {+ if (_brainTreePaymentSettings.AdditionalFee <= 0)+ return _brainTreePaymentSettings.AdditionalFee;- /// <summary>- /// Voids a payment- /// </summary>- /// <returns>Result</returns>- public async Task<VoidPaymentResult> Void(PaymentTransaction paymentTransaction)+ double result;+ if (_brainTreePaymentSettings.AdditionalFeePercentage){- var result = new VoidPaymentResult();- result.AddError("Void method not supported");- return await Task.FromResult(result);+ //percentage+ var orderTotalCalculationService = _httpContextAccessor.HttpContext!.RequestServices+ .GetRequiredService<IOrderCalculationService>();+ var subtotal = await orderTotalCalculationService.GetShoppingCartSubTotal(cart, true);+ result = (float)subtotal.subTotalWithDiscount *+ (float)_brainTreePaymentSettings.AdditionalFee / 100f;}-- /// <summary>- /// Cancel a payment- /// </summary>- /// <returns>Result</returns>- public Task CancelPayment(PaymentTransaction paymentTransaction)+ else{- return Task.CompletedTask;+ //fixed value+ result = _brainTreePaymentSettings.AdditionalFee;}- /// <summary>- /// Gets a value indicating whether customers can complete a payment after order is placed but not completed (for redirection payment methods)- /// </summary>- /// <param name="paymentTransaction"></param>- /// <returns>Result</returns>- public async Task<bool> CanRePostRedirectPayment(PaymentTransaction paymentTransaction)- {- ArgumentNullException.ThrowIfNull(paymentTransaction);+ if (!(result > 0)) return await Task.FromResult(result);+ var currencyService = _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<ICurrencyService>();+ var workContext = _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<IWorkContext>();+ result = await currencyService.ConvertFromPrimaryStoreCurrency(result, workContext.WorkingCurrency);- //it's not a redirection payment method. So we always return false- return await Task.FromResult(false);- }+ //return result;+ return await Task.FromResult(result);+ }+ /// <summary>+ /// Captures payment+ /// </summary>+ /// <returns>Capture payment result</returns>+ public async Task<CapturePaymentResult> Capture(PaymentTransaction paymentTransaction)+ {+ var result = new CapturePaymentResult();+ result.AddError("Capture method not supported");+ return await Task.FromResult(result);+ }- /// <summary>- /// Gets a value indicating whether capture is supported- /// </summary>- public async Task<bool> SupportCapture()- {- return await Task.FromResult(false);- }+ /// <summary>+ /// Refunds a payment+ /// </summary>+ /// <param name="refundPaymentRequest">Request</param>+ /// <returns>Result</returns>+ public async Task<RefundPaymentResult> Refund(RefundPaymentRequest refundPaymentRequest)+ {+ var result = new RefundPaymentResult();+ result.AddError("Refund method not supported");+ return await Task.FromResult(result);+ }- /// <summary>- /// Gets a value indicating whether partial refund is supported- /// </summary>- public async Task<bool> SupportPartiallyRefund()- {- return await Task.FromResult(false);- }+ /// <summary>+ /// Voids a payment+ /// </summary>+ /// <returns>Result</returns>+ public async Task<VoidPaymentResult> Void(PaymentTransaction paymentTransaction)+ {+ var result = new VoidPaymentResult();+ result.AddError("Void method not supported");+ return await Task.FromResult(result);+ }- /// <summary>- /// Gets a value indicating whether refund is supported- /// </summary>- public async Task<bool> SupportRefund()- {- return await Task.FromResult(false);- }+ /// <summary>+ /// Cancel a payment+ /// </summary>+ /// <returns>Result</returns>+ public Task CancelPayment(PaymentTransaction paymentTransaction)+ {+ return Task.CompletedTask;+ }- /// <summary>- /// Gets a value indicating whether void is supported- /// </summary>- public async Task<bool> SupportVoid()- {- return await Task.FromResult(false);- }+ /// <summary>+ /// Gets a value indicating whether customers can complete a payment after order is placed but not completed (for+ /// redirection payment methods)+ /// </summary>+ /// <param name="paymentTransaction"></param>+ /// <returns>Result</returns>+ public async Task<bool> CanRePostRedirectPayment(PaymentTransaction paymentTransaction)+ {+ ArgumentNullException.ThrowIfNull(paymentTransaction);- /// <summary>- /// Gets a payment method type- /// </summary>- public PaymentMethodType PaymentMethodType => PaymentMethodType.Standard;+ //it's not a redirection payment method. So we always return false+ return await Task.FromResult(false);+ }- public string ConfigurationUrl => BrainTreeDefaults.ConfigurationUrl;- public string SystemName => BrainTreeDefaults.ProviderSystemName;+ /// <summary>+ /// Gets a value indicating whether capture is supported+ /// </summary>+ public async Task<bool> SupportCapture()+ {+ return await Task.FromResult(false);+ }- public string FriendlyName => _translationService.GetResource(BrainTreeDefaults.FriendlyName);+ /// <summary>+ /// Gets a value indicating whether partial refund is supported+ /// </summary>+ public async Task<bool> SupportPartiallyRefund()+ {+ return await Task.FromResult(false);+ }- public int Priority => _brainTreePaymentSettings.DisplayOrder;+ /// <summary>+ /// Gets a value indicating whether refund is supported+ /// </summary>+ public async Task<bool> SupportRefund()+ {+ return await Task.FromResult(false);+ }- public IList<string> LimitedToStores => new List<string>();+ /// <summary>+ /// Gets a value indicating whether void is supported+ /// </summary>+ public async Task<bool> SupportVoid()+ {+ return await Task.FromResult(false);+ }- public IList<string> LimitedToGroups => new List<string>();+ /// <summary>+ /// Gets a payment method type+ /// </summary>+ public PaymentMethodType PaymentMethodType => PaymentMethodType.Standard;- /// <summary>- /// Gets a value indicating whether we should display a payment information page for this plugin- /// </summary>- public async Task<bool> SkipPaymentInfo()- {- return await Task.FromResult(false);- }+ public string ConfigurationUrl => BrainTreeDefaults.ConfigurationUrl;- /// <summary>- /// Gets a payment method description that will be displayed on checkout pages in the public store- /// </summary>- public async Task<string> Description()- {- return await Task.FromResult(- _translationService.GetResource("Plugins.Payments.BrainTree.PaymentMethodDescription"));- }+ public string SystemName => BrainTreeDefaults.ProviderSystemName;++ public string FriendlyName => _translationService.GetResource(BrainTreeDefaults.FriendlyName);++ public int Priority => _brainTreePaymentSettings.DisplayOrder;++ public IList<string> LimitedToStores => new List<string>();++ public IList<string> LimitedToGroups => new List<string>();- public string LogoURL => "/Plugins/Payments.BrainTree/logo.jpg";+ /// <summary>+ /// Gets a value indicating whether we should display a payment information page for this plugin+ /// </summary>+ public async Task<bool> SkipPaymentInfo()+ {+ return await Task.FromResult(false);}++ /// <summary>+ /// Gets a payment method description that will be displayed on checkout pages in the public store+ /// </summary>+ public async Task<string> Description()+ {+ return await Task.FromResult(+ _translationService.GetResource("Plugins.Payments.BrainTree.PaymentMethodDescription"));+ }++ public string LogoURL => "/Plugins/Payments.BrainTree/logo.jpg";}\ No newline at end of filediff --git a/src/Plugins/Payments.BrainTree/BrainTreePaymentSettings.cs b/src/Plugins/Payments.BrainTree/BrainTreePaymentSettings.csindex 7df49555e..d7bbcd201 100644--- a/src/Plugins/Payments.BrainTree/BrainTreePaymentSettings.cs+++ b/src/Plugins/Payments.BrainTree/BrainTreePaymentSettings.cs@@ -1,16 +1,15 @@using Grand.Domain.Configuration;-namespace Payments.BrainTree+namespace Payments.BrainTree;++public class BrainTreePaymentSettings : ISettings{- public class BrainTreePaymentSettings : ISettings- {- public bool Use3DS { get; set; }- public bool UseSandBox { get; set; }- public string MerchantId { get; set; }- public string PublicKey { get; set; }- public string PrivateKey { get; set; }- public double AdditionalFee { get; set; }- public bool AdditionalFeePercentage { get; set; }- public int DisplayOrder { get; set; }- }-}+ public bool Use3DS { get; set; }+ public bool UseSandBox { get; set; }+ public string MerchantId { get; set; }+ public string PublicKey { get; set; }+ public string PrivateKey { get; set; }+ public double AdditionalFee { get; set; }+ public bool AdditionalFeePercentage { get; set; }+ public int DisplayOrder { get; set; }+}\ No newline at end of filediff --git a/src/Plugins/Payments.BrainTree/BrainTreeWidgetProvider.cs b/src/Plugins/Payments.BrainTree/BrainTreeWidgetProvider.csindex 10d0cbafd..6f7fd26eb 100644--- a/src/Plugins/Payments.BrainTree/BrainTreeWidgetProvider.cs+++ b/src/Plugins/Payments.BrainTree/BrainTreeWidgetProvider.cs@@ -1,39 +1,39 @@using Grand.Business.Core.Interfaces.Cms;using Grand.Business.Core.Interfaces.Common.Localization;-namespace Payments.BrainTree+namespace Payments.BrainTree;++public class BrainTreeWidgetProvider : IWidgetProvider{- public class BrainTreeWidgetProvider : IWidgetProvider- {- private readonly ITranslationService _translationService;- private readonly BrainTreePaymentSettings _brainTreePaymentSettings;+ private readonly BrainTreePaymentSettings _brainTreePaymentSettings;+ private readonly ITranslationService _translationService;- public BrainTreeWidgetProvider(ITranslationService translationService, BrainTreePaymentSettings brainTreePaymentSettings)- {- _translationService = translationService;- _brainTreePaymentSettings = brainTreePaymentSettings;- }+ public BrainTreeWidgetProvider(ITranslationService translationService,+ BrainTreePaymentSettings brainTreePaymentSettings)+ {+ _translationService = translationService;+ _brainTreePaymentSettings = brainTreePaymentSettings;+ }- public string ConfigurationUrl => BrainTreeDefaults.ConfigurationUrl;+ public string ConfigurationUrl => BrainTreeDefaults.ConfigurationUrl;- public string SystemName => BrainTreeDefaults.ProviderSystemName;+ public string SystemName => BrainTreeDefaults.ProviderSystemName;- public string FriendlyName => _translationService.GetResource(BrainTreeDefaults.FriendlyName);+ public string FriendlyName => _translationService.GetResource(BrainTreeDefaults.FriendlyName);- public int Priority => _brainTreePaymentSettings.DisplayOrder;+ public int Priority => _brainTreePaymentSettings.DisplayOrder;- public IList<string> LimitedToStores => new List<string>();+ public IList<string> LimitedToStores => new List<string>();- public IList<string> LimitedToGroups => new List<string>();+ public IList<string> LimitedToGroups => new List<string>();- public async Task<IList<string>> GetWidgetZones()- {- return await Task.FromResult(new[] { "checkout_payment_info_top" });- }+ public async Task<IList<string>> GetWidgetZones()+ {+ return await Task.FromResult(new[] { "checkout_payment_info_top" });+ }- public Task<string> GetPublicViewComponentName(string widgetZone)- {- return Task.FromResult("PaymentBrainTreeScripts");- }+ public Task<string> GetPublicViewComponentName(string widgetZone)+ {+ return Task.FromResult("PaymentBrainTreeScripts");}-}+}\ No newline at end of filediff --git a/src/Plugins/Payments.BrainTree/Components/PaymentBrainTreeScripts.cs b/src/Plugins/Payments.BrainTree/Components/PaymentBrainTreeScripts.csindex 33b3a89e6..3caf242a5 100644--- a/src/Plugins/Payments.BrainTree/Components/PaymentBrainTreeScripts.cs+++ b/src/Plugins/Payments.BrainTree/Components/PaymentBrainTreeScripts.cs@@ -1,13 +1,12 @@using Microsoft.AspNetCore.Mvc;-namespace Payments.BrainTree.Components+namespace Payments.BrainTree.Components;++[ViewComponent(Name = "PaymentBrainTreeScripts")]+public class PaymentBrainTreeScripts : ViewComponent{- [ViewComponent(Name = "PaymentBrainTreeScripts")]- public class PaymentBrainTreeScripts : ViewComponent+ public IViewComponentResult Invoke(){- public IViewComponentResult Invoke()- {- return View();- }+ return View();}-}+}\ No newline at end of filediff --git a/src/Plugins/Payments.BrainTree/Controllers/PaymentBrainTreeController.cs b/src/Plugins/Payments.BrainTree/Controllers/PaymentBrainTreeController.csindex 7dbce19ff..b11b2291e 100644--- a/src/Plugins/Payments.BrainTree/Controllers/PaymentBrainTreeController.cs+++ b/src/Plugins/Payments.BrainTree/Controllers/PaymentBrainTreeController.cs@@ -9,106 +9,107 @@ using Microsoft.AspNetCore.Mvc.Rendering;using Payments.BrainTree.Models;using Payments.BrainTree.Validators;using System.Net;+using Environment = Braintree.Environment;-namespace Payments.BrainTree.Controllers+namespace Payments.BrainTree.Controllers;++public class PaymentBrainTreeController : BasePaymentController{- public class PaymentBrainTreeController : BasePaymentController+ private readonly BrainTreePaymentSettings _brainTreePaymentSettings;+ private readonly IOrderCalculationService _orderTotalCalculationService;+ private readonly IShoppingCartService _shoppingCartService;+ private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;++ public PaymentBrainTreeController(BrainTreePaymentSettings brainTreePaymentSettings,+ IOrderCalculationService orderTotalCalculationService,+ IShoppingCartService shoppingCartService,+ IWorkContext workContext,+ ITranslationService translationService){- private readonly BrainTreePaymentSettings _brainTreePaymentSettings;- private readonly IOrderCalculationService _orderTotalCalculationService;- private readonly IShoppingCartService _shoppingCartService;- private readonly IWorkContext _workContext;- private readonly ITranslationService _translationService;-- public PaymentBrainTreeController(BrainTreePaymentSettings brainTreePaymentSettings,- IOrderCalculationService orderTotalCalculationService,- IShoppingCartService shoppingCartService,- IWorkContext workContext,- ITranslationService translationService)+ _brainTreePaymentSettings = brainTreePaymentSettings;+ _orderTotalCalculationService = orderTotalCalculationService;+ _shoppingCartService = shoppingCartService;+ _workContext = workContext;+ _translationService = translationService;+ }++ public async Task<IActionResult> PaymentInfo()+ {+ var model = new PaymentInfoModel();++ if (_brainTreePaymentSettings.Use3DS){- _brainTreePaymentSettings = brainTreePaymentSettings;- _orderTotalCalculationService = orderTotalCalculationService;- _shoppingCartService = shoppingCartService;- _workContext = workContext;- _translationService = translationService;+ var cart = await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id,+ ShoppingCartType.ShoppingCart);++ if (!cart.Any())+ throw new Exception("Your cart is empty");++ //get settings+ var useSandBox = _brainTreePaymentSettings.UseSandBox;+ var merchantId = _brainTreePaymentSettings.MerchantId;+ var publicKey = _brainTreePaymentSettings.PublicKey;+ var privateKey = _brainTreePaymentSettings.PrivateKey;++ var gateway = new BraintreeGateway {+ Environment = useSandBox ? Environment.SANDBOX : Environment.PRODUCTION,+ MerchantId = merchantId,+ PublicKey = publicKey,+ PrivateKey = privateKey+ };++ ViewBag.ClientToken = await gateway.ClientToken.GenerateAsync();+ ViewBag.OrderTotal = (await _orderTotalCalculationService.GetShoppingCartTotal(cart)).shoppingCartTotal;++ return View("PaymentInfo_3DS", model);}- public async Task<IActionResult> PaymentInfo()+ //years+ for (var i = 0; i < 15; i++){- var model = new PaymentInfoModel();-- if (_brainTreePaymentSettings.Use3DS)- {- var cart = await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, ShoppingCartType.ShoppingCart);-- if (!cart.Any())- throw new Exception("Your cart is empty");-- //get settings- var useSandBox = _brainTreePaymentSettings.UseSandBox;- var merchantId = _brainTreePaymentSettings.MerchantId;- var publicKey = _brainTreePaymentSettings.PublicKey;- var privateKey = _brainTreePaymentSettings.PrivateKey;-- var gateway = new BraintreeGateway {- Environment = useSandBox ? Braintree.Environment.SANDBOX : Braintree.Environment.PRODUCTION,- MerchantId = merchantId,- PublicKey = publicKey,- PrivateKey = privateKey- };-- ViewBag.ClientToken = await gateway.ClientToken.GenerateAsync();- ViewBag.OrderTotal = (await _orderTotalCalculationService.GetShoppingCartTotal(cart)).shoppingCartTotal;-- return View("PaymentInfo_3DS", model);- }-- //years- for (var i = 0; i < 15; i++)- {- var year = Convert.ToString(DateTime.Now.Year + i);- model.ExpireYears.Add(new SelectListItem {- Text = year,- Value = year- });- }-- //months- for (var i = 1; i <= 12; i++)- {- var text = i < 10 ? "0" + i : i.ToString();- model.ExpireMonths.Add(new SelectListItem {- Text = text,- Value = i.ToString()- });- }-- //set postback values (we cannot access "Form" with "GET" requests)- if (Request.Method == WebRequestMethods.Http.Get)- return View("PaymentInfo", model);-- var form = await HttpContext.Request.ReadFormAsync();-- model.CardholderName = form["CardholderName"];- model.CardNumber = form["CardNumber"];- model.CardCode = form["CardCode"];-- var selectedMonth = model.ExpireMonths- .FirstOrDefault(x => x.Value.Equals(form["ExpireMonth"], StringComparison.InvariantCultureIgnoreCase));- if (selectedMonth != null)- selectedMonth.Selected = true;- var selectedYear = model.ExpireYears- .FirstOrDefault(x => x.Value.Equals(form["ExpireYear"], StringComparison.InvariantCultureIgnoreCase));- if (selectedYear != null)- selectedYear.Selected = true;-- var validator = new PaymentInfoValidator(_brainTreePaymentSettings, _translationService);- var results = await validator.ValidateAsync(model);- if (results.IsValid) return View("PaymentInfo", model);- var query = from error in results.Errors- select error.ErrorMessage;- model.Errors = string.Join(", ", query);- return View("PaymentInfo", model);+ var year = Convert.ToString(DateTime.Now.Year + i);+ model.ExpireYears.Add(new SelectListItem {+ Text = year,+ Value = year+ });+ }++ //months+ for (var i = 1; i <= 12; i++)+ {+ var text = i < 10 ? "0" + i : i.ToString();+ model.ExpireMonths.Add(new SelectListItem {+ Text = text,+ Value = i.ToString()+ });}++ //set postback values (we cannot access "Form" with "GET" requests)+ if (Request.Method == WebRequestMethods.Http.Get)+ return View("PaymentInfo", model);++ var form = await HttpContext.Request.ReadFormAsync();++ model.CardholderName = form["CardholderName"];+ model.CardNumber = form["CardNumber"];+ model.CardCode = form["CardCode"];++ var selectedMonth = model.ExpireMonths+ .FirstOrDefault(x => x.Value.Equals(form["ExpireMonth"], StringComparison.InvariantCultureIgnoreCase));+ if (selectedMonth != null)+ selectedMonth.Selected = true;+ var selectedYear = model.ExpireYears+ .FirstOrDefault(x => x.Value.Equals(form["ExpireYear"], StringComparison.InvariantCultureIgnoreCase));+ if (selectedYear != null)+ selectedYear.Selected = true;++ var validator = new PaymentInfoValidator(_brainTreePaymentSettings, _translationService);+ var results = await validator.ValidateAsync(model);+ if (results.IsValid) return View("PaymentInfo", model);+ var query = from error in results.Errors+ select error.ErrorMessage;+ model.Errors = string.Join(", ", query);+ return View("PaymentInfo", model);}}\ No newline at end of filediff --git a/src/Plugins/Payments.BrainTree/EndpointProvider.cs b/src/Plugins/Payments.BrainTree/EndpointProvider.csindex b7e67a18b..ba635fe10 100644--- a/src/Plugins/Payments.BrainTree/EndpointProvider.cs+++ b/src/Plugins/Payments.BrainTree/EndpointProvider.cs@@ -2,18 +2,17 @@using Microsoft.AspNetCore.Builder;using Microsoft.AspNetCore.Routing;-namespace Payments.BrainTree+namespace Payments.BrainTree;++public class EndpointProvider : IEndpointProvider{- public class EndpointProvider : IEndpointProvider+ public void RegisterEndpoint(IEndpointRouteBuilder endpointRouteBuilder){- public void RegisterEndpoint(IEndpointRouteBuilder endpointRouteBuilder)- {- endpointRouteBuilder.MapControllerRoute("Plugin.PaymentBrainTree",- "Plugins/PaymentBrainTree/PaymentInfo",- new { controller = "PaymentBrainTree", action = "PaymentInfo", area = "" }- );- }- public int Priority => 0;-+ endpointRouteBuilder.MapControllerRoute("Plugin.PaymentBrainTree",+ "Plugins/PaymentBrainTree/PaymentInfo",+ new { controller = "PaymentBrainTree", action = "PaymentInfo", area = "" }+ );}-}++ public int Priority => 0;+}\ No newline at end of filediff --git a/src/Plugins/Payments.BrainTree/Models/ConfigurationModel.cs b/src/Plugins/Payments.BrainTree/Models/ConfigurationModel.csindex e6eb13e5f..df543f7c1 100644--- a/src/Plugins/Payments.BrainTree/Models/ConfigurationModel.cs+++ b/src/Plugins/Payments.BrainTree/Models/ConfigurationModel.cs@@ -1,32 +1,31 @@using Grand.Infrastructure.ModelBinding;using Grand.Infrastructure.Models;-namespace Payments.BrainTree.Models+namespace Payments.BrainTree.Models;++public class ConfigurationModel : BaseModel{- public class ConfigurationModel : BaseModel- {- [GrandResourceDisplayName("Plugins.Payments.BrainTree.Fields.Use3DS")]- public bool Use3DS { get; set; }+ [GrandResourceDisplayName("Plugins.Payments.BrainTree.Fields.Use3DS")]+ public bool Use3DS { get; set; }- [GrandResourceDisplayName("Plugins.Payments.BrainTree.Fields.UseSandbox")]- public bool UseSandBox { get; set; }+ [GrandResourceDisplayName("Plugins.Payments.BrainTree.Fields.UseSandbox")]+ public bool UseSandBox { get; set; }- [GrandResourceDisplayName("Plugins.Payments.BrainTree.Fields.MerchantId")]- public string MerchantId { get; set; }+ [GrandResourceDisplayName("Plugins.Payments.BrainTree.Fields.MerchantId")]+ public string MerchantId { get; set; }- [GrandResourceDisplayName("Plugins.Payments.BrainTree.Fields.PublicKey")]- public string PublicKey { get; set; }+ [GrandResourceDisplayName("Plugins.Payments.BrainTree.Fields.PublicKey")]+ public string PublicKey { get; set; }- [GrandResourceDisplayName("Plugins.Payments.BrainTree.Fields.PrivateKey")]- public string PrivateKey { get; set; }+ [GrandResourceDisplayName("Plugins.Payments.BrainTree.Fields.PrivateKey")]+ public string PrivateKey { get; set; }- [GrandResourceDisplayName("Plugins.Payments.BrainTree.Fields.AdditionalFee")]- public double AdditionalFee { get; set; }+ [GrandResourceDisplayName("Plugins.Payments.BrainTree.Fields.AdditionalFee")]+ public double AdditionalFee { get; set; }- [GrandResourceDisplayName("Plugins.Payments.BrainTree.Fields.AdditionalFeePercentage")]- public bool AdditionalFeePercentage { get; set; }+ [GrandResourceDisplayName("Plugins.Payments.BrainTree.Fields.AdditionalFeePercentage")]+ public bool AdditionalFeePercentage { get; set; }- [GrandResourceDisplayName("Plugins.Payments.BrainTree.Fields.DisplayOrder")]- public int DisplayOrder { get; set; }- }+ [GrandResourceDisplayName("Plugins.Payments.BrainTree.Fields.DisplayOrder")]+ public int DisplayOrder { get; set; }}\ No newline at end of filediff --git a/src/Plugins/Payments.BrainTree/Models/PaymentInfoModel.cs b/src/Plugins/Payments.BrainTree/Models/PaymentInfoModel.csindex f5d78ccc7..68d19de50 100644--- a/src/Plugins/Payments.BrainTree/Models/PaymentInfoModel.cs+++ b/src/Plugins/Payments.BrainTree/Models/PaymentInfoModel.cs@@ -2,35 +2,33 @@using Grand.Infrastructure.Models;using Microsoft.AspNetCore.Mvc.Rendering;-namespace Payments.BrainTree.Models-{- public class PaymentInfoModel : BaseModel- {- [GrandResourceDisplayName("Payment.SelectCreditCard")]- public string CreditCardType { get; set; }+namespace Payments.BrainTree.Models;- [GrandResourceDisplayName("Payment.CardholderName")]+public class PaymentInfoModel : BaseModel+{+ [GrandResourceDisplayName("Payment.SelectCreditCard")]+ public string CreditCardType { get; set; }- public string CardholderName { get; set; }+ [GrandResourceDisplayName("Payment.CardholderName")]- [GrandResourceDisplayName("Payment.CardNumber")]- public string CardNumber { get; set; }+ public string CardholderName { get; set; }- [GrandResourceDisplayName("Payment.ExpirationDate")]- public string ExpireMonth { get; set; }+ [GrandResourceDisplayName("Payment.CardNumber")]+ public string CardNumber { get; set; }- [GrandResourceDisplayName("Payment.ExpirationDate")]- public string ExpireYear { get; set; }+ [GrandResourceDisplayName("Payment.ExpirationDate")]+ public string ExpireMonth { get; set; }- public IList<SelectListItem> ExpireMonths { get; set; } = new List<SelectListItem>();+ [GrandResourceDisplayName("Payment.ExpirationDate")]+ public string ExpireYear { get; set; }- public IList<SelectListItem> ExpireYears { get; set; } = new List<SelectListItem>();+ public IList<SelectListItem> ExpireMonths { get; set; } = new List<SelectListItem>();- [GrandResourceDisplayName("Payment.CardCode")]- public string CardCode { get; set; }+ public IList<SelectListItem> ExpireYears { get; set; } = new List<SelectListItem>();- public string CardNonce { get; set; }- public string Errors { get; set; }+ [GrandResourceDisplayName("Payment.CardCode")]+ public string CardCode { get; set; }- }+ public string CardNonce { get; set; }+ public string Errors { get; set; }}\ No newline at end of filediff --git a/src/Plugins/Payments.BrainTree/StartupApplication.cs b/src/Plugins/Payments.BrainTree/StartupApplication.csindex c5e3e1672..bcf458c5e 100644--- a/src/Plugins/Payments.BrainTree/StartupApplication.cs+++ b/src/Plugins/Payments.BrainTree/StartupApplication.cs@@ -6,23 +6,21 @@ using Microsoft.AspNetCore.Hosting;using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;-namespace Payments.BrainTree+namespace Payments.BrainTree;++public class StartupApplication : IStartupApplication{- public class StartupApplication : IStartupApplication+ public void ConfigureServices(IServiceCollection services, IConfiguration configuration){- public void ConfigureServices(IServiceCollection services, IConfiguration configuration)- {- services.AddScoped<IPaymentProvider, BrainTreePaymentProvider>();- services.AddScoped<IWidgetProvider, BrainTreeWidgetProvider>();- }-- public int Priority => 10;- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)- {+ services.AddScoped<IPaymentProvider, BrainTreePaymentProvider>();+ services.AddScoped<IWidgetProvider, BrainTreeWidgetProvider>();+ }- }- public bool BeforeConfigure => false;+ public int Priority => 10;+ public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)+ {}-}+ public bool BeforeConfigure => false;+}\ No newline at end of filediff --git a/src/Plugins/Payments.BrainTree/Validators/PaymentInfoValidator.cs b/src/Plugins/Payments.BrainTree/Validators/PaymentInfoValidator.csindex 01a097a3c..5ebc58b07 100644--- a/src/Plugins/Payments.BrainTree/Validators/PaymentInfoValidator.cs+++ b/src/Plugins/Payments.BrainTree/Validators/PaymentInfoValidator.cs@@ -2,24 +2,28 @@using Grand.Business.Core.Interfaces.Common.Localization;using Payments.BrainTree.Models;-namespace Payments.BrainTree.Validators+namespace Payments.BrainTree.Validators;++public class PaymentInfoValidator : AbstractValidator<PaymentInfoModel>{- public class PaymentInfoValidator : AbstractValidator<PaymentInfoModel>+ public PaymentInfoValidator(BrainTreePaymentSettings brainTreePaymentSettings,+ ITranslationService translationService){- public PaymentInfoValidator(BrainTreePaymentSettings brainTreePaymentSettings, ITranslationService translationService)- {- if (brainTreePaymentSettings.Use3DS)- return;+ if (brainTreePaymentSettings.Use3DS)+ return;- //useful links:- //http://fluentvalidation.codeplex.com/wikipage?title=Custom&referringTitle=Documentation&ANCHOR#CustomValidator- //http://benjii.me/2010/11/credit-card-validator-attribute-for-asp-net-mvc-3/+ //useful links:+ //http://fluentvalidation.codeplex.com/wikipage?title=Custom&referringTitle=Documentation&ANCHOR#CustomValidator+ //http://benjii.me/2010/11/credit-card-validator-attribute-for-asp-net-mvc-3/- RuleFor(x => x.CardholderName).NotEmpty().WithMessage(translationService.GetResource("Payment.CardholderName.Required"));- RuleFor(x => x.CardNumber).CreditCard().WithMessage(translationService.GetResource("Payment.CardNumber.Wrong"));- RuleFor(x => x.CardCode).Matches("^[0-9]{3,4}$").WithMessage(translationService.GetResource("Payment.CardCode.Wrong"));- RuleFor(x => x.ExpireMonth).NotEmpty().WithMessage(translationService.GetResource("Payment.ExpireMonth.Required"));- RuleFor(x => x.ExpireYear).NotEmpty().WithMessage(translationService.GetResource("Payment.ExpireYear.Required"));- }+ RuleFor(x => x.CardholderName).NotEmpty()+ .WithMessage(translationService.GetResource("Payment.CardholderName.Required"));+ RuleFor(x => x.CardNumber).CreditCard().WithMessage(translationService.GetResource("Payment.CardNumber.Wrong"));+ RuleFor(x => x.CardCode).Matches("^[0-9]{3,4}$")+ .WithMessage(translationService.GetResource("Payment.CardCode.Wrong"));+ RuleFor(x => x.ExpireMonth).NotEmpty()+ .WithMessage(translationService.GetResource("Payment.ExpireMonth.Required"));+ RuleFor(x => x.ExpireYear).NotEmpty()+ .WithMessage(translationService.GetResource("Payment.ExpireYear.Required"));}}\ No newline at end of filediff --git a/src/Plugins/Payments.BrainTree/Views/PaymentBrainTree/PaymentInfo.cshtml b/src/Plugins/Payments.BrainTree/Views/PaymentBrainTree/PaymentInfo.cshtmlindex 9733158ca..27cff9764 100644--- a/src/Plugins/Payments.BrainTree/Views/PaymentBrainTree/PaymentInfo.cshtml+++ b/src/Plugins/Payments.BrainTree/Views/PaymentBrainTree/PaymentInfo.cshtml@@ -8,7 +8,7 @@<label class="col-form-label" asp-for="CardholderName">@Loc["Payment.CardholderName"]:</label></div><div class="col-md-4 col-12 text-right">- <input asp-for="CardholderName" class="form-control" autofocus="autofocus" />+ <input asp-for="CardholderName" class="form-control" autofocus="autofocus"/><span asp-validation-for="CardholderName"></span></div></div>@@ -18,7 +18,7 @@<label class="col-form-label" asp-for="CardNumber">@Loc["Payment.CardNumber"]:</label></div><div class="col-md-4 col-12 text-right">- <input asp-for="CardNumber" class="form-control" autofocus="autofocus" />+ <input asp-for="CardNumber" class="form-control" autofocus="autofocus"/><span asp-validation-for="CardNumber"></span></div></div>@@ -38,7 +38,7 @@<label class="col-form-label" asp-for="CardCode">@Loc["Payment.CardCode"]:</label></div><div class="col-md-4 col-12 text-right">- <input asp-for="CardCode" class="form-control" autofocus="autofocus" />+ <input asp-for="CardCode" class="form-control" autofocus="autofocus"/><span asp-validation-for="CardCode"></span></div></div>diff --git a/src/Plugins/Payments.BrainTree/Views/PaymentBrainTree/PaymentInfo_3DS.cshtml b/src/Plugins/Payments.BrainTree/Views/PaymentBrainTree/PaymentInfo_3DS.cshtmlindex 971843023..e61289384 100644--- a/src/Plugins/Payments.BrainTree/Views/PaymentBrainTree/PaymentInfo_3DS.cshtml+++ b/src/Plugins/Payments.BrainTree/Views/PaymentBrainTree/PaymentInfo_3DS.cshtml@@ -1,8 +1,9 @@-@model Payments.BrainTree.Models.PaymentInfoModel+@using Grand.Infrastructure+@model Payments.BrainTree.Models.PaymentInfoModel@{Layout = "";}-@inject Grand.Infrastructure.IWorkContext _workContext+@inject IWorkContext _workContext<style type="text/css">.braintree-input {@@ -47,13 +48,13 @@</div><div class="col-md-4 col-12 text-right"><div class="braintree-input form-control" id="cc-cvv"></div>- <input id="CardNonce" name="CardNonce" type="hidden" />+ <input id="CardNonce" name="CardNonce" type="hidden"/></div></div></div>-<input type="hidden" asp-for="Errors" />+<input type="hidden" asp-for="Errors"/><div style="color:red; margin:0 auto" id="braintree-errors"></div><div id="braintree-authentication"></div><div class="script-tag-info">diff --git a/src/Plugins/Payments.BrainTree/Views/_ViewImports.cshtml b/src/Plugins/Payments.BrainTree/Views/_ViewImports.cshtmlindex 2fb08c043..fb3b84aa9 100644--- a/src/Plugins/Payments.BrainTree/Views/_ViewImports.cshtml+++ b/src/Plugins/Payments.BrainTree/Views/_ViewImports.cshtml@@ -4,5 +4,6 @@@using Microsoft.AspNetCore.Mvc.ViewFeatures@using Grand.Infrastructure.Extensions+@using Grand.Web.Common.Localization-@inject Grand.Web.Common.Localization.LocService Loc+@inject LocService Loc\ No newline at end of filediff --git a/src/Plugins/Payments.CashOnDelivery/Areas/Admin/Controllers/PaymentCashOnDeliveryController.cs b/src/Plugins/Payments.CashOnDelivery/Areas/Admin/Controllers/PaymentCashOnDeliveryController.csindex 8c3b8a1aa..039914c91 100644--- a/src/Plugins/Payments.CashOnDelivery/Areas/Admin/Controllers/PaymentCashOnDeliveryController.cs+++ b/src/Plugins/Payments.CashOnDelivery/Areas/Admin/Controllers/PaymentCashOnDeliveryController.cs@@ -11,91 +11,91 @@ using Grand.Web.Common.Security.Authorization;using Microsoft.AspNetCore.Mvc;using Payments.CashOnDelivery.Models;-namespace Payments.CashOnDelivery.Areas.Admin.Controllers+namespace Payments.CashOnDelivery.Areas.Admin.Controllers;++[AuthorizeAdmin]+[Area("Admin")]+[PermissionAuthorize(PermissionSystemName.PaymentMethods)]+public class PaymentCashOnDeliveryController : BasePaymentController{- [AuthorizeAdmin]- [Area("Admin")]- [PermissionAuthorize(PermissionSystemName.PaymentMethods)]- public class PaymentCashOnDeliveryController : BasePaymentController+ private readonly ISettingService _settingService;+ private readonly IStoreService _storeService;+ private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;+++ public PaymentCashOnDeliveryController(IWorkContext workContext,+ IStoreService storeService,+ ISettingService settingService,+ ITranslationService translationService)+ {+ _workContext = workContext;+ _storeService = storeService;+ _settingService = settingService;+ _translationService = translationService;+ }+++ protected virtual async Task<string> GetActiveStore(IStoreService storeService, IWorkContext workContext){- private readonly IWorkContext _workContext;- private readonly IStoreService _storeService;- private readonly ISettingService _settingService;- private readonly ITranslationService _translationService;--- public PaymentCashOnDeliveryController(IWorkContext workContext,- IStoreService storeService,- ISettingService settingService,- ITranslationService translationService)- {- _workContext = workContext;- _storeService = storeService;- _settingService = settingService;- _translationService = translationService;- }--- protected virtual async Task<string> GetActiveStore(IStoreService storeService, IWorkContext workContext)- {- var stores = await storeService.GetAllStores();- if (stores.Count < 2)- return stores.FirstOrDefault().Id;-- var storeId = workContext.CurrentCustomer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.AdminAreaStoreScopeConfiguration);- var store = await storeService.GetStoreById(storeId);-- return store != null ? store.Id : "";- }-- public async Task<IActionResult> Configure()- {- //load settings for a chosen store scope- var storeScope = await this.GetActiveStore(_storeService, _workContext);- var cashOnDeliveryPaymentSettings = _settingService.LoadSetting<CashOnDeliveryPaymentSettings>(storeScope);-- var model = new ConfigurationModel {- DescriptionText = cashOnDeliveryPaymentSettings.DescriptionText,- AdditionalFee = cashOnDeliveryPaymentSettings.AdditionalFee,- AdditionalFeePercentage = cashOnDeliveryPaymentSettings.AdditionalFeePercentage,- ShippableProductRequired = cashOnDeliveryPaymentSettings.ShippableProductRequired,- DisplayOrder = cashOnDeliveryPaymentSettings.DisplayOrder,- SkipPaymentInfo = cashOnDeliveryPaymentSettings.SkipPaymentInfo- };- model.DescriptionText = cashOnDeliveryPaymentSettings.DescriptionText;-- model.ActiveStore = storeScope;-- return View(model);- }-- [HttpPost]- public async Task<IActionResult> Configure(ConfigurationModel model)- {- if (!ModelState.IsValid)- return await Configure();-- //load settings for a chosen store scope- var storeScope = await this.GetActiveStore(_storeService, _workContext);- var cashOnDeliveryPaymentSettings = _settingService.LoadSetting<CashOnDeliveryPaymentSettings>(storeScope);-- //save settings- cashOnDeliveryPaymentSettings.DescriptionText = model.DescriptionText;- cashOnDeliveryPaymentSettings.AdditionalFee = model.AdditionalFee;- cashOnDeliveryPaymentSettings.AdditionalFeePercentage = model.AdditionalFeePercentage;- cashOnDeliveryPaymentSettings.ShippableProductRequired = model.ShippableProductRequired;- cashOnDeliveryPaymentSettings.DisplayOrder = model.DisplayOrder;- cashOnDeliveryPaymentSettings.SkipPaymentInfo = model.SkipPaymentInfo;-- await _settingService.SaveSetting(cashOnDeliveryPaymentSettings, storeScope);-- //now clear settings cache- await _settingService.ClearCache();-- Success(_translationService.GetResource("Admin.Plugins.Saved"));+ var stores = await storeService.GetAllStores();+ if (stores.Count < 2)+ return stores.FirstOrDefault().Id;++ var storeId =+ workContext.CurrentCustomer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames+ .AdminAreaStoreScopeConfiguration);+ var store = await storeService.GetStoreById(storeId);++ return store != null ? store.Id : "";+ }+ public async Task<IActionResult> Configure()+ {+ //load settings for a chosen store scope+ var storeScope = await GetActiveStore(_storeService, _workContext);+ var cashOnDeliveryPaymentSettings = _settingService.LoadSetting<CashOnDeliveryPaymentSettings>(storeScope);++ var model = new ConfigurationModel {+ DescriptionText = cashOnDeliveryPaymentSettings.DescriptionText,+ AdditionalFee = cashOnDeliveryPaymentSettings.AdditionalFee,+ AdditionalFeePercentage = cashOnDeliveryPaymentSettings.AdditionalFeePercentage,+ ShippableProductRequired = cashOnDeliveryPaymentSettings.ShippableProductRequired,+ DisplayOrder = cashOnDeliveryPaymentSettings.DisplayOrder,+ SkipPaymentInfo = cashOnDeliveryPaymentSettings.SkipPaymentInfo+ };+ model.DescriptionText = cashOnDeliveryPaymentSettings.DescriptionText;++ model.ActiveStore = storeScope;++ return View(model);+ }++ [HttpPost]+ public async Task<IActionResult> Configure(ConfigurationModel model)+ {+ if (!ModelState.IsValid)return await Configure();- }+ //load settings for a chosen store scope+ var storeScope = await GetActiveStore(_storeService, _workContext);+ var cashOnDeliveryPaymentSettings = _settingService.LoadSetting<CashOnDeliveryPaymentSettings>(storeScope);++ //save settings+ cashOnDeliveryPaymentSettings.DescriptionText = model.DescriptionText;+ cashOnDeliveryPaymentSettings.AdditionalFee = model.AdditionalFee;+ cashOnDeliveryPaymentSettings.AdditionalFeePercentage = model.AdditionalFeePercentage;+ cashOnDeliveryPaymentSettings.ShippableProductRequired = model.ShippableProductRequired;+ cashOnDeliveryPaymentSettings.DisplayOrder = model.DisplayOrder;+ cashOnDeliveryPaymentSettings.SkipPaymentInfo = model.SkipPaymentInfo;++ await _settingService.SaveSetting(cashOnDeliveryPaymentSettings, storeScope);++ //now clear settings cache+ await _settingService.ClearCache();++ Success(_translationService.GetResource("Admin.Plugins.Saved"));++ return await Configure();}-}+}\ No newline at end of filediff --git a/src/Plugins/Payments.CashOnDelivery/Areas/Admin/Views/PaymentCashOnDelivery/Configure.cshtml b/src/Plugins/Payments.CashOnDelivery/Areas/Admin/Views/PaymentCashOnDelivery/Configure.cshtmlindex 040a3f402..361a31623 100644--- a/src/Plugins/Payments.CashOnDelivery/Areas/Admin/Views/PaymentCashOnDelivery/Configure.cshtml+++ b/src/Plugins/Payments.CashOnDelivery/Areas/Admin/Views/PaymentCashOnDelivery/Configure.cshtml@@ -1,102 +1,102 @@@{Layout = "_ConfigurePlugin";}-@model ConfigurationModel-@using Microsoft.AspNetCore.Mvc.Razor;-@using Payments.CashOnDelivery.Models;+@using Microsoft.AspNetCore.Mvc.Razor+@model Payments.CashOnDelivery.Models.ConfigurationModel@await Component.InvokeAsync("StoreScope")-<input id="active-menu-item" type="hidden" value="/Admin/Payment/Methods" />+<input id="active-menu-item" type="hidden" value="/Admin/Payment/Methods"/><form asp-controller="PaymentCashOnDelivery" asp-action="Configure" method="post">- @{ Func<int, HelperResult>- template = @<div class="form-body">+ @{+ Func<int, HelperResult>+ template = @<div class="form-body">+ <div class="form-group">+ <div class="col-md-3 col-sm-3 text-right">+ <admin-label asp-for="@Model.Locales[item].DescriptionText" class="control-label"/>+ </div>+ <div class="col-md-9 col-sm-9">+ <admin-textarea asp-for="@Model.Locales[item].DescriptionText"></admin-textarea>+ <span asp-validation-for="@Model.Locales[item].DescriptionText"></span>+ </div>+ </div>+ <input asp-for="@Model.Locales[item].LanguageId" type="hidden"/>+ </div>;+ }++ <div class="form-horizontal">+ <localized-editor localized-template="@template" name="plugin-settings-localized" language-ids="@Model.Locales.Select(c => c.LanguageId).ToList()">+ <div class="form-body">+ <div class="form-group">+ <div class="col-md-3 col-sm-3 text-right">+ <admin-label asp-for="DescriptionText" class="control-label"/>+ </div>+ <div class="col-md-9 col-sm-9">+ <admin-textarea asp-for="DescriptionText"></admin-textarea>+ <span asp-validation-for="DescriptionText"></span>+ </div>+ </div>+ </div>+ </localized-editor>+ <div class="form-body"><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="@Model.Locales[item].DescriptionText" class="control-label" />+ <admin-label asp-for="AdditionalFee" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-textarea asp-for="@Model.Locales[item].DescriptionText"></admin-textarea>- <span asp-validation-for="@Model.Locales[item].DescriptionText"></span>+ <admin-input asp-for="AdditionalFee"/>+ <span asp-validation-for="AdditionalFee"></span></div></div>- <input asp-for="@Model.Locales[item].LanguageId" type="hidden" />- </div>;- }--<div class="form-horizontal">- <localized-editor localized-template=@template name="plugin-settings-localized" [email protected](c=>c.LanguageId).ToList()>- <div class="form-body"><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="DescriptionText" class="control-label" />+ <admin-label asp-for="AdditionalFeePercentage" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-textarea asp-for="DescriptionText"></admin-textarea>- <span asp-validation-for="DescriptionText"></span>+ <label class="mt-checkbox mt-checkbox-outline control control-checkbox">+ <admin-input asp-for="AdditionalFeePercentage"/>+ <div class="control__indicator"></div>+ </label>+ <span asp-validation-for="AdditionalFeePercentage"></span></div></div>- </div>- </localized-editor>- <div class="form-body">- <div class="form-group">- <div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="AdditionalFee" class="control-label" />- </div>- <div class="col-md-9 col-sm-9">- <admin-input asp-for="AdditionalFee" />- <span asp-validation-for="AdditionalFee"></span>- </div>- </div>- <div class="form-group">- <div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="AdditionalFeePercentage" class="control-label" />- </div>- <div class="col-md-9 col-sm-9">- <label class="mt-checkbox mt-checkbox-outline control control-checkbox">- <admin-input asp-for="AdditionalFeePercentage" />- <div class="control__indicator"></div>- </label>- <span asp-validation-for="AdditionalFeePercentage"></span>- </div>- </div>- <div class="form-group">- <div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="ShippableProductRequired" class="control-label" />- </div>- <div class="col-md-9 col-sm-9">- <label class="mt-checkbox mt-checkbox-outline control control-checkbox">- <admin-input asp-for="ShippableProductRequired" />- <div class="control__indicator"></div>- </label>- <span asp-validation-for="ShippableProductRequired"></span>- </div>- </div>- <div class="form-group">- <div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="SkipPaymentInfo" class="control-label" />- </div>- <div class="col-md-9 col-sm-9">- <label class="mt-checkbox mt-checkbox-outline control control-checkbox">- <admin-input asp-for="SkipPaymentInfo" />- <div class="control__indicator"></div>- </label>- <span asp-validation-for="SkipPaymentInfo"></span>+ <div class="form-group">+ <div class="col-md-3 col-sm-3 text-right">+ <admin-label asp-for="ShippableProductRequired" class="control-label"/>+ </div>+ <div class="col-md-9 col-sm-9">+ <label class="mt-checkbox mt-checkbox-outline control control-checkbox">+ <admin-input asp-for="ShippableProductRequired"/>+ <div class="control__indicator"></div>+ </label>+ <span asp-validation-for="ShippableProductRequired"></span>+ </div></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 class="form-group">+ <div class="col-md-3 col-sm-3 text-right">+ <admin-label asp-for="SkipPaymentInfo" class="control-label"/>+ </div>+ <div class="col-md-9 col-sm-9">+ <label class="mt-checkbox mt-checkbox-outline control control-checkbox">+ <admin-input asp-for="SkipPaymentInfo"/>+ <div class="control__indicator"></div>+ </label>+ <span asp-validation-for="SkipPaymentInfo"></span>+ </div></div>- <div class="col-md-9 col-sm-9">- <admin-input asp-for="DisplayOrder" />- <span asp-validation-for="DisplayOrder"></span>+ <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>- </div><div class="form-actions"><div class="row"><div class="offset-md-3 offset-sm-3 col-md-9 col-sm-9">- <input type="submit" name="save" class="btn green" value="@Loc["Admin.Common.Save"]" />+ <input type="submit" name="save" class="btn green" value="@Loc["Admin.Common.Save"]"/></div></div></div>diff --git a/src/Plugins/Payments.CashOnDelivery/Areas/Admin/Views/_ViewImports.cshtml b/src/Plugins/Payments.CashOnDelivery/Areas/Admin/Views/_ViewImports.cshtmlindex 2fb08c043..fb3b84aa9 100644--- a/src/Plugins/Payments.CashOnDelivery/Areas/Admin/Views/_ViewImports.cshtml+++ b/src/Plugins/Payments.CashOnDelivery/Areas/Admin/Views/_ViewImports.cshtml@@ -4,5 +4,6 @@@using Microsoft.AspNetCore.Mvc.ViewFeatures@using Grand.Infrastructure.Extensions+@using Grand.Web.Common.Localization-@inject Grand.Web.Common.Localization.LocService Loc+@inject LocService Loc\ No newline at end of filediff --git a/src/Plugins/Payments.CashOnDelivery/Areas/Admin/Views/_ViewStart.cshtml b/src/Plugins/Payments.CashOnDelivery/Areas/Admin/Views/_ViewStart.cshtmlindex f5d9339f9..734b482f0 100644--- a/src/Plugins/Payments.CashOnDelivery/Areas/Admin/Views/_ViewStart.cshtml+++ b/src/Plugins/Payments.CashOnDelivery/Areas/Admin/Views/_ViewStart.cshtml@@ -1,3 +1,3 @@@{Layout = "";-}+}\ No newline at end of filediff --git a/src/Plugins/Payments.CashOnDelivery/CashOnDeliveryPaymentDefaults.cs b/src/Plugins/Payments.CashOnDelivery/CashOnDeliveryPaymentDefaults.csindex ebd2ae2e8..d4efeec00 100644--- a/src/Plugins/Payments.CashOnDelivery/CashOnDeliveryPaymentDefaults.cs+++ b/src/Plugins/Payments.CashOnDelivery/CashOnDeliveryPaymentDefaults.cs@@ -1,9 +1,8 @@-namespace Payments.CashOnDelivery+namespace Payments.CashOnDelivery;++public static class CashOnDeliveryPaymentDefaults{- public static class CashOnDeliveryPaymentDefaults- {- public const string ProviderSystemName = "Payments.CashOnDelivery";- public const string FriendlyName = "Payments.CashOnDelivery.FriendlyName";- public const string ConfigurationUrl = "/Admin/PaymentCashOnDelivery/Configure";- }-}+ public const string ProviderSystemName = "Payments.CashOnDelivery";+ public const string FriendlyName = "Payments.CashOnDelivery.FriendlyName";+ public const string ConfigurationUrl = "/Admin/PaymentCashOnDelivery/Configure";+}\ No newline at end of filediff --git a/src/Plugins/Payments.CashOnDelivery/CashOnDeliveryPaymentPlugin.cs b/src/Plugins/Payments.CashOnDelivery/CashOnDeliveryPaymentPlugin.csindex d75320def..23d5578d0 100644--- a/src/Plugins/Payments.CashOnDelivery/CashOnDeliveryPaymentPlugin.cs+++ b/src/Plugins/Payments.CashOnDelivery/CashOnDeliveryPaymentPlugin.cs@@ -3,91 +3,113 @@ using Grand.Business.Core.Interfaces.Common.Configuration;using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Infrastructure.Plugins;-namespace Payments.CashOnDelivery+namespace Payments.CashOnDelivery;++/// <summary>+/// CashOnDelivery payment processor+/// </summary>+public class CashOnDeliveryPaymentPlugin : BasePlugin, IPlugin{+ #region Ctor++ public CashOnDeliveryPaymentPlugin(+ ISettingService settingService,+ ITranslationService translationService,+ ILanguageService languageService)+ {+ _settingService = settingService;+ _translationService = translationService;+ _languageService = languageService;+ }++ #endregion++ #region Fields++ private readonly ISettingService _settingService;+ private readonly ITranslationService _translationService;+ private readonly ILanguageService _languageService;++ #endregion++ #region Methods+/// <summary>- /// CashOnDelivery payment processor+ /// Gets a configuration page URL/// </summary>- public class CashOnDeliveryPaymentPlugin : BasePlugin, IPlugin+ public override string ConfigurationUrl(){- #region Fields-- private readonly ISettingService _settingService;- private readonly ITranslationService _translationService;- private readonly ILanguageService _languageService;-- #endregion-- #region Ctor-- public CashOnDeliveryPaymentPlugin(- ISettingService settingService,- ITranslationService translationService,- ILanguageService languageService)- {- _settingService = settingService;- _translationService = translationService;- _languageService = languageService;- }-- #endregion-- #region Methods-- /// <summary>- /// Gets a configuration page URL- /// </summary>- public override string ConfigurationUrl()- {- return CashOnDeliveryPaymentDefaults.ConfigurationUrl;- }-- public override async Task Install()- {- var settings = new CashOnDeliveryPaymentSettings- {- DescriptionText = "<p>In cases where an order is placed, an authorized representative will contact you, personally or over telephone, to confirm the order.<br />After the order is confirmed, it will be processed.<br />Orders once confirmed, cannot be cancelled.</p><p>P.S. You can edit this text from admin panel.</p>"- };- await _settingService.SaveSetting(settings);- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Payments.CashOnDelivery.FriendlyName", "Cash on delivery");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.DescriptionText", "Description");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.DescriptionText.Hint", "Enter info that will be shown to customers during checkout");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.PaymentMethodDescription", "Cash On Delivery");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.AdditionalFee", "Additional fee");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.AdditionalFee.Hint", "The additional fee.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.AdditionalFeePercentage", "Additional fee. Use percentage");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.AdditionalFeePercentage.Hint", "Determines whether to apply a percentage additional fee to the order total. If not enabled, a fixed value is used.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.ShippableProductRequired", "Shippable product required");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.ShippableProductRequired.Hint", "An option indicating whether shippable products are required in order to display this payment method during checkout.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.SkipPaymentInfo", "Skip payment info");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.DisplayOrder", "Display order");--- await base.Install();- }-- public override async Task Uninstall()- {- //settings- await _settingService.DeleteSetting<CashOnDeliveryPaymentSettings>();-- //locales- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.DescriptionText");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.DescriptionText.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.PaymentMethodDescription");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.AdditionalFee");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.AdditionalFee.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.AdditionalFeePercentage");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.AdditionalFeePercentage.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.ShippableProductRequired");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.ShippableProductRequired.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Payment.CashOnDelivery.SkipPaymentInfo");-- await base.Uninstall();- }-- #endregion+ return CashOnDeliveryPaymentDefaults.ConfigurationUrl;+ }+ public override async Task Install()+ {+ var settings = new CashOnDeliveryPaymentSettings {+ DescriptionText =+ "<p>In cases where an order is placed, an authorized representative will contact you, personally or over telephone, to confirm the order.<br />After the order is confirmed, it will be processed.<br />Orders once confirmed, cannot be cancelled.</p><p>P.S. You can edit this text from admin panel.</p>"+ };+ await _settingService.SaveSetting(settings);+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Payments.CashOnDelivery.FriendlyName", "Cash on delivery");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.DescriptionText", "Description");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.DescriptionText.Hint",+ "Enter info that will be shown to customers during checkout");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.PaymentMethodDescription", "Cash On Delivery");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.AdditionalFee", "Additional fee");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.AdditionalFee.Hint", "The additional fee.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.AdditionalFeePercentage", "Additional fee. Use percentage");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.AdditionalFeePercentage.Hint",+ "Determines whether to apply a percentage additional fee to the order total. If not enabled, a fixed value is used.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.ShippableProductRequired", "Shippable product required");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.ShippableProductRequired.Hint",+ "An option indicating whether shippable products are required in order to display this payment method during checkout.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.SkipPaymentInfo", "Skip payment info");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.DisplayOrder", "Display order");+++ await base.Install();+ }+ public override async Task Uninstall()+ {+ //settings+ await _settingService.DeleteSetting<CashOnDeliveryPaymentSettings>();++ //locales+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.DescriptionText");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.DescriptionText.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.PaymentMethodDescription");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.AdditionalFee");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.AdditionalFee.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.AdditionalFeePercentage");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.AdditionalFeePercentage.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.ShippableProductRequired");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.ShippableProductRequired.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Payment.CashOnDelivery.SkipPaymentInfo");++ await base.Uninstall();}++ #endregion}\ No newline at end of filediff --git a/src/Plugins/Payments.CashOnDelivery/CashOnDeliveryPaymentProvider.cs b/src/Plugins/Payments.CashOnDelivery/CashOnDeliveryPaymentProvider.csindex 38cd4730c..f14152467 100644--- a/src/Plugins/Payments.CashOnDelivery/CashOnDeliveryPaymentProvider.cs+++ b/src/Plugins/Payments.CashOnDelivery/CashOnDeliveryPaymentProvider.cs@@ -1,201 +1,204 @@using Grand.Business.Core.Enums.Checkout;using Grand.Business.Core.Interfaces.Checkout.Orders;using Grand.Business.Core.Interfaces.Checkout.Payments;-using Grand.Business.Core.Utilities.Checkout;using Grand.Business.Core.Interfaces.Common.Directory;using Grand.Business.Core.Interfaces.Common.Localization;+using Grand.Business.Core.Utilities.Checkout;using Grand.Domain.Orders;using Grand.Domain.Payments;using Grand.Infrastructure;using Microsoft.AspNetCore.Http;using Microsoft.Extensions.DependencyInjection;-namespace Payments.CashOnDelivery+namespace Payments.CashOnDelivery;++public class CashOnDeliveryPaymentProvider : IPaymentProvider{- public class CashOnDeliveryPaymentProvider : IPaymentProvider+ private readonly CashOnDeliveryPaymentSettings _cashOnDeliveryPaymentSettings;+ private readonly IHttpContextAccessor _httpContextAccessor;+ private readonly ITranslationService _translationService;++ public CashOnDeliveryPaymentProvider(+ ITranslationService translationService,+ IHttpContextAccessor httpContextAccessor,+ CashOnDeliveryPaymentSettings cashOnDeliveryPaymentSettings){- private readonly ITranslationService _translationService;- private readonly IHttpContextAccessor _httpContextAccessor;+ _translationService = translationService;+ _httpContextAccessor = httpContextAccessor;+ _cashOnDeliveryPaymentSettings = cashOnDeliveryPaymentSettings;+ }- private readonly CashOnDeliveryPaymentSettings _cashOnDeliveryPaymentSettings;+ public string ConfigurationUrl => CashOnDeliveryPaymentDefaults.ConfigurationUrl;- public CashOnDeliveryPaymentProvider(- ITranslationService translationService,- IHttpContextAccessor httpContextAccessor,- CashOnDeliveryPaymentSettings cashOnDeliveryPaymentSettings)- {- _translationService = translationService;- _httpContextAccessor = httpContextAccessor;- _cashOnDeliveryPaymentSettings = cashOnDeliveryPaymentSettings;- }+ public string SystemName => CashOnDeliveryPaymentDefaults.ProviderSystemName;- public string ConfigurationUrl => CashOnDeliveryPaymentDefaults.ConfigurationUrl;+ public string FriendlyName => _translationService.GetResource(CashOnDeliveryPaymentDefaults.FriendlyName);- public string SystemName => CashOnDeliveryPaymentDefaults.ProviderSystemName;+ public int Priority => _cashOnDeliveryPaymentSettings.DisplayOrder;- public string FriendlyName => _translationService.GetResource(CashOnDeliveryPaymentDefaults.FriendlyName);+ public IList<string> LimitedToStores => new List<string>();- public int Priority => _cashOnDeliveryPaymentSettings.DisplayOrder;+ public IList<string> LimitedToGroups => new List<string>();- public IList<string> LimitedToStores => new List<string>();+ /// <summary>+ /// Init a process a payment transaction+ /// </summary>+ /// <returns>Payment transaction</returns>+ public async Task<PaymentTransaction> InitPaymentTransaction()+ {+ return await Task.FromResult<PaymentTransaction>(null);+ }- public IList<string> LimitedToGroups => new List<string>();+ public async Task<ProcessPaymentResult> ProcessPayment(PaymentTransaction paymentTransaction)+ {+ var result = new ProcessPaymentResult {+ NewPaymentTransactionStatus = TransactionStatus.Pending+ };+ return await Task.FromResult(result);+ }- /// <summary>- /// Init a process a payment transaction- /// </summary>- /// <returns>Payment transaction</returns>- public async Task<PaymentTransaction> InitPaymentTransaction()- {- return await Task.FromResult<PaymentTransaction>(null);- }- public async Task<ProcessPaymentResult> ProcessPayment(PaymentTransaction paymentTransaction)- {- var result = new ProcessPaymentResult {- NewPaymentTransactionStatus = TransactionStatus.Pending- };- return await Task.FromResult(result);- }+ public Task PostProcessPayment(PaymentTransaction paymentTransaction)+ {+ //nothing+ return Task.CompletedTask;+ }- public Task PostProcessPayment(PaymentTransaction paymentTransaction)- {- //nothing- return Task.CompletedTask;- }- /// <summary>- /// Post redirect payment (used by payment gateways that redirecting to a another URL)- /// </summary>- /// <param name="paymentTransaction">Payment transaction</param>- public Task PostRedirectPayment(PaymentTransaction paymentTransaction)- {- //nothing- return Task.CompletedTask;- }- public async Task<bool> HidePaymentMethod(IList<ShoppingCartItem> cart)- {- if (_cashOnDeliveryPaymentSettings.ShippableProductRequired && !cart.RequiresShipping())- return true;+ /// <summary>+ /// Post redirect payment (used by payment gateways that redirecting to a another URL)+ /// </summary>+ /// <param name="paymentTransaction">Payment transaction</param>+ public Task PostRedirectPayment(PaymentTransaction paymentTransaction)+ {+ //nothing+ return Task.CompletedTask;+ }- return await Task.FromResult(false);- }+ public async Task<bool> HidePaymentMethod(IList<ShoppingCartItem> cart)+ {+ if (_cashOnDeliveryPaymentSettings.ShippableProductRequired && !cart.RequiresShipping())+ return true;- public async Task<double> GetAdditionalHandlingFee(IList<ShoppingCartItem> cart)- {- if (_cashOnDeliveryPaymentSettings.AdditionalFee <= 0)- return _cashOnDeliveryPaymentSettings.AdditionalFee;-- double result;- if (_cashOnDeliveryPaymentSettings.AdditionalFeePercentage)- {- //percentage- var orderTotalCalculationService = _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<IOrderCalculationService>();- var subtotal = await orderTotalCalculationService.GetShoppingCartSubTotal(cart, true);- result = (float)subtotal.subTotalWithDiscount * (float)_cashOnDeliveryPaymentSettings.AdditionalFee / 100f;- }- else- {- //fixed value- result = _cashOnDeliveryPaymentSettings.AdditionalFee;- }-- if (!(result > 0)) return result;- var currencyService = _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<ICurrencyService>();- var workContext = _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<IWorkContext>();- result = await currencyService.ConvertFromPrimaryStoreCurrency(result, workContext.WorkingCurrency);-- //return result;- return result;- }+ return await Task.FromResult(false);+ }- public async Task<IList<string>> ValidatePaymentForm(IDictionary<string, string> model)- {- var warnings = new List<string>();- return await Task.FromResult(warnings);- }+ public async Task<double> GetAdditionalHandlingFee(IList<ShoppingCartItem> cart)+ {+ if (_cashOnDeliveryPaymentSettings.AdditionalFee <= 0)+ return _cashOnDeliveryPaymentSettings.AdditionalFee;- public async Task<PaymentTransaction> SavePaymentInfo(IDictionary<string, string> model)+ double result;+ if (_cashOnDeliveryPaymentSettings.AdditionalFeePercentage){- return await Task.FromResult<PaymentTransaction>(null);+ //percentage+ var orderTotalCalculationService = _httpContextAccessor.HttpContext!.RequestServices+ .GetRequiredService<IOrderCalculationService>();+ var subtotal = await orderTotalCalculationService.GetShoppingCartSubTotal(cart, true);+ result = (float)subtotal.subTotalWithDiscount * (float)_cashOnDeliveryPaymentSettings.AdditionalFee / 100f;}-- public Task<string> GetControllerRouteName()+ else{- return Task.FromResult("Plugin.PaymentCashOnDelivery");+ //fixed value+ result = _cashOnDeliveryPaymentSettings.AdditionalFee;}- public async Task<CapturePaymentResult> Capture(PaymentTransaction paymentTransaction)- {- var result = new CapturePaymentResult();- result.AddError("Capture method not supported");- return await Task.FromResult(result);- }+ if (!(result > 0)) return result;+ var currencyService = _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<ICurrencyService>();+ var workContext = _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<IWorkContext>();+ result = await currencyService.ConvertFromPrimaryStoreCurrency(result, workContext.WorkingCurrency);- public async Task<bool> CanRePostRedirectPayment(PaymentTransaction paymentTransaction)- {- ArgumentNullException.ThrowIfNull(paymentTransaction);+ //return result;+ return result;+ }- //it's not a redirection payment method. So we always return false- return await Task.FromResult(false);- }+ public async Task<IList<string>> ValidatePaymentForm(IDictionary<string, string> model)+ {+ var warnings = new List<string>();+ return await Task.FromResult(warnings);+ }- public async Task<RefundPaymentResult> Refund(RefundPaymentRequest refundPaymentRequest)- {- var result = new RefundPaymentResult();- result.AddError("Refund method not supported");- return await Task.FromResult(result);- }+ public async Task<PaymentTransaction> SavePaymentInfo(IDictionary<string, string> model)+ {+ return await Task.FromResult<PaymentTransaction>(null);+ }- public async Task<VoidPaymentResult> Void(PaymentTransaction paymentTransaction)- {- var result = new VoidPaymentResult();- result.AddError("Void method not supported");- return await Task.FromResult(result);- }+ public Task<string> GetControllerRouteName()+ {+ return Task.FromResult("Plugin.PaymentCashOnDelivery");+ }- /// <summary>- /// Cancel a payment- /// </summary>- /// <returns>Result</returns>- public async Task CancelPayment(PaymentTransaction paymentTransaction)- {- var paymentTransactionService = _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<IPaymentTransactionService>();- paymentTransaction.TransactionStatus = TransactionStatus.Canceled;- await paymentTransactionService.UpdatePaymentTransaction(paymentTransaction);- }+ public async Task<CapturePaymentResult> Capture(PaymentTransaction paymentTransaction)+ {+ var result = new CapturePaymentResult();+ result.AddError("Capture method not supported");+ return await Task.FromResult(result);+ }- public async Task<bool> SupportCapture()- {- return await Task.FromResult(false);- }+ public async Task<bool> CanRePostRedirectPayment(PaymentTransaction paymentTransaction)+ {+ ArgumentNullException.ThrowIfNull(paymentTransaction);- public async Task<bool> SupportPartiallyRefund()- {- return await Task.FromResult(false);- }+ //it's not a redirection payment method. So we always return false+ return await Task.FromResult(false);+ }- public async Task<bool> SupportRefund()- {- return await Task.FromResult(false);- }+ public async Task<RefundPaymentResult> Refund(RefundPaymentRequest refundPaymentRequest)+ {+ var result = new RefundPaymentResult();+ result.AddError("Refund method not supported");+ return await Task.FromResult(result);+ }- public async Task<bool> SupportVoid()- {- return await Task.FromResult(false);- }+ public async Task<VoidPaymentResult> Void(PaymentTransaction paymentTransaction)+ {+ var result = new VoidPaymentResult();+ result.AddError("Void method not supported");+ return await Task.FromResult(result);+ }- public PaymentMethodType PaymentMethodType => PaymentMethodType.Standard;+ /// <summary>+ /// Cancel a payment+ /// </summary>+ /// <returns>Result</returns>+ public async Task CancelPayment(PaymentTransaction paymentTransaction)+ {+ var paymentTransactionService = _httpContextAccessor.HttpContext!.RequestServices+ .GetRequiredService<IPaymentTransactionService>();+ paymentTransaction.TransactionStatus = TransactionStatus.Canceled;+ await paymentTransactionService.UpdatePaymentTransaction(paymentTransaction);+ }- public async Task<bool> SkipPaymentInfo()- {- return await Task.FromResult(_cashOnDeliveryPaymentSettings.SkipPaymentInfo);- }+ public async Task<bool> SupportCapture()+ {+ return await Task.FromResult(false);+ }- public async Task<string> Description()- {- return await Task.FromResult(_translationService.GetResource("Plugins.Payment.CashOnDelivery.PaymentMethodDescription"));- }+ public async Task<bool> SupportPartiallyRefund()+ {+ return await Task.FromResult(false);+ }- public string LogoURL => "/Plugins/Payments.CashOnDelivery/logo.jpg";+ public async Task<bool> SupportRefund()+ {+ return await Task.FromResult(false);+ }++ public async Task<bool> SupportVoid()+ {+ return await Task.FromResult(false);+ }++ public PaymentMethodType PaymentMethodType => PaymentMethodType.Standard;+ public async Task<bool> SkipPaymentInfo()+ {+ return await Task.FromResult(_cashOnDeliveryPaymentSettings.SkipPaymentInfo);}-}++ public async Task<string> Description()+ {+ return await Task.FromResult(+ _translationService.GetResource("Plugins.Payment.CashOnDelivery.PaymentMethodDescription"));+ }++ public string LogoURL => "/Plugins/Payments.CashOnDelivery/logo.jpg";+}\ No newline at end of filediff --git a/src/Plugins/Payments.CashOnDelivery/CashOnDeliveryPaymentSettings.cs b/src/Plugins/Payments.CashOnDelivery/CashOnDeliveryPaymentSettings.csindex fbf5145a8..a9c651680 100644--- a/src/Plugins/Payments.CashOnDelivery/CashOnDeliveryPaymentSettings.cs+++ b/src/Plugins/Payments.CashOnDelivery/CashOnDeliveryPaymentSettings.cs@@ -1,25 +1,29 @@using Grand.Domain.Configuration;-namespace Payments.CashOnDelivery+namespace Payments.CashOnDelivery;++public class CashOnDeliveryPaymentSettings : ISettings{- public class CashOnDeliveryPaymentSettings : ISettings- {- public int DisplayOrder { get; set; }+ public int DisplayOrder { get; set; }++ public string DescriptionText { get; set; }++ /// <summary>+ /// Gets or sets a value indicating whether to "additional fee" is specified as percentage. true - percentage, false -+ /// fixed value.+ /// </summary>+ public bool AdditionalFeePercentage { get; set; }++ /// <summary>+ /// Additional fee+ /// </summary>+ public double AdditionalFee { get; set; }- public string DescriptionText { get; set; }- /// <summary>- /// Gets or sets a value indicating whether to "additional fee" is specified as percentage. true - percentage, false - fixed value.- /// </summary>- public bool AdditionalFeePercentage { get; set; }- /// <summary>- /// Additional fee- /// </summary>- public double AdditionalFee { get; set; }- /// <summary>- /// Gets or sets a value indicating whether shippable products are required in order to display this payment method during checkout- /// </summary>- public bool ShippableProductRequired { get; set; }+ /// <summary>+ /// Gets or sets a value indicating whether shippable products are required in order to display this payment method+ /// during checkout+ /// </summary>+ public bool ShippableProductRequired { get; set; }- public bool SkipPaymentInfo { get; set; }- }-}+ public bool SkipPaymentInfo { get; set; }+}\ No newline at end of filediff --git a/src/Plugins/Payments.CashOnDelivery/Controllers/PaymentCashOnDeliveryController.cs b/src/Plugins/Payments.CashOnDelivery/Controllers/PaymentCashOnDeliveryController.csindex 2a7d1993a..2e43d9954 100644--- a/src/Plugins/Payments.CashOnDelivery/Controllers/PaymentCashOnDeliveryController.cs+++ b/src/Plugins/Payments.CashOnDelivery/Controllers/PaymentCashOnDeliveryController.cs@@ -4,30 +4,30 @@ using Grand.Web.Common.Controllers;using Microsoft.AspNetCore.Mvc;using Payments.CashOnDelivery.Models;-namespace Payments.CashOnDelivery.Controllers+namespace Payments.CashOnDelivery.Controllers;++public class PaymentCashOnDeliveryController : BasePaymentController{- public class PaymentCashOnDeliveryController : BasePaymentController- {- private readonly IWorkContext _workContext;- private readonly ISettingService _settingService;+ private readonly ISettingService _settingService;+ private readonly IWorkContext _workContext;- public PaymentCashOnDeliveryController(- IWorkContext workContext,- ISettingService settingService)- {- _workContext = workContext;- _settingService = settingService;- }+ public PaymentCashOnDeliveryController(+ IWorkContext workContext,+ ISettingService settingService)+ {+ _workContext = workContext;+ _settingService = settingService;+ }- public IActionResult PaymentInfo()- {- var cashOnDeliveryPaymentSettings = _settingService.LoadSetting<CashOnDeliveryPaymentSettings>(_workContext.CurrentStore.Id);+ public IActionResult PaymentInfo()+ {+ var cashOnDeliveryPaymentSettings =+ _settingService.LoadSetting<CashOnDeliveryPaymentSettings>(_workContext.CurrentStore.Id);- var model = new PaymentInfoModel {- DescriptionText = cashOnDeliveryPaymentSettings.DescriptionText- };+ var model = new PaymentInfoModel {+ DescriptionText = cashOnDeliveryPaymentSettings.DescriptionText+ };- return View(model);- }+ return View(model);}}\ No newline at end of filediff --git a/src/Plugins/Payments.CashOnDelivery/EndpointProvider.cs b/src/Plugins/Payments.CashOnDelivery/EndpointProvider.csindex bda0bb361..cca45d1c9 100644--- a/src/Plugins/Payments.CashOnDelivery/EndpointProvider.cs+++ b/src/Plugins/Payments.CashOnDelivery/EndpointProvider.cs@@ -2,18 +2,17 @@using Microsoft.AspNetCore.Builder;using Microsoft.AspNetCore.Routing;-namespace Payments.CashOnDelivery+namespace Payments.CashOnDelivery;++public class EndpointProvider : IEndpointProvider{- public class EndpointProvider : IEndpointProvider+ public void RegisterEndpoint(IEndpointRouteBuilder endpointRouteBuilder){- public void RegisterEndpoint(IEndpointRouteBuilder endpointRouteBuilder)- {- endpointRouteBuilder.MapControllerRoute("Plugin.PaymentCashOnDelivery",- "Plugins/PaymentCashOnDelivery/PaymentInfo",- new { controller = "PaymentCashOnDelivery", action = "PaymentInfo", area = "" }- );- }- public int Priority => 0;-+ endpointRouteBuilder.MapControllerRoute("Plugin.PaymentCashOnDelivery",+ "Plugins/PaymentCashOnDelivery/PaymentInfo",+ new { controller = "PaymentCashOnDelivery", action = "PaymentInfo", area = "" }+ );}-}++ public int Priority => 0;+}\ No newline at end of filediff --git a/src/Plugins/Payments.CashOnDelivery/Models/ConfigurationModel.cs b/src/Plugins/Payments.CashOnDelivery/Models/ConfigurationModel.csindex 3ed6e8745..5cba1d033 100644--- a/src/Plugins/Payments.CashOnDelivery/Models/ConfigurationModel.cs+++ b/src/Plugins/Payments.CashOnDelivery/Models/ConfigurationModel.cs@@ -1,43 +1,42 @@-using Grand.Web.Common.Models;-using Grand.Infrastructure.ModelBinding;+using Grand.Infrastructure.ModelBinding;using Grand.Infrastructure.Models;+using Grand.Web.Common.Models;-namespace Payments.CashOnDelivery.Models+namespace Payments.CashOnDelivery.Models;++public class ConfigurationModel : BaseModel, ILocalizedModel<ConfigurationModel.ConfigurationLocalizedModel>{- public class ConfigurationModel : BaseModel, ILocalizedModel<ConfigurationModel.ConfigurationLocalizedModel>- {- public string ActiveStore { get; set; }+ public string ActiveStore { get; set; }- [GrandResourceDisplayName("Plugins.Payment.CashOnDelivery.DescriptionText")]- public string DescriptionText { get; set; }+ [GrandResourceDisplayName("Plugins.Payment.CashOnDelivery.DescriptionText")]+ public string DescriptionText { get; set; }- [GrandResourceDisplayName("Plugins.Payment.CashOnDelivery.AdditionalFee")]- public double AdditionalFee { get; set; }+ [GrandResourceDisplayName("Plugins.Payment.CashOnDelivery.AdditionalFee")]+ public double AdditionalFee { get; set; }- [GrandResourceDisplayName("Plugins.Payment.CashOnDelivery.AdditionalFeePercentage")]- public bool AdditionalFeePercentage { get; set; }+ [GrandResourceDisplayName("Plugins.Payment.CashOnDelivery.AdditionalFeePercentage")]+ public bool AdditionalFeePercentage { get; set; }- [GrandResourceDisplayName("Plugins.Payment.CashOnDelivery.ShippableProductRequired")]- public bool ShippableProductRequired { get; set; }+ [GrandResourceDisplayName("Plugins.Payment.CashOnDelivery.ShippableProductRequired")]+ public bool ShippableProductRequired { get; set; }- [GrandResourceDisplayName("Plugins.Payment.CashOnDelivery.DisplayOrder")]- public int DisplayOrder { get; set; }+ [GrandResourceDisplayName("Plugins.Payment.CashOnDelivery.DisplayOrder")]+ public int DisplayOrder { get; set; }- [GrandResourceDisplayName("Plugins.Payment.CashOnDelivery.SkipPaymentInfo")]- public bool SkipPaymentInfo { get; set; }-- public IList<ConfigurationLocalizedModel> Locales { get; set; } = new List<ConfigurationLocalizedModel>();+ [GrandResourceDisplayName("Plugins.Payment.CashOnDelivery.SkipPaymentInfo")]+ public bool SkipPaymentInfo { get; set; }- #region Nested class+ public IList<ConfigurationLocalizedModel> Locales { get; set; } = new List<ConfigurationLocalizedModel>();- public class ConfigurationLocalizedModel : ILocalizedModelLocal- {- public string LanguageId { get; set; }+ #region Nested class- [GrandResourceDisplayName("Plugins.Payment.CashOnDelivery.DescriptionText")]- public string DescriptionText { get; set; }- }+ public class ConfigurationLocalizedModel : ILocalizedModelLocal+ {+ [GrandResourceDisplayName("Plugins.Payment.CashOnDelivery.DescriptionText")]+ public string DescriptionText { get; set; }- #endregion+ public string LanguageId { get; set; }}++ #endregion}\ No newline at end of filediff --git a/src/Plugins/Payments.CashOnDelivery/Models/PaymentInfoModel.cs b/src/Plugins/Payments.CashOnDelivery/Models/PaymentInfoModel.csindex 99e08c494..8a42e327f 100644--- a/src/Plugins/Payments.CashOnDelivery/Models/PaymentInfoModel.cs+++ b/src/Plugins/Payments.CashOnDelivery/Models/PaymentInfoModel.cs@@ -1,9 +1,8 @@using Grand.Infrastructure.Models;-namespace Payments.CashOnDelivery.Models+namespace Payments.CashOnDelivery.Models;++public class PaymentInfoModel : BaseModel{- public class PaymentInfoModel : BaseModel- {- public string DescriptionText { get; set; }- }+ public string DescriptionText { get; set; }}\ No newline at end of filediff --git a/src/Plugins/Payments.CashOnDelivery/StartupApplication.cs b/src/Plugins/Payments.CashOnDelivery/StartupApplication.csindex e6782c51b..33aa8f03c 100644--- a/src/Plugins/Payments.CashOnDelivery/StartupApplication.cs+++ b/src/Plugins/Payments.CashOnDelivery/StartupApplication.cs@@ -5,21 +5,20 @@ using Microsoft.AspNetCore.Hosting;using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;-namespace Payments.CashOnDelivery+namespace Payments.CashOnDelivery;++public class StartupApplication : IStartupApplication{- public class StartupApplication : IStartupApplication+ public void ConfigureServices(IServiceCollection services, IConfiguration configuration){- public void ConfigureServices(IServiceCollection services, IConfiguration configuration)- {- services.AddScoped<IPaymentProvider, CashOnDeliveryPaymentProvider>();- }+ services.AddScoped<IPaymentProvider, CashOnDeliveryPaymentProvider>();+ }- public int Priority => 10;- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)- {+ public int Priority => 10;- }- public bool BeforeConfigure => false;+ public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)+ {}-}+ public bool BeforeConfigure => false;+}\ No newline at end of filediff --git a/src/Plugins/Payments.CashOnDelivery/Views/PaymentCashOnDelivery/PaymentInfo.cshtml b/src/Plugins/Payments.CashOnDelivery/Views/PaymentCashOnDelivery/PaymentInfo.cshtmlindex 738ce4a19..c7e698c76 100644--- a/src/Plugins/Payments.CashOnDelivery/Views/PaymentCashOnDelivery/PaymentInfo.cshtml+++ b/src/Plugins/Payments.CashOnDelivery/Views/PaymentCashOnDelivery/PaymentInfo.cshtml@@ -4,4 +4,4 @@@model Payments.CashOnDelivery.Models.PaymentInfoModel<div>@Html.Raw(Model.DescriptionText)-</div>+</div>\ No newline at end of filediff --git a/src/Plugins/Payments.StripeCheckout/Areas/Admin/Controllers/StripeCheckoutController.cs b/src/Plugins/Payments.StripeCheckout/Areas/Admin/Controllers/StripeCheckoutController.csindex 8a410cfbc..ea853e4e5 100644--- a/src/Plugins/Payments.StripeCheckout/Areas/Admin/Controllers/StripeCheckoutController.cs+++ b/src/Plugins/Payments.StripeCheckout/Areas/Admin/Controllers/StripeCheckoutController.cs@@ -19,11 +19,11 @@ namespace Payments.StripeCheckout.Areas.Admin.Controllers;[PermissionAuthorize(PermissionSystemName.PaymentMethods)]public class StripeCheckoutController : BasePaymentController{- private readonly IWorkContext _workContext;- private readonly IStoreService _storeService;+ private readonly IPermissionService _permissionService;private readonly ISettingService _settingService;+ private readonly IStoreService _storeService;private readonly ITranslationService _translationService;- private readonly IPermissionService _permissionService;+ private readonly IWorkContext _workContext;public StripeCheckoutController(IWorkContext workContext,IStoreService storeService,diff --git a/src/Plugins/Payments.StripeCheckout/Areas/Admin/Views/StripeCheckout/Configure.cshtml b/src/Plugins/Payments.StripeCheckout/Areas/Admin/Views/StripeCheckout/Configure.cshtmlindex 8b35bdb93..70a527373 100644--- a/src/Plugins/Payments.StripeCheckout/Areas/Admin/Views/StripeCheckout/Configure.cshtml+++ b/src/Plugins/Payments.StripeCheckout/Areas/Admin/Views/StripeCheckout/Configure.cshtml@@ -6,12 +6,11 @@var urlHelper = UrlHelperFactory.GetUrlHelper(ActionContextAccessor.ActionContext!);var webhookUrl = WorkContext.CurrentHost.Url.TrimEnd('/') + urlHelper.RouteUrl(StripeCheckoutDefaults.WebHook);}-@model ConfigurationModel-@using Microsoft.AspNetCore.Mvc.Routing+@using Grand.Infrastructure@using Microsoft.AspNetCore.Mvc.Infrastructure+@using Microsoft.AspNetCore.Mvc.Routing@using Payments.StripeCheckout-@using Payments.StripeCheckout.Models-@using Grand.Infrastructure+@model Payments.StripeCheckout.Models.ConfigurationModel@await Component.InvokeAsync("StoreScope")<form asp-area="Admin" asp-controller="StripeCheckout" asp-action="Configure" method="post">diff --git a/src/Plugins/Payments.StripeCheckout/Areas/Admin/Views/_ViewImports.cshtml b/src/Plugins/Payments.StripeCheckout/Areas/Admin/Views/_ViewImports.cshtmlindex 2fb08c043..fb3b84aa9 100644--- a/src/Plugins/Payments.StripeCheckout/Areas/Admin/Views/_ViewImports.cshtml+++ b/src/Plugins/Payments.StripeCheckout/Areas/Admin/Views/_ViewImports.cshtml@@ -4,5 +4,6 @@@using Microsoft.AspNetCore.Mvc.ViewFeatures@using Grand.Infrastructure.Extensions+@using Grand.Web.Common.Localization-@inject Grand.Web.Common.Localization.LocService Loc+@inject LocService Loc\ No newline at end of filediff --git a/src/Plugins/Payments.StripeCheckout/Controllers/PaymentStripeCheckoutController.cs b/src/Plugins/Payments.StripeCheckout/Controllers/PaymentStripeCheckoutController.csindex 404a5a386..a8159047d 100644--- a/src/Plugins/Payments.StripeCheckout/Controllers/PaymentStripeCheckoutController.cs+++ b/src/Plugins/Payments.StripeCheckout/Controllers/PaymentStripeCheckoutController.cs@@ -12,14 +12,14 @@ namespace Payments.StripeCheckout.Controllers;public class PaymentStripeCheckoutController : BasePaymentController{- private readonly IWorkContext _workContext;- private readonly IOrderService _orderService;- private readonly IStripeCheckoutService _stripeCheckoutService;private readonly ILogger<PaymentStripeCheckoutController> _logger;- private readonly IPaymentTransactionService _paymentTransactionService;- private readonly StripeCheckoutPaymentSettings _stripeCheckoutPaymentSettings;+ private readonly IOrderService _orderService;private readonly PaymentSettings _paymentSettings;+ private readonly IPaymentTransactionService _paymentTransactionService;+ private readonly StripeCheckoutPaymentSettings _stripeCheckoutPaymentSettings;+ private readonly IStripeCheckoutService _stripeCheckoutService;+ private readonly IWorkContext _workContext;public PaymentStripeCheckoutController(IWorkContext workContext,@@ -47,7 +47,7 @@ public class PaymentStripeCheckoutController : BasePaymentControllerawait _stripeCheckoutService.WebHookProcessPayment(Request.Headers["Stripe-Signature"], json);return Ok();}- catch(Exception e)+ catch (Exception e){return BadRequest(e.Message);}diff --git a/src/Plugins/Payments.StripeCheckout/EndpointProvider.cs b/src/Plugins/Payments.StripeCheckout/EndpointProvider.csindex 051289390..a4f8f1ac7 100644--- a/src/Plugins/Payments.StripeCheckout/EndpointProvider.cs+++ b/src/Plugins/Payments.StripeCheckout/EndpointProvider.cs@@ -8,24 +8,24 @@ public class EndpointProvider : IEndpointProvider{public void RegisterEndpoint(IEndpointRouteBuilder endpointRouteBuilder){- //PaymentInfo- endpointRouteBuilder.MapControllerRoute(StripeCheckoutDefaults.PaymentInfo,- "Plugins/PaymentStripeCheckout/PaymentInfo",- new { controller = "PaymentStripeCheckout", action = "PaymentInfo", area = "" }- );+ //PaymentInfo+ endpointRouteBuilder.MapControllerRoute(StripeCheckoutDefaults.PaymentInfo,+ "Plugins/PaymentStripeCheckout/PaymentInfo",+ new { controller = "PaymentStripeCheckout", action = "PaymentInfo", area = "" }+ );- //WebHook- endpointRouteBuilder.MapControllerRoute(StripeCheckoutDefaults.WebHook,- "Plugins/PaymentStripeCheckout/WebHook",- new { controller = "PaymentStripeCheckout", action = "WebHook", area = "" }- );-- //Cancel- endpointRouteBuilder.MapControllerRoute("Plugin.Payments.StripeCheckout.CancelOrder",- "Plugins/PaymentStripeCheckout/CancelOrder/{orderId}",- new { controller = "PaymentStripeCheckout", action = "CancelOrder", area = "" }- );- }- public int Priority => 0;+ //WebHook+ endpointRouteBuilder.MapControllerRoute(StripeCheckoutDefaults.WebHook,+ "Plugins/PaymentStripeCheckout/WebHook",+ new { controller = "PaymentStripeCheckout", action = "WebHook", area = "" }+ );++ //Cancel+ endpointRouteBuilder.MapControllerRoute("Plugin.Payments.StripeCheckout.CancelOrder",+ "Plugins/PaymentStripeCheckout/CancelOrder/{orderId}",+ new { controller = "PaymentStripeCheckout", action = "CancelOrder", area = "" }+ );+ }+ public int Priority => 0;}\ No newline at end of filediff --git a/src/Plugins/Payments.StripeCheckout/Models/ConfigurationModel.cs b/src/Plugins/Payments.StripeCheckout/Models/ConfigurationModel.csindex 124f0cdba..d4b08f216 100644--- a/src/Plugins/Payments.StripeCheckout/Models/ConfigurationModel.cs+++ b/src/Plugins/Payments.StripeCheckout/Models/ConfigurationModel.cs@@ -6,10 +6,10 @@ namespace Payments.StripeCheckout.Models;public class ConfigurationModel : BaseModel{public string StoreScope { get; set; }-+[GrandResourceDisplayName("Plugins.Payments.StripeCheckout.Fields.ApiKey")]public string ApiKey { get; set; }-+[GrandResourceDisplayName("Plugins.Payments.StripeCheckout.Fields.WebhookEndpointSecret")]public string WebhookEndpointSecret { get; set; }diff --git a/src/Plugins/Payments.StripeCheckout/Models/PaymentInfo.cs b/src/Plugins/Payments.StripeCheckout/Models/PaymentInfo.csindex e41483145..aabdf9829 100644--- a/src/Plugins/Payments.StripeCheckout/Models/PaymentInfo.cs+++ b/src/Plugins/Payments.StripeCheckout/Models/PaymentInfo.cs@@ -1,3 +1,3 @@namespace Payments.StripeCheckout.Models;-public record PaymentInfo(string Description);+public record PaymentInfo(string Description);\ No newline at end of filediff --git a/src/Plugins/Payments.StripeCheckout/Services/StripeCheckoutService.cs b/src/Plugins/Payments.StripeCheckout/Services/StripeCheckoutService.csindex d5a63c2ff..11e8c84d3 100644--- a/src/Plugins/Payments.StripeCheckout/Services/StripeCheckoutService.cs+++ b/src/Plugins/Payments.StripeCheckout/Services/StripeCheckoutService.cs@@ -11,11 +11,11 @@ namespace Payments.StripeCheckout.Services;public class StripeCheckoutService : IStripeCheckoutService{- private readonly StripeCheckoutPaymentSettings _stripeCheckoutPaymentSettings;- private readonly IWorkContext _workContext;private readonly ILogger<StripeCheckoutService> _logger;private readonly IMediator _mediator;private readonly IPaymentTransactionService _paymentTransactionService;+ private readonly StripeCheckoutPaymentSettings _stripeCheckoutPaymentSettings;+ private readonly IWorkContext _workContext;public StripeCheckoutService(IWorkContext workContext,@@ -56,6 +56,7 @@ public class StripeCheckoutService : IStripeCheckoutService_logger.LogError(e, "StripeException");return false;}+return false;}@@ -76,7 +77,7 @@ public class StripeCheckoutService : IStripeCheckoutServicetry{paymentTransaction.AuthorizationTransactionId = paymentIntent.Id;- paymentTransaction.PaidAmount += (paymentIntent.Amount / 100);+ paymentTransaction.PaidAmount += paymentIntent.Amount / 100;await _mediator.Send(new MarkAsPaidCommand { PaymentTransaction = paymentTransaction });}catch (Exception e)@@ -102,24 +103,24 @@ public class StripeCheckoutService : IStripeCheckoutServicePriceData = new SessionLineItemPriceDataOptions {UnitAmountDecimal = (decimal?)order.OrderTotal * 100,ProductData = new SessionLineItemPriceDataProductDataOptions {- Name = string.Format(_stripeCheckoutPaymentSettings.Line, order.OrderNumber),+ Name = string.Format(_stripeCheckoutPaymentSettings.Line, order.OrderNumber)},- Currency = order.CustomerCurrencyCode,+ Currency = order.CustomerCurrencyCode},- Quantity = 1,+ Quantity = 1}],ClientReferenceId = order.Id,CustomerEmail = order.CustomerEmail,- PaymentIntentData = new SessionPaymentIntentDataOptions() {- Metadata = new Dictionary<string, string> { { "order_guid", order.OrderGuid.ToString() } },+ PaymentIntentData = new SessionPaymentIntentDataOptions {+ Metadata = new Dictionary<string, string> { { "order_guid", order.OrderGuid.ToString() } }},Mode = "payment",SuccessUrl = $"{storeLocation}/orderdetails/{order.Id}",- CancelUrl = $"{storeLocation}/Plugins/PaymentStripeCheckout/CancelOrder/{order.Id}",+ CancelUrl = $"{storeLocation}/Plugins/PaymentStripeCheckout/CancelOrder/{order.Id}"};var service = new SessionService();- Session session = await service.CreateAsync(options);+ var session = await service.CreateAsync(options);return session;}diff --git a/src/Plugins/Payments.StripeCheckout/StartupApplication.cs b/src/Plugins/Payments.StripeCheckout/StartupApplication.csindex 6e5002791..d1706ab64 100644--- a/src/Plugins/Payments.StripeCheckout/StartupApplication.cs+++ b/src/Plugins/Payments.StripeCheckout/StartupApplication.cs@@ -17,9 +17,10 @@ public class StartupApplication : IStartupApplication}public int Priority => 10;+public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment){-}+public bool BeforeConfigure => false;}\ No newline at end of filediff --git a/src/Plugins/Payments.StripeCheckout/StripeCheckoutPaymentPlugin.cs b/src/Plugins/Payments.StripeCheckout/StripeCheckoutPaymentPlugin.csindex 62d690822..9811b9780 100644--- a/src/Plugins/Payments.StripeCheckout/StripeCheckoutPaymentPlugin.cs+++ b/src/Plugins/Payments.StripeCheckout/StripeCheckoutPaymentPlugin.cs@@ -6,18 +6,10 @@ using Grand.Infrastructure.Plugins;namespace Payments.StripeCheckout;/// <summary>-/// StripeCheckout payment processor+/// StripeCheckout payment processor/// </summary>public class StripeCheckoutPaymentPlugin : BasePlugin, IPlugin{- #region Fields-- private readonly ITranslationService _translationService;- private readonly ILanguageService _languageService;- private readonly ISettingService _settingService;-- #endregion-#region Ctorpublic StripeCheckoutPaymentPlugin(@@ -32,10 +24,18 @@ public class StripeCheckoutPaymentPlugin : BasePlugin, IPlugin#endregion+ #region Fields++ private readonly ITranslationService _translationService;+ private readonly ILanguageService _languageService;+ private readonly ISettingService _settingService;++ #endregion+#region Methods/// <summary>- /// Gets a configuration page URL+ /// Gets a configuration page URL/// </summary>public override string ConfigurationUrl(){@@ -43,13 +43,14 @@ public class StripeCheckoutPaymentPlugin : BasePlugin, IPlugin}/// <summary>- /// Install the plugin+ /// Install the plugin/// </summary>public override async Task Install(){//settingsawait _settingService.SaveSetting(new StripeCheckoutPaymentSettings {- Description = "Enjoy seamless transactions with the flexibility to pay using your preferred payment method through Stripe Checkout. We ensure a secure and hassle-free payment experience, accommodating a wide range of payment options to suit your convenience.",+ Description =+ "Enjoy seamless transactions with the flexibility to pay using your preferred payment method through Stripe Checkout. We ensure a secure and hassle-free payment experience, accommodating a wide range of payment options to suit your convenience.",DisplayOrder = 0,Line = "Order number {0}"});@@ -72,7 +73,7 @@ public class StripeCheckoutPaymentPlugin : BasePlugin, IPlugin}/// <summary>- /// Uninstall the plugin+ /// Uninstall the plugin/// </summary>public override async Task Uninstall(){diff --git a/src/Plugins/Payments.StripeCheckout/StripeCheckoutPaymentProvider.cs b/src/Plugins/Payments.StripeCheckout/StripeCheckoutPaymentProvider.csindex b3257fb06..88d16533c 100644--- a/src/Plugins/Payments.StripeCheckout/StripeCheckoutPaymentProvider.cs+++ b/src/Plugins/Payments.StripeCheckout/StripeCheckoutPaymentProvider.cs@@ -1,8 +1,8 @@using Grand.Business.Core.Enums.Checkout;using Grand.Business.Core.Interfaces.Checkout.Orders;using Grand.Business.Core.Interfaces.Checkout.Payments;-using Grand.Business.Core.Utilities.Checkout;using Grand.Business.Core.Interfaces.Common.Localization;+using Grand.Business.Core.Utilities.Checkout;using Grand.Domain.Orders;using Grand.Domain.Payments;using Microsoft.AspNetCore.Http;@@ -12,11 +12,11 @@ namespace Payments.StripeCheckout;public class StripeCheckoutPaymentProvider : IPaymentProvider{- private readonly ITranslationService _translationService;- private readonly IStripeCheckoutService _stripeCheckoutService;- private readonly StripeCheckoutPaymentSettings _stripeCheckoutPaymentSettings;private readonly IHttpContextAccessor _httpContextAccessor;private readonly IOrderService _orderService;+ private readonly StripeCheckoutPaymentSettings _stripeCheckoutPaymentSettings;+ private readonly IStripeCheckoutService _stripeCheckoutService;+ private readonly ITranslationService _translationService;#region Ctor@@ -50,7 +50,7 @@ public class StripeCheckoutPaymentProvider : IPaymentProvider#region Properties/// <summary>- /// Init a process a payment transaction+ /// Init a process a payment transaction/// </summary>/// <returns>Payment transaction</returns>public async Task<PaymentTransaction> InitPaymentTransaction()@@ -59,7 +59,7 @@ public class StripeCheckoutPaymentProvider : IPaymentProvider}/// <summary>- /// Process a payment+ /// Process a payment/// </summary>/// <param name="paymentTransaction"></param>/// <returns>Process payment result</returns>@@ -76,7 +76,7 @@ public class StripeCheckoutPaymentProvider : IPaymentProvider}/// <summary>- /// Post process payment (used by payment gateways that require redirecting to a third-party URL)+ /// Post process payment (used by payment gateways that require redirecting to a third-party URL)/// </summary>/// <param name="paymentTransaction"></param>public async Task PostRedirectPayment(PaymentTransaction paymentTransaction)@@ -87,7 +87,7 @@ public class StripeCheckoutPaymentProvider : IPaymentProvider}/// <summary>- /// Returns a value indicating whether payment method should be hidden during checkout+ /// Returns a value indicating whether payment method should be hidden during checkout/// </summary>/// <param name="cart">Shopping cart</param>/// <returns>true - hide; false - display.</returns>@@ -100,7 +100,7 @@ public class StripeCheckoutPaymentProvider : IPaymentProvider}/// <summary>- /// Gets additional handling fee+ /// Gets additional handling fee/// </summary>/// <param name="cart">Shopping cart</param>/// <returns>Additional handling fee</returns>@@ -110,7 +110,7 @@ public class StripeCheckoutPaymentProvider : IPaymentProvider}/// <summary>- /// Captures payment+ /// Captures payment/// </summary>/// <returns>Capture payment result</returns>public async Task<CapturePaymentResult> Capture(PaymentTransaction paymentTransaction)@@ -121,7 +121,7 @@ public class StripeCheckoutPaymentProvider : IPaymentProvider}/// <summary>- /// Refunds a payment+ /// Refunds a payment/// </summary>/// <param name="refundPaymentRequest">Request</param>/// <returns>Result</returns>@@ -133,7 +133,7 @@ public class StripeCheckoutPaymentProvider : IPaymentProvider}/// <summary>- /// Voids a payment+ /// Voids a payment/// </summary>/// <returns>Result</returns>public async Task<VoidPaymentResult> Void(PaymentTransaction paymentTransaction)@@ -144,7 +144,7 @@ public class StripeCheckoutPaymentProvider : IPaymentProvider}/// <summary>- /// Cancel a payment+ /// Cancel a payment/// </summary>/// <returns>Result</returns>public Task CancelPayment(PaymentTransaction paymentTransaction)@@ -154,7 +154,8 @@ public class StripeCheckoutPaymentProvider : IPaymentProvider/// <summary>- /// Gets a value indicating whether customers can complete a payment after order is placed but not completed (for redirection payment methods)+ /// Gets a value indicating whether customers can complete a payment after order is placed but not completed (for+ /// redirection payment methods)/// </summary>/// <returns>Result</returns>public async Task<bool> CanRePostRedirectPayment(PaymentTransaction paymentTransaction)@@ -167,7 +168,7 @@ public class StripeCheckoutPaymentProvider : IPaymentProvider}/// <summary>- /// Validate payment form+ /// Validate payment form/// </summary>/// <param name="model"></param>/// <returns>List of validating errors</returns>@@ -177,7 +178,7 @@ public class StripeCheckoutPaymentProvider : IPaymentProvider}/// <summary>- /// Get payment information+ /// Get payment information/// </summary>/// <param name="model"></param>/// <returns>Payment info holder</returns>@@ -188,7 +189,7 @@ public class StripeCheckoutPaymentProvider : IPaymentProvider/// <summary>- /// Gets a value indicating whether capture is supported+ /// Gets a value indicating whether capture is supported/// </summary>public async Task<bool> SupportCapture(){@@ -196,7 +197,7 @@ public class StripeCheckoutPaymentProvider : IPaymentProvider}/// <summary>- /// Gets a value indicating whether partial refund is supported+ /// Gets a value indicating whether partial refund is supported/// </summary>public async Task<bool> SupportPartiallyRefund(){@@ -204,7 +205,7 @@ public class StripeCheckoutPaymentProvider : IPaymentProvider}/// <summary>- /// Gets a value indicating whether refund is supported+ /// Gets a value indicating whether refund is supported/// </summary>public async Task<bool> SupportRefund(){@@ -212,7 +213,7 @@ public class StripeCheckoutPaymentProvider : IPaymentProvider}/// <summary>- /// Gets a value indicating whether void is supported+ /// Gets a value indicating whether void is supported/// </summary>public async Task<bool> SupportVoid(){@@ -220,12 +221,12 @@ public class StripeCheckoutPaymentProvider : IPaymentProvider}/// <summary>- /// Gets a payment method type+ /// Gets a payment method type/// </summary>public PaymentMethodType PaymentMethodType => PaymentMethodType.Redirection;/// <summary>- /// Gets a value indicating whether we should display a payment information page for this plugin+ /// Gets a value indicating whether we should display a payment information page for this plugin/// </summary>public async Task<bool> SkipPaymentInfo(){@@ -233,7 +234,7 @@ public class StripeCheckoutPaymentProvider : IPaymentProvider}/// <summary>- /// Gets a payment method description that will be displayed on checkout pages in the public store+ /// Gets a payment method description that will be displayed on checkout pages in the public store/// </summary>public async Task<string> Description(){diff --git a/src/Plugins/Payments.StripeCheckout/Views/_ViewImports.cshtml b/src/Plugins/Payments.StripeCheckout/Views/_ViewImports.cshtmlindex 2fb08c043..fb3b84aa9 100644--- a/src/Plugins/Payments.StripeCheckout/Views/_ViewImports.cshtml+++ b/src/Plugins/Payments.StripeCheckout/Views/_ViewImports.cshtml@@ -4,5 +4,6 @@@using Microsoft.AspNetCore.Mvc.ViewFeatures@using Grand.Infrastructure.Extensions+@using Grand.Web.Common.Localization-@inject Grand.Web.Common.Localization.LocService Loc+@inject LocService Loc\ No newline at end of filediff --git a/src/Plugins/Shipping.ByWeight/Areas/Admin/Controllers/ShippingByWeightController.cs b/src/Plugins/Shipping.ByWeight/Areas/Admin/Controllers/ShippingByWeightController.csindex 713b635f1..af7a45006 100644--- a/src/Plugins/Shipping.ByWeight/Areas/Admin/Controllers/ShippingByWeightController.cs+++ b/src/Plugins/Shipping.ByWeight/Areas/Admin/Controllers/ShippingByWeightController.cs@@ -16,304 +16,320 @@ using Shipping.ByWeight.Domain;using Shipping.ByWeight.Models;using Shipping.ByWeight.Services;-namespace Shipping.ByWeight.Areas.Admin.Controllers+namespace Shipping.ByWeight.Areas.Admin.Controllers;++[AuthorizeAdmin]+[Area("Admin")]+[PermissionAuthorize(PermissionSystemName.ShippingSettings)]+public class ShippingByWeightController : BaseShippingController{- [AuthorizeAdmin]- [Area("Admin")]- [PermissionAuthorize(PermissionSystemName.ShippingSettings)]- public class ShippingByWeightController : BaseShippingController+ private readonly ICountryService _countryService;+ private readonly ICurrencyService _currencyService;+ private readonly CurrencySettings _currencySettings;+ private readonly IMeasureService _measureService;+ private readonly MeasureSettings _measureSettings;+ private readonly ISettingService _settingService;+ private readonly IShippingByWeightService _shippingByWeightService;+ private readonly ByWeightShippingSettings _shippingByWeightSettings;+ private readonly IShippingMethodService _shippingMethodService;+ private readonly IStoreService _storeService;+ private readonly ITranslationService _translationService;+ private readonly IWarehouseService _warehouseService;++ public ShippingByWeightController(+ IWarehouseService warehouseService,+ IShippingMethodService shippingMethodService,+ IStoreService storeService,+ ICountryService countryService,+ ByWeightShippingSettings shippingByWeightSettings,+ IShippingByWeightService shippingByWeightService,+ ISettingService settingService,+ ITranslationService translationService,+ ICurrencyService currencyService,+ CurrencySettings currencySettings,+ IMeasureService measureService,+ MeasureSettings measureSettings){- private readonly IWarehouseService _warehouseService;- private readonly IShippingMethodService _shippingMethodService;- private readonly IStoreService _storeService;- private readonly ICountryService _countryService;- private readonly ByWeightShippingSettings _shippingByWeightSettings;- private readonly IShippingByWeightService _shippingByWeightService;- private readonly ISettingService _settingService;- private readonly ITranslationService _translationService;- private readonly ICurrencyService _currencyService;- private readonly CurrencySettings _currencySettings;- private readonly IMeasureService _measureService;- private readonly MeasureSettings _measureSettings;-- public ShippingByWeightController(- IWarehouseService warehouseService,- IShippingMethodService shippingMethodService,- IStoreService storeService,- ICountryService countryService,- ByWeightShippingSettings shippingByWeightSettings,- IShippingByWeightService shippingByWeightService,- ISettingService settingService,- ITranslationService translationService,- ICurrencyService currencyService,- CurrencySettings currencySettings,- IMeasureService measureService,- MeasureSettings measureSettings)- {- _warehouseService = warehouseService;- _shippingMethodService = shippingMethodService;- _storeService = storeService;- _countryService = countryService;- _shippingByWeightSettings = shippingByWeightSettings;- _shippingByWeightService = shippingByWeightService;- _settingService = settingService;- _translationService = translationService;- _currencyService = currencyService;- _currencySettings = currencySettings;- _measureService = measureService;- _measureSettings = measureSettings;- }- public IActionResult Configure()- {- var model = new ShippingByWeightListModel {- LimitMethodsToCreated = _shippingByWeightSettings.LimitMethodsToCreated,- DisplayOrder = _shippingByWeightSettings.DisplayOrder- };+ _warehouseService = warehouseService;+ _shippingMethodService = shippingMethodService;+ _storeService = storeService;+ _countryService = countryService;+ _shippingByWeightSettings = shippingByWeightSettings;+ _shippingByWeightService = shippingByWeightService;+ _settingService = settingService;+ _translationService = translationService;+ _currencyService = currencyService;+ _currencySettings = currencySettings;+ _measureService = measureService;+ _measureSettings = measureSettings;+ }- return View(model);- }+ public IActionResult Configure()+ {+ var model = new ShippingByWeightListModel {+ LimitMethodsToCreated = _shippingByWeightSettings.LimitMethodsToCreated,+ DisplayOrder = _shippingByWeightSettings.DisplayOrder+ };- [HttpPost]- [AutoValidateAntiforgeryToken]- public async Task<IActionResult> SaveGeneralSettings(ShippingByWeightListModel model)- {- //save settings- _shippingByWeightSettings.LimitMethodsToCreated = model.LimitMethodsToCreated;- _shippingByWeightSettings.DisplayOrder = model.DisplayOrder;+ return View(model);+ }- await _settingService.SaveSetting(_shippingByWeightSettings);+ [HttpPost]+ [AutoValidateAntiforgeryToken]+ public async Task<IActionResult> SaveGeneralSettings(ShippingByWeightListModel model)+ {+ //save settings+ _shippingByWeightSettings.LimitMethodsToCreated = model.LimitMethodsToCreated;+ _shippingByWeightSettings.DisplayOrder = model.DisplayOrder;- return Json(new { Result = true });- }+ await _settingService.SaveSetting(_shippingByWeightSettings);+ return Json(new { Result = true });+ }- [HttpPost]- [AutoValidateAntiforgeryToken]- public async Task<IActionResult> RatesList(DataSourceRequest command)- {- var records = await _shippingByWeightService.GetAll(command.Page - 1, command.PageSize);-- var sbwModel = new List<ShippingByWeightModel>();- foreach (var x in records)- {-- var m = new ShippingByWeightModel- {- Id = x.Id,- StoreId = x.StoreId,- WarehouseId = x.WarehouseId,- ShippingMethodId = x.ShippingMethodId,- CountryId = x.CountryId,- From = x.From,- To = x.To,- AdditionalFixedCost = x.AdditionalFixedCost,- PercentageRateOfSubtotal = x.PercentageRateOfSubtotal,- RatePerWeightUnit = x.RatePerWeightUnit,- LowerWeightLimit = x.LowerWeightLimit- };- //shipping method- var shippingMethod = await _shippingMethodService.GetShippingMethodById(x.ShippingMethodId);- m.ShippingMethodName = shippingMethod != null ? shippingMethod.Name : "Unavailable";- //store- var store = await _storeService.GetStoreById(x.StoreId);- m.StoreName = store != null ? store.Shortcut : "*";- //warehouse- var warehouse = await _warehouseService.GetWarehouseById(x.WarehouseId);- m.WarehouseName = warehouse != null ? warehouse.Name : "*";- //country- var c = await _countryService.GetCountryById(x.CountryId);- m.CountryName = c != null ? c.Name : "*";- //state- var s = c?.StateProvinces.FirstOrDefault(y => y.Id == x.StateProvinceId);- m.StateProvinceName = s != null ? s.Name : "*";- //zip- m.Zip = !string.IsNullOrEmpty(x.Zip) ? x.Zip : "*";--- var htmlSb = new StringBuilder("<div>");- htmlSb.Append($"{_translationService.GetResource("Plugins.Shipping.ByWeight.Fields.From")}: {m.From}");- htmlSb.Append("<br />");- htmlSb.Append($"{_translationService.GetResource("Plugins.Shipping.ByWeight.Fields.To")}: {m.To}");- htmlSb.Append("<br />");- htmlSb.Append($"{_translationService.GetResource("Plugins.Shipping.ByWeight.Fields.AdditionalFixedCost")}: {m.AdditionalFixedCost}");- htmlSb.Append("<br />");- htmlSb.Append($"{_translationService.GetResource("Plugins.Shipping.ByWeight.Fields.RatePerWeightUnit")}: {m.RatePerWeightUnit}");- htmlSb.Append("<br />");- htmlSb.Append($"{_translationService.GetResource("Plugins.Shipping.ByWeight.Fields.LowerWeightLimit")}: {m.LowerWeightLimit}");- htmlSb.Append("<br />");- htmlSb.Append($"{_translationService.GetResource("Plugins.Shipping.ByWeight.Fields.PercentageRateOfSubtotal")}: {m.PercentageRateOfSubtotal}");-- htmlSb.Append("</div>");- m.DataHtml = htmlSb.ToString();-- sbwModel.Add(m);- }- var gridModel = new DataSourceResult- {- Data = sbwModel,- Total = records.TotalCount- };- return Json(gridModel);- }+ [HttpPost]+ [AutoValidateAntiforgeryToken]+ public async Task<IActionResult> RatesList(DataSourceRequest command)+ {+ var records = await _shippingByWeightService.GetAll(command.Page - 1, command.PageSize);- [HttpPost]- [AutoValidateAntiforgeryToken]- public async Task<IActionResult> RateDelete(string id)+ var sbwModel = new List<ShippingByWeightModel>();+ foreach (var x in records){- var sbw = await _shippingByWeightService.GetById(id);- if (sbw != null)- await _shippingByWeightService.DeleteShippingByWeightRecord(sbw);-- return new JsonResult("");+ var m = new ShippingByWeightModel {+ Id = x.Id,+ StoreId = x.StoreId,+ WarehouseId = x.WarehouseId,+ ShippingMethodId = x.ShippingMethodId,+ CountryId = x.CountryId,+ From = x.From,+ To = x.To,+ AdditionalFixedCost = x.AdditionalFixedCost,+ PercentageRateOfSubtotal = x.PercentageRateOfSubtotal,+ RatePerWeightUnit = x.RatePerWeightUnit,+ LowerWeightLimit = x.LowerWeightLimit+ };+ //shipping method+ var shippingMethod = await _shippingMethodService.GetShippingMethodById(x.ShippingMethodId);+ m.ShippingMethodName = shippingMethod != null ? shippingMethod.Name : "Unavailable";+ //store+ var store = await _storeService.GetStoreById(x.StoreId);+ m.StoreName = store != null ? store.Shortcut : "*";+ //warehouse+ var warehouse = await _warehouseService.GetWarehouseById(x.WarehouseId);+ m.WarehouseName = warehouse != null ? warehouse.Name : "*";+ //country+ var c = await _countryService.GetCountryById(x.CountryId);+ m.CountryName = c != null ? c.Name : "*";+ //state+ var s = c?.StateProvinces.FirstOrDefault(y => y.Id == x.StateProvinceId);+ m.StateProvinceName = s != null ? s.Name : "*";+ //zip+ m.Zip = !string.IsNullOrEmpty(x.Zip) ? x.Zip : "*";+++ var htmlSb = new StringBuilder("<div>");+ htmlSb.Append($"{_translationService.GetResource("Plugins.Shipping.ByWeight.Fields.From")}: {m.From}");+ htmlSb.Append("<br />");+ htmlSb.Append($"{_translationService.GetResource("Plugins.Shipping.ByWeight.Fields.To")}: {m.To}");+ htmlSb.Append("<br />");+ htmlSb.Append(+ $"{_translationService.GetResource("Plugins.Shipping.ByWeight.Fields.AdditionalFixedCost")}: {m.AdditionalFixedCost}");+ htmlSb.Append("<br />");+ htmlSb.Append(+ $"{_translationService.GetResource("Plugins.Shipping.ByWeight.Fields.RatePerWeightUnit")}: {m.RatePerWeightUnit}");+ htmlSb.Append("<br />");+ htmlSb.Append(+ $"{_translationService.GetResource("Plugins.Shipping.ByWeight.Fields.LowerWeightLimit")}: {m.LowerWeightLimit}");+ htmlSb.Append("<br />");+ htmlSb.Append(+ $"{_translationService.GetResource("Plugins.Shipping.ByWeight.Fields.PercentageRateOfSubtotal")}: {m.PercentageRateOfSubtotal}");++ htmlSb.Append("</div>");+ m.DataHtml = htmlSb.ToString();++ sbwModel.Add(m);}- public async Task<IActionResult> AddPopup()- {- var model = new ShippingByWeightModel {- PrimaryStoreCurrencyCode = (await _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId)).CurrencyCode,- BaseWeightIn = (await _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId)).Name,- To = 1000000- };+ var gridModel = new DataSourceResult {+ Data = sbwModel,+ Total = records.TotalCount+ };- var shippingMethods = await _shippingMethodService.GetAllShippingMethods();- if (shippingMethods.Count == 0)- return Content("No shipping methods can be loaded");-- //stores- model.AvailableStores.Add(new SelectListItem { Text = "*", Value = " " });- foreach (var store in await _storeService.GetAllStores())- model.AvailableStores.Add(new SelectListItem { Text = store.Shortcut, Value = store.Id });- //warehouses- model.AvailableWarehouses.Add(new SelectListItem { Text = "*", Value = " " });- foreach (var warehouses in await _warehouseService.GetAllWarehouses())- model.AvailableWarehouses.Add(new SelectListItem { Text = warehouses.Name, Value = warehouses.Id });- //shipping methods- foreach (var sm in shippingMethods)- model.AvailableShippingMethods.Add(new SelectListItem { Text = sm.Name, Value = sm.Id });- //countries- model.AvailableCountries.Add(new SelectListItem { Text = "*", Value = " " });- var countries = await _countryService.GetAllCountries(showHidden: true);- foreach (var c in countries)- model.AvailableCountries.Add(new SelectListItem { Text = c.Name, Value = c.Id });- //states- model.AvailableStates.Add(new SelectListItem { Text = "*", Value = "" });-- return View(model);- }+ return Json(gridModel);+ }- [HttpPost]- [AutoValidateAntiforgeryToken]- public async Task<IActionResult> AddPopup(ShippingByWeightModel model)- {- var sbw = new ShippingByWeightRecord- {- StoreId = model.StoreId,- WarehouseId = model.WarehouseId,- CountryId = model.CountryId,- StateProvinceId = model.StateProvinceId,- Zip = model.Zip == "*" ? null : model.Zip,- ShippingMethodId = model.ShippingMethodId,- From = model.From,- To = model.To,- AdditionalFixedCost = model.AdditionalFixedCost,- RatePerWeightUnit = model.RatePerWeightUnit,- PercentageRateOfSubtotal = model.PercentageRateOfSubtotal,- LowerWeightLimit = model.LowerWeightLimit- };- await _shippingByWeightService.InsertShippingByWeightRecord(sbw);+ [HttpPost]+ [AutoValidateAntiforgeryToken]+ public async Task<IActionResult> RateDelete(string id)+ {+ var sbw = await _shippingByWeightService.GetById(id);+ if (sbw != null)+ await _shippingByWeightService.DeleteShippingByWeightRecord(sbw);- ViewBag.RefreshPage = true;+ return new JsonResult("");+ }- return View(model);- }+ public async Task<IActionResult> AddPopup()+ {+ var model = new ShippingByWeightModel {+ PrimaryStoreCurrencyCode =+ (await _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId)).CurrencyCode,+ BaseWeightIn = (await _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId)).Name,+ To = 1000000+ };++ var shippingMethods = await _shippingMethodService.GetAllShippingMethods();+ if (shippingMethods.Count == 0)+ return Content("No shipping methods can be loaded");++ //stores+ model.AvailableStores.Add(new SelectListItem { Text = "*", Value = " " });+ foreach (var store in await _storeService.GetAllStores())+ model.AvailableStores.Add(new SelectListItem { Text = store.Shortcut, Value = store.Id });+ //warehouses+ model.AvailableWarehouses.Add(new SelectListItem { Text = "*", Value = " " });+ foreach (var warehouses in await _warehouseService.GetAllWarehouses())+ model.AvailableWarehouses.Add(new SelectListItem { Text = warehouses.Name, Value = warehouses.Id });+ //shipping methods+ foreach (var sm in shippingMethods)+ model.AvailableShippingMethods.Add(new SelectListItem { Text = sm.Name, Value = sm.Id });+ //countries+ model.AvailableCountries.Add(new SelectListItem { Text = "*", Value = " " });+ var countries = await _countryService.GetAllCountries(showHidden: true);+ foreach (var c in countries)+ model.AvailableCountries.Add(new SelectListItem { Text = c.Name, Value = c.Id });+ //states+ model.AvailableStates.Add(new SelectListItem { Text = "*", Value = "" });++ return View(model);+ }- //edit- public async Task<IActionResult> EditPopup(string id)- {- var sbw = await _shippingByWeightService.GetById(id);- if (sbw == null)- //No record found with the specified id- return RedirectToAction("Configure");-- var model = new ShippingByWeightModel- {- Id = sbw.Id,- StoreId = sbw.StoreId,- WarehouseId = sbw.WarehouseId,- CountryId = sbw.CountryId,- StateProvinceId = sbw.StateProvinceId,- Zip = sbw.Zip,- ShippingMethodId = sbw.ShippingMethodId,- From = sbw.From,- To = sbw.To,- AdditionalFixedCost = sbw.AdditionalFixedCost,- PercentageRateOfSubtotal = sbw.PercentageRateOfSubtotal,- RatePerWeightUnit = sbw.RatePerWeightUnit,- LowerWeightLimit = sbw.LowerWeightLimit,- PrimaryStoreCurrencyCode = (await _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId)).CurrencyCode,- BaseWeightIn = (await _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId)).Name- };+ [HttpPost]+ [AutoValidateAntiforgeryToken]+ public async Task<IActionResult> AddPopup(ShippingByWeightModel model)+ {+ var sbw = new ShippingByWeightRecord {+ StoreId = model.StoreId,+ WarehouseId = model.WarehouseId,+ CountryId = model.CountryId,+ StateProvinceId = model.StateProvinceId,+ Zip = model.Zip == "*" ? null : model.Zip,+ ShippingMethodId = model.ShippingMethodId,+ From = model.From,+ To = model.To,+ AdditionalFixedCost = model.AdditionalFixedCost,+ RatePerWeightUnit = model.RatePerWeightUnit,+ PercentageRateOfSubtotal = model.PercentageRateOfSubtotal,+ LowerWeightLimit = model.LowerWeightLimit+ };+ await _shippingByWeightService.InsertShippingByWeightRecord(sbw);++ ViewBag.RefreshPage = true;++ return View(model);+ }- var shippingMethods = await _shippingMethodService.GetAllShippingMethods();- if (shippingMethods.Count == 0)- return Content("No shipping methods can be loaded");-- var selectedStore = await _storeService.GetStoreById(sbw.StoreId);- var selectedWarehouse = await _warehouseService.GetWarehouseById(sbw.WarehouseId);- var selectedShippingMethod = await _shippingMethodService.GetShippingMethodById(sbw.ShippingMethodId);- var selectedCountry = await _countryService.GetCountryById(sbw.CountryId);- var selectedState = selectedCountry?.StateProvinces.FirstOrDefault(x => x.Id == sbw.StateProvinceId);- //stores- model.AvailableStores.Add(new SelectListItem { Text = "*", Value = "" });- foreach (var store in await _storeService.GetAllStores())- model.AvailableStores.Add(new SelectListItem { Text = store.Shortcut, Value = store.Id, Selected = selectedStore != null && store.Id == selectedStore.Id });- //warehouses- model.AvailableWarehouses.Add(new SelectListItem { Text = "*", Value = "" });- foreach (var warehouse in await _warehouseService.GetAllWarehouses())- model.AvailableWarehouses.Add(new SelectListItem { Text = warehouse.Name, Value = warehouse.Id, Selected = selectedWarehouse != null && warehouse.Id == selectedWarehouse.Id });- //shipping methods- foreach (var sm in shippingMethods)- model.AvailableShippingMethods.Add(new SelectListItem { Text = sm.Name, Value = sm.Id, Selected = selectedShippingMethod != null && sm.Id == selectedShippingMethod.Id });- //countries- model.AvailableCountries.Add(new SelectListItem { Text = "*", Value = "" });- var countries = await _countryService.GetAllCountries(showHidden: true);- foreach (var c in countries)- model.AvailableCountries.Add(new SelectListItem { Text = c.Name, Value = c.Id, Selected = selectedCountry != null && c.Id == selectedCountry.Id });- //states- var states = selectedCountry != null ? await _countryService.GetStateProvincesByCountryId(selectedCountry.Id) : new List<StateProvince>();- model.AvailableStates.Add(new SelectListItem { Text = "*", Value = "" });- foreach (var s in states)- model.AvailableStates.Add(new SelectListItem { Text = s.Name, Value = s.Id, Selected = selectedState != null && s.Id == selectedState.Id });-- return View(model);- }- [HttpPost]- [AutoValidateAntiforgeryToken]- public async Task<IActionResult> EditPopup(ShippingByWeightModel model)- {- var sbw = await _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.From = model.From;- sbw.To = model.To;- sbw.AdditionalFixedCost = model.AdditionalFixedCost;- sbw.RatePerWeightUnit = model.RatePerWeightUnit;- sbw.PercentageRateOfSubtotal = model.PercentageRateOfSubtotal;- sbw.LowerWeightLimit = model.LowerWeightLimit;- await _shippingByWeightService.UpdateShippingByWeightRecord(sbw);-- ViewBag.RefreshPage = true;-- return View(model);- }+ //edit+ public async Task<IActionResult> EditPopup(string id)+ {+ var sbw = await _shippingByWeightService.GetById(id);+ if (sbw == null)+ //No record found with the specified id+ return RedirectToAction("Configure");++ var model = new ShippingByWeightModel {+ Id = sbw.Id,+ StoreId = sbw.StoreId,+ WarehouseId = sbw.WarehouseId,+ CountryId = sbw.CountryId,+ StateProvinceId = sbw.StateProvinceId,+ Zip = sbw.Zip,+ ShippingMethodId = sbw.ShippingMethodId,+ From = sbw.From,+ To = sbw.To,+ AdditionalFixedCost = sbw.AdditionalFixedCost,+ PercentageRateOfSubtotal = sbw.PercentageRateOfSubtotal,+ RatePerWeightUnit = sbw.RatePerWeightUnit,+ LowerWeightLimit = sbw.LowerWeightLimit,+ PrimaryStoreCurrencyCode =+ (await _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId)).CurrencyCode,+ BaseWeightIn = (await _measureService.GetMeasureWeightById(_measureSettings.BaseWeightId)).Name+ };++ var shippingMethods = await _shippingMethodService.GetAllShippingMethods();+ if (shippingMethods.Count == 0)+ return Content("No shipping methods can be loaded");++ var selectedStore = await _storeService.GetStoreById(sbw.StoreId);+ var selectedWarehouse = await _warehouseService.GetWarehouseById(sbw.WarehouseId);+ var selectedShippingMethod = await _shippingMethodService.GetShippingMethodById(sbw.ShippingMethodId);+ var selectedCountry = await _countryService.GetCountryById(sbw.CountryId);+ var selectedState = selectedCountry?.StateProvinces.FirstOrDefault(x => x.Id == sbw.StateProvinceId);+ //stores+ model.AvailableStores.Add(new SelectListItem { Text = "*", Value = "" });+ foreach (var store in await _storeService.GetAllStores())+ model.AvailableStores.Add(new SelectListItem {+ Text = store.Shortcut, Value = store.Id,+ Selected = selectedStore != null && store.Id == selectedStore.Id+ });+ //warehouses+ model.AvailableWarehouses.Add(new SelectListItem { Text = "*", Value = "" });+ foreach (var warehouse in await _warehouseService.GetAllWarehouses())+ model.AvailableWarehouses.Add(new SelectListItem {+ Text = warehouse.Name, Value = warehouse.Id,+ Selected = selectedWarehouse != null && warehouse.Id == selectedWarehouse.Id+ });+ //shipping methods+ foreach (var sm in shippingMethods)+ model.AvailableShippingMethods.Add(new SelectListItem {+ Text = sm.Name, Value = sm.Id,+ Selected = selectedShippingMethod != null && sm.Id == selectedShippingMethod.Id+ });+ //countries+ model.AvailableCountries.Add(new SelectListItem { Text = "*", Value = "" });+ var countries = await _countryService.GetAllCountries(showHidden: true);+ foreach (var c in countries)+ model.AvailableCountries.Add(new SelectListItem+ { Text = c.Name, Value = c.Id, Selected = selectedCountry != null && c.Id == selectedCountry.Id });+ //states+ var states = selectedCountry != null+ ? await _countryService.GetStateProvincesByCountryId(selectedCountry.Id)+ : new List<StateProvince>();+ model.AvailableStates.Add(new SelectListItem { Text = "*", Value = "" });+ foreach (var s in states)+ model.AvailableStates.Add(new SelectListItem+ { Text = s.Name, Value = s.Id, Selected = selectedState != null && s.Id == selectedState.Id });++ return View(model);+ }++ [HttpPost]+ [AutoValidateAntiforgeryToken]+ public async Task<IActionResult> EditPopup(ShippingByWeightModel model)+ {+ var sbw = await _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.From = model.From;+ sbw.To = model.To;+ sbw.AdditionalFixedCost = model.AdditionalFixedCost;+ sbw.RatePerWeightUnit = model.RatePerWeightUnit;+ sbw.PercentageRateOfSubtotal = model.PercentageRateOfSubtotal;+ sbw.LowerWeightLimit = model.LowerWeightLimit;+ await _shippingByWeightService.UpdateShippingByWeightRecord(sbw);++ ViewBag.RefreshPage = true;++ return View(model);}-}+}\ No newline at end of filediff --git a/src/Plugins/Shipping.ByWeight/Areas/Admin/Views/ShippingByWeight/AddPopup.cshtml b/src/Plugins/Shipping.ByWeight/Areas/Admin/Views/ShippingByWeight/AddPopup.cshtmlindex be39d3b0e..302ce79be 100644--- a/src/Plugins/Shipping.ByWeight/Areas/Admin/Views/ShippingByWeight/AddPopup.cshtml+++ b/src/Plugins/Shipping.ByWeight/Areas/Admin/Views/ShippingByWeight/AddPopup.cshtml@@ -1,13 +1,12 @@@{Layout = "";}-@model ShippingByWeightModel-@using Shipping.ByWeight.Models;+@model Shipping.ByWeight.Models.ShippingByWeightModel<form id="AddPopup" asp-controller="ShippingByWeight" asp-action="AddPopup" method="post"asp-route-ShippingByWeightId="@Context.Request.Query["ShippingByWeightId"]"- asp-route-btnId="@Context.Request.Query["btnId"]"- asp-route-formId="@Context.Request.Query["formId"]">-+ asp-route-btnId="@Context.Request.Query["btnId"]"+ asp-route-formId="@Context.Request.Query["formId"]">+<div class="row"><div class="col-md-12">@@ -19,7 +18,7 @@</div></div><div class="x_content form">- <partial name="_CreateOrUpdate" model="Model" />+ <partial name="_CreateOrUpdate" model="Model"/></div></div></div>diff --git a/src/Plugins/Shipping.ByWeight/Areas/Admin/Views/ShippingByWeight/Configure.cshtml b/src/Plugins/Shipping.ByWeight/Areas/Admin/Views/ShippingByWeight/Configure.cshtmlindex e7c7ef4b5..5371a8e78 100644--- a/src/Plugins/Shipping.ByWeight/Areas/Admin/Views/ShippingByWeight/Configure.cshtml+++ b/src/Plugins/Shipping.ByWeight/Areas/Admin/Views/ShippingByWeight/Configure.cshtml@@ -1,13 +1,12 @@-@model ShippingByWeightListModel+@using Grand.Domain.Common+@model Shipping.ByWeight.Models.ShippingByWeightListModel@inject AdminAreaSettings adminAreaSettings-@using Shipping.ByWeight.Models;-@using Grand.Domain.Common;@{Layout = "_ConfigurePlugin";}-<input id="active-menu-item" type="hidden" value="/Admin/Shipping/Providers" />+<input id="active-menu-item" type="hidden" value="/Admin/Shipping/Providers"/><form asp-controller="ShippingByWeight" asp-action="Configure" method="post" id="shipping-byweight-form">-+<div class="note note-info"><strong>@Loc["Plugins.Shipping.ByWeight.Formula"]:</strong>@Loc["Plugins.Shipping.ByWeight.Formula.Value"]@@ -25,7 +24,7 @@<a id="btnAddNewOption" href="@(addNewUrl)" class="btn default">@Loc["Plugins.Shipping.ByWeight.AddRecord"]</a>- <input type="submit" id="btnRefresh" style="display: none" />+ <input type="submit" id="btnRefresh" style="display: none"/></div></div><script>@@ -138,7 +137,7 @@field: "Id",title: "@Loc["Admin.Common.Edit"]",width: 100,- template: "<a href=\"@Url.Action("EditPopup","ShippingByWeight")?id=#=Id#&btnId=btnRefresh&formId=shipping-byweight-form\" class='k-button editpopup k-button-icontext'>@Loc["Admin.Common.Edit"]</a>"+ template: "<a href=\"@Url.Action("EditPopup", "ShippingByWeight")?id=#=Id#&btnId=btnRefresh&formId=shipping-byweight-form\" class='k-button editpopup k-button-icontext'>@Loc["Admin.Common.Edit"]</a>"}, {command: { name: "destroy", text: "@Loc["Admin.Common.Delete"]" },title: "@Loc["Admin.Common.Delete"]",@@ -167,10 +166,10 @@<div class="panel-body"><div class="form-body"><div class="form-group">- <admin-label asp-for="LimitMethodsToCreated" />+ <admin-label asp-for="LimitMethodsToCreated"/><div class="col-md-9 col-sm-9"><label class="mt-checkbox mt-checkbox-outline control control-checkbox">- <admin-input asp-for="LimitMethodsToCreated" />+ <admin-input asp-for="LimitMethodsToCreated"/><div class="control__indicator"></div></label><span asp-validation-for="LimitMethodsToCreated"></span>@@ -178,15 +177,15 @@</div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="DisplayOrder" class="control-label" />+ <admin-label asp-for="DisplayOrder" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="DisplayOrder" />+ <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"]" />+ <input type="button" id="savegeneralsettings" class="btn default" value="@Loc["Admin.Common.Save"]"/><script>$(function () {$('#savegeneralsettings').click(function () {@@ -216,4 +215,4 @@</div></div></div>-</form>+</form>\ No newline at end of filediff --git a/src/Plugins/Shipping.ByWeight/Areas/Admin/Views/ShippingByWeight/EditPopup.cshtml b/src/Plugins/Shipping.ByWeight/Areas/Admin/Views/ShippingByWeight/EditPopup.cshtmlindex c67b87dc6..312dda14d 100644--- a/src/Plugins/Shipping.ByWeight/Areas/Admin/Views/ShippingByWeight/EditPopup.cshtml+++ b/src/Plugins/Shipping.ByWeight/Areas/Admin/Views/ShippingByWeight/EditPopup.cshtml@@ -1,8 +1,7 @@@{Layout = "";}-@model ShippingByWeightModel-@using Shipping.ByWeight.Models;+@model Shipping.ByWeight.Models.ShippingByWeightModel<form id="EditPopup" asp-controller="ShippingByWeight" asp-action="EditPopup" method="post"asp-route-ShippingByWeightId="@Context.Request.Query["ShippingByWeightId"]"asp-route-btnId="@Context.Request.Query["btnId"]"@@ -18,7 +17,7 @@</div></div><div class="x_content form">- <partial name="_CreateOrUpdate" model="Model" />+ <partial name="_CreateOrUpdate" model="Model"/></div></div></div>diff --git a/src/Plugins/Shipping.ByWeight/Areas/Admin/Views/ShippingByWeight/_CreateOrUpdate.cshtml b/src/Plugins/Shipping.ByWeight/Areas/Admin/Views/ShippingByWeight/_CreateOrUpdate.cshtmlindex 880d45e79..afd2668cf 100644--- a/src/Plugins/Shipping.ByWeight/Areas/Admin/Views/ShippingByWeight/_CreateOrUpdate.cshtml+++ b/src/Plugins/Shipping.ByWeight/Areas/Admin/Views/ShippingByWeight/_CreateOrUpdate.cshtml@@ -1,8 +1,7 @@-@model ShippingByWeightModel-@using Shipping.ByWeight.Models-@using Microsoft.AspNetCore.Routing+@using Microsoft.AspNetCore.Routing+@model Shipping.ByWeight.Models.ShippingByWeightModel<div asp-validation-summary="All"></div>-<input asp-for="Id" type="hidden" />+<input asp-for="Id" type="hidden"/>@if (ViewBag.RefreshPage == true){@@ -40,115 +39,117 @@<div class="form-body"><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="StoreId" class="control-label" />+ <admin-label asp-for="StoreId" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-select asp-for="StoreId" asp-items="Model.AvailableStores" />+ <admin-select asp-for="StoreId" asp-items="Model.AvailableStores"/><span asp-validation-for="StoreId"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="WarehouseId" class="control-label" />+ <admin-label asp-for="WarehouseId" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-select asp-for="WarehouseId" asp-items="Model.AvailableWarehouses" />+ <admin-select asp-for="WarehouseId" asp-items="Model.AvailableWarehouses"/><span asp-validation-for="WarehouseId"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="CountryId" class="control-label" />+ <admin-label asp-for="CountryId" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-select asp-for="CountryId" asp-items="Model.AvailableCountries" />+ <admin-select asp-for="CountryId" asp-items="Model.AvailableCountries"/><span asp-validation-for="CountryId"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="StateProvinceId" class="control-label" />+ <admin-label asp-for="StateProvinceId" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-select asp-for="StateProvinceId" asp-items="Model.AvailableStates" />+ <admin-select asp-for="StateProvinceId" asp-items="Model.AvailableStates"/><span asp-validation-for="StateProvinceId"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="Zip" class="control-label" />+ <admin-label asp-for="Zip" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="Zip" />+ <admin-input asp-for="Zip"/><span asp-validation-for="Zip"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="ShippingMethodId" class="control-label" />+ <admin-label asp-for="ShippingMethodId" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-select asp-for="ShippingMethodId" asp-items="Model.AvailableShippingMethods" />+ <admin-select asp-for="ShippingMethodId" asp-items="Model.AvailableShippingMethods"/><span asp-validation-for="ShippingMethodId"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="From" class="control-label" />+ <admin-label asp-for="From" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="From" /> [@Model.BaseWeightIn]+ <admin-input asp-for="From"/> [@Model.BaseWeightIn]<span asp-validation-for="From"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="To" class="control-label" />+ <admin-label asp-for="To" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="To" /> [@Model.BaseWeightIn]+ <admin-input asp-for="To"/> [@Model.BaseWeightIn]<span asp-validation-for="To"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="AdditionalFixedCost" class="control-label" />+ <admin-label asp-for="AdditionalFixedCost" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="AdditionalFixedCost" /> [@Model.PrimaryStoreCurrencyCode]+ <admin-input asp-for="AdditionalFixedCost"/> [@Model.PrimaryStoreCurrencyCode]<span asp-validation-for="AdditionalFixedCost"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="LowerWeightLimit" class="control-label" />+ <admin-label asp-for="LowerWeightLimit" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="LowerWeightLimit" />+ <admin-input asp-for="LowerWeightLimit"/><span asp-validation-for="LowerWeightLimit"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="RatePerWeightUnit" class="control-label" />+ <admin-label asp-for="RatePerWeightUnit" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="RatePerWeightUnit" /> [@Model.PrimaryStoreCurrencyCode]+ <admin-input asp-for="RatePerWeightUnit"/> [@Model.PrimaryStoreCurrencyCode]<span asp-validation-for="RatePerWeightUnit"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="PercentageRateOfSubtotal" class="control-label" />+ <admin-label asp-for="PercentageRateOfSubtotal" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="PercentageRateOfSubtotal" />+ <admin-input asp-for="PercentageRateOfSubtotal"/><span asp-validation-for="PercentageRateOfSubtotal"></span></div></div><div class="form-group"><div class="offset-sm-3 offset-md-3 col-md-9 col-sm-9">- <button class="btn btn-success" type="submit" name="save"><i class="fa fa-check"></i>@Loc["Admin.Common.Save"]</button>+ <button class="btn btn-success" type="submit" name="save">+ <i class="fa fa-check"></i>@Loc["Admin.Common.Save"]+ </button></div></div></div>diff --git a/src/Plugins/Shipping.ByWeight/Areas/Admin/Views/_ViewImports.cshtml b/src/Plugins/Shipping.ByWeight/Areas/Admin/Views/_ViewImports.cshtmlindex 0a765b55a..52adbfe6d 100644--- a/src/Plugins/Shipping.ByWeight/Areas/Admin/Views/_ViewImports.cshtml+++ b/src/Plugins/Shipping.ByWeight/Areas/Admin/Views/_ViewImports.cshtml@@ -5,5 +5,6 @@@using Microsoft.AspNetCore.Mvc.ViewFeatures@using Grand.Infrastructure.Extensions@using Grand.Web.Common+@using Grand.Web.Common.Localization-@inject Grand.Web.Common.Localization.LocService Loc+@inject LocService Loc\ No newline at end of filediff --git a/src/Plugins/Shipping.ByWeight/ByWeightShippingDefaults.cs b/src/Plugins/Shipping.ByWeight/ByWeightShippingDefaults.csindex c1903f62a..4395bd1a0 100644--- a/src/Plugins/Shipping.ByWeight/ByWeightShippingDefaults.cs+++ b/src/Plugins/Shipping.ByWeight/ByWeightShippingDefaults.cs@@ -1,9 +1,8 @@-namespace Shipping.ByWeight+namespace Shipping.ByWeight;++public static class ByWeightShippingDefaults{- public static class ByWeightShippingDefaults- {- public const string ProviderSystemName = "Shipping.ByWeight";- public const string FriendlyName = "Shipping.ByWeight.FriendlyName";- public const string ConfigurationUrl = "../ShippingByWeight/Configure";- }-}+ public const string ProviderSystemName = "Shipping.ByWeight";+ public const string FriendlyName = "Shipping.ByWeight.FriendlyName";+ public const string ConfigurationUrl = "../ShippingByWeight/Configure";+}\ No newline at end of filediff --git a/src/Plugins/Shipping.ByWeight/ByWeightShippingPlugin.cs b/src/Plugins/Shipping.ByWeight/ByWeightShippingPlugin.csindex 48b8be3bb..e166dd050 100644--- a/src/Plugins/Shipping.ByWeight/ByWeightShippingPlugin.cs+++ b/src/Plugins/Shipping.ByWeight/ByWeightShippingPlugin.cs@@ -4,81 +4,101 @@ using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Domain.Orders;using Grand.Infrastructure.Plugins;-namespace Shipping.ByWeight+namespace Shipping.ByWeight;++public class ByWeightShippingPlugin : BasePlugin, IPlugin{- public class ByWeightShippingPlugin : BasePlugin, IPlugin+ #region Ctor++ public ByWeightShippingPlugin(+ ISettingService settingService,+ ITranslationService translationService,+ ILanguageService languageService){- #region Fields+ _settingService = settingService;+ _translationService = translationService;+ _languageService = languageService;+ }- private readonly ISettingService _settingService;- private readonly ITranslationService _translationService;- private readonly ILanguageService _languageService;- #endregion+ #endregion- #region Ctor- public ByWeightShippingPlugin(- ISettingService settingService,- ITranslationService translationService,- ILanguageService languageService)- {- _settingService = settingService;- _translationService = translationService;- _languageService = languageService;- }- #endregion+ #region Fields- #region Methods+ private readonly ISettingService _settingService;+ private readonly ITranslationService _translationService;+ private readonly ILanguageService _languageService;- /// <summary>- /// Install plugin- /// </summary>- public override async Task Install()- {- //settings- var settings = new ByWeightShippingSettings {- LimitMethodsToCreated = false- };- await _settingService.SaveSetting(settings);+ #endregion- //locales- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ByWeight.FriendlyName", "Shipping by Weight");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Shipping.ByWeight.Fields.Store", "Store");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Shipping.ByWeight.Fields.Warehouse", "Warehouse");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Shipping.ByWeight.Fields.Country", "Country");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Shipping.ByWeight.Fields.StateProvince", "State / province");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Shipping.ByWeight.Fields.Zip", "Zip");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Shipping.ByWeight.Fields.ShippingMethod", "Shipping method");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Shipping.ByWeight.Fields.From", "Order weight from");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Shipping.ByWeight.Fields.To", "Order weight to");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Shipping.ByWeight.Fields.AdditionalFixedCost", "Additional fixed cost");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Shipping.ByWeight.Fields.LowerWeightLimit", "Lower weight limit");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Shipping.ByWeight.Fields.PercentageRateOfSubtotal", "Charge percentage (of subtotal)");- await 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]");+ #region Methods- await base.Install();- }+ /// <summary>+ /// Install plugin+ /// </summary>+ public override async Task Install()+ {+ //settings+ var settings = new ByWeightShippingSettings {+ LimitMethodsToCreated = false+ };+ await _settingService.SaveSetting(settings);- /// <summary>- /// Returns a value indicating whether shipping methods should be hidden during checkout- /// </summary>- /// <param name="cart">Shopping cart</param>- /// <returns>true - hide; false - display.</returns>- public async Task<bool> HideShipmentMethods(IList<ShoppingCartItem> cart)- {- //you can put any logic here- //for example, hide this shipping methods if all products in the cart are downloadable- //or hide this shipping methods if current customer is from certain country- return await Task.FromResult(false);- }+ //locales+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ByWeight.FriendlyName", "Shipping by Weight");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Shipping.ByWeight.Fields.Store", "Store");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Shipping.ByWeight.Fields.Warehouse", "Warehouse");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Shipping.ByWeight.Fields.Country", "Country");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Shipping.ByWeight.Fields.StateProvince", "State / province");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Shipping.ByWeight.Fields.Zip", "Zip");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Shipping.ByWeight.Fields.ShippingMethod", "Shipping method");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Shipping.ByWeight.Fields.From", "Order weight from");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Shipping.ByWeight.Fields.To", "Order weight to");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Shipping.ByWeight.Fields.AdditionalFixedCost", "Additional fixed cost");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Shipping.ByWeight.Fields.LowerWeightLimit", "Lower weight limit");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Shipping.ByWeight.Fields.PercentageRateOfSubtotal", "Charge percentage (of subtotal)");+ await 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]");- #endregion+ await base.Install();+ }+ /// <summary>+ /// Returns a value indicating whether shipping methods should be hidden during checkout+ /// </summary>+ /// <param name="cart">Shopping cart</param>+ /// <returns>true - hide; false - display.</returns>+ public async Task<bool> HideShipmentMethods(IList<ShoppingCartItem> cart)+ {+ //you can put any logic here+ //for example, hide this shipping methods if all products in the cart are downloadable+ //or hide this shipping methods if current customer is from certain country+ return await Task.FromResult(false);}-}+ #endregion+}\ No newline at end of filediff --git a/src/Plugins/Shipping.ByWeight/ByWeightShippingProvider.cs b/src/Plugins/Shipping.ByWeight/ByWeightShippingProvider.csindex c20d0ac2a..7aedea312 100644--- a/src/Plugins/Shipping.ByWeight/ByWeightShippingProvider.cs+++ b/src/Plugins/Shipping.ByWeight/ByWeightShippingProvider.cs@@ -1,12 +1,12 @@-using Grand.Business.Core.Interfaces.Catalog.Prices;+using Grand.Business.Core.Enums.Checkout;+using Grand.Business.Core.Extensions;+using Grand.Business.Core.Interfaces.Catalog.Prices;using Grand.Business.Core.Interfaces.Catalog.Products;-using Grand.Business.Core.Enums.Checkout;using Grand.Business.Core.Interfaces.Checkout.CheckoutAttributes;using Grand.Business.Core.Interfaces.Checkout.Shipping;-using Grand.Business.Core.Utilities.Checkout;-using Grand.Business.Core.Extensions;using Grand.Business.Core.Interfaces.Common.Directory;using Grand.Business.Core.Interfaces.Common.Localization;+using Grand.Business.Core.Utilities.Checkout;using Grand.Domain.Catalog;using Grand.Domain.Common;using Grand.Domain.Customers;@@ -17,300 +17,309 @@ using Microsoft.AspNetCore.Http;using Microsoft.Extensions.DependencyInjection;using Shipping.ByWeight.Services;-namespace Shipping.ByWeight+namespace Shipping.ByWeight;++public class ByWeightShippingCalcPlugin : IShippingRateCalculationProvider{- public class ByWeightShippingCalcPlugin : IShippingRateCalculationProvider+ #region Ctor++ public ByWeightShippingCalcPlugin(+ IShippingMethodService shippingMethodService,+ IWorkContext workContext,+ ITranslationService translationService,+ IProductService productService,+ ICheckoutAttributeParser checkoutAttributeParser,+ ICurrencyService currencyService,+ IHttpContextAccessor httpContextAccessor,+ ByWeightShippingSettings byWeightShippingSettings){- #region Fields-- private readonly IShippingMethodService _shippingMethodService;- private readonly IWorkContext _workContext;- private readonly ITranslationService _translationService;- private readonly IProductService _productService;- private readonly ICheckoutAttributeParser _checkoutAttributeParser;- private readonly ICurrencyService _currencyService;- private readonly IHttpContextAccessor _httpContextAccessor;- private readonly ByWeightShippingSettings _byWeightShippingSettings;-- #endregion-- #region Ctor- public ByWeightShippingCalcPlugin(- IShippingMethodService shippingMethodService,- IWorkContext workContext,- ITranslationService translationService,- IProductService productService,- ICheckoutAttributeParser checkoutAttributeParser,- ICurrencyService currencyService,- IHttpContextAccessor httpContextAccessor,- ByWeightShippingSettings byWeightShippingSettings)+ _shippingMethodService = shippingMethodService;+ _workContext = workContext;+ _translationService = translationService;+ _productService = productService;+ _checkoutAttributeParser = checkoutAttributeParser;+ _currencyService = currencyService;+ _httpContextAccessor = httpContextAccessor;+ _byWeightShippingSettings = byWeightShippingSettings;+ }++ #endregion++ #region Utilities++ private async Task<double?> GetRate(double subTotal, double weight, string shippingMethodId,+ string storeId, string warehouseId, string countryId, string stateProvinceId, string zip)+ {+ var shippingByWeightService =+ _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<IShippingByWeightService>();++ var shippingByWeightRecord = await shippingByWeightService.FindRecord(shippingMethodId,+ storeId, warehouseId, countryId, stateProvinceId, zip, weight);+ if (shippingByWeightRecord == null){- _shippingMethodService = shippingMethodService;- _workContext = workContext;- _translationService = translationService;- _productService = productService;- _checkoutAttributeParser = checkoutAttributeParser;- _currencyService = currencyService;- _httpContextAccessor = httpContextAccessor;- _byWeightShippingSettings = byWeightShippingSettings;- }- #endregion+ if (_byWeightShippingSettings.LimitMethodsToCreated)+ return null;- #region Utilities+ return 0;+ }- private async Task<double?> GetRate(double subTotal, double weight, string shippingMethodId,- string storeId, string warehouseId, string countryId, string stateProvinceId, string zip)+ //additional fixed cost+ var shippingTotal = shippingByWeightRecord.AdditionalFixedCost;+ //charge amount per weight unit+ if (shippingByWeightRecord.RatePerWeightUnit > 0){+ var weightRate = weight - shippingByWeightRecord.LowerWeightLimit;+ if (weightRate < 0)+ weightRate = 0;+ shippingTotal += shippingByWeightRecord.RatePerWeightUnit * weightRate;+ }- var shippingByWeightService = _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<IShippingByWeightService>();+ //percentage rate of subtotal+ if (shippingByWeightRecord.PercentageRateOfSubtotal > 0)+ shippingTotal += Math.Round((float)subTotal * (float)shippingByWeightRecord.PercentageRateOfSubtotal / 100f,+ 2);- var shippingByWeightRecord = await shippingByWeightService.FindRecord(shippingMethodId,- storeId, warehouseId, countryId, stateProvinceId, zip, weight);- if (shippingByWeightRecord == null)- {- if (_byWeightShippingSettings.LimitMethodsToCreated)- return null;+ if (shippingTotal < 0)+ shippingTotal = 0;+ return shippingTotal;+ }- return 0;- }+ #endregion- //additional fixed cost- var shippingTotal = shippingByWeightRecord.AdditionalFixedCost;- //charge amount per weight unit- if (shippingByWeightRecord.RatePerWeightUnit > 0)- {- var weightRate = weight - shippingByWeightRecord.LowerWeightLimit;- if (weightRate < 0)- weightRate = 0;- shippingTotal += shippingByWeightRecord.RatePerWeightUnit * weightRate;- }- //percentage rate of subtotal- if (shippingByWeightRecord.PercentageRateOfSubtotal > 0)- {- shippingTotal += Math.Round((float)subTotal * (float)shippingByWeightRecord.PercentageRateOfSubtotal / 100f, 2);- }+ #region Fields- if (shippingTotal < 0)- shippingTotal = 0;- return shippingTotal;- }+ private readonly IShippingMethodService _shippingMethodService;+ private readonly IWorkContext _workContext;+ private readonly ITranslationService _translationService;+ private readonly IProductService _productService;+ private readonly ICheckoutAttributeParser _checkoutAttributeParser;+ private readonly ICurrencyService _currencyService;+ private readonly IHttpContextAccessor _httpContextAccessor;+ private readonly ByWeightShippingSettings _byWeightShippingSettings;- #endregion+ #endregion- #region Methods+ #region Methods- /// <summary>- /// Gets shopping cart item weight (of one item)- /// </summary>- /// <param name="shoppingCartItem">Shopping cart item</param>- /// <returns>Shopping cart item weight</returns>- private async Task<double> GetShoppingCartItemWeight(ShoppingCartItem shoppingCartItem)- {- ArgumentNullException.ThrowIfNull(shoppingCartItem);+ /// <summary>+ /// Gets shopping cart item weight (of one item)+ /// </summary>+ /// <param name="shoppingCartItem">Shopping cart item</param>+ /// <returns>Shopping cart item weight</returns>+ private async Task<double> GetShoppingCartItemWeight(ShoppingCartItem shoppingCartItem)+ {+ ArgumentNullException.ThrowIfNull(shoppingCartItem);- var product = await _productService.GetProductById(shoppingCartItem.ProductId);- if (product == null)- return 0;+ var product = await _productService.GetProductById(shoppingCartItem.ProductId);+ if (product == null)+ return 0;- //attribute weight- double attributesTotalWeight = 0;- if (shoppingCartItem.Attributes != null && shoppingCartItem.Attributes.Any())- {- var attributeValues = product.ParseProductAttributeValues(shoppingCartItem.Attributes);- foreach (var attributeValue in attributeValues)+ //attribute weight+ double attributesTotalWeight = 0;+ if (shoppingCartItem.Attributes != null && shoppingCartItem.Attributes.Any())+ {+ var attributeValues = product.ParseProductAttributeValues(shoppingCartItem.Attributes);+ foreach (var attributeValue in attributeValues)+ switch (attributeValue.AttributeValueTypeId){- switch (attributeValue.AttributeValueTypeId)+ case AttributeValueType.Simple:{- case AttributeValueType.Simple:- {- //simple attribute- attributesTotalWeight += attributeValue.WeightAdjustment;- }- break;- case AttributeValueType.AssociatedToProduct:- {- //bundled product- var associatedProduct = await _productService.GetProductById(attributeValue.AssociatedProductId);- if (associatedProduct is { IsShipEnabled: true })- {- attributesTotalWeight += associatedProduct.Weight * attributeValue.Quantity;- }- }- break;+ //simple attribute+ attributesTotalWeight += attributeValue.WeightAdjustment;}+ break;+ case AttributeValueType.AssociatedToProduct:+ {+ //bundled product+ var associatedProduct =+ await _productService.GetProductById(attributeValue.AssociatedProductId);+ if (associatedProduct is { IsShipEnabled: true })+ attributesTotalWeight += associatedProduct.Weight * attributeValue.Quantity;+ }+ break;}- }- var weight = product.Weight + attributesTotalWeight;- return weight;}- /// <summary>- /// Gets shopping cart weight- /// </summary>- /// <param name="request">Request</param>- /// <param name="includeCheckoutAttributes">A value indicating whether we should calculate weights of selected checkout attributes</param>- /// <returns>Total weight</returns>- private async Task<double> GetTotalWeight(GetShippingOptionRequest request, bool includeCheckoutAttributes = true)- {- ArgumentNullException.ThrowIfNull(request);- Customer customer = request.Customer;+ var weight = product.Weight + attributesTotalWeight;+ return weight;+ }- double totalWeight = 0;- //shopping cart items- foreach (var packageItem in request.Items)- totalWeight += await GetShoppingCartItemWeight(packageItem.ShoppingCartItem) * packageItem.GetQuantity();+ /// <summary>+ /// Gets shopping cart weight+ /// </summary>+ /// <param name="request">Request</param>+ /// <param name="includeCheckoutAttributes">+ /// A value indicating whether we should calculate weights of selected checkout+ /// attributes+ /// </param>+ /// <returns>Total weight</returns>+ private async Task<double> GetTotalWeight(GetShippingOptionRequest request, bool includeCheckoutAttributes = true)+ {+ ArgumentNullException.ThrowIfNull(request);++ var customer = request.Customer;++ double totalWeight = 0;+ //shopping cart items+ foreach (var packageItem in request.Items)+ totalWeight += await GetShoppingCartItemWeight(packageItem.ShoppingCartItem) * packageItem.GetQuantity();- //checkout attributes- if (customer != null && includeCheckoutAttributes)+ //checkout attributes+ if (customer != null && includeCheckoutAttributes)+ {+ var checkoutAttributes =+ customer.GetUserFieldFromEntity<List<CustomAttribute>>(SystemCustomerFieldNames.CheckoutAttributes,+ request.StoreId);+ if (checkoutAttributes.Any()){- var checkoutAttributes = customer.GetUserFieldFromEntity<List<CustomAttribute>>(SystemCustomerFieldNames.CheckoutAttributes, request.StoreId);- if (checkoutAttributes.Any())- {- var attributeValues = await _checkoutAttributeParser.ParseCheckoutAttributeValues(checkoutAttributes);- foreach (var attributeValue in attributeValues)- totalWeight += attributeValue.WeightAdjustment;- }+ var attributeValues = await _checkoutAttributeParser.ParseCheckoutAttributeValues(checkoutAttributes);+ foreach (var attributeValue in attributeValues)+ totalWeight += attributeValue.WeightAdjustment;}- return totalWeight;}+ return totalWeight;+ }- /// <summary>- /// Gets available shipping options- /// </summary>- /// <param name="getShippingOptionRequest">A request for getting shipping options</param>- /// <returns>Represents a response of getting shipping rate options</returns>- public async Task<GetShippingOptionResponse> GetShippingOptions(GetShippingOptionRequest getShippingOptionRequest)- {- ArgumentNullException.ThrowIfNull(getShippingOptionRequest);+ /// <summary>+ /// Gets available shipping options+ /// </summary>+ /// <param name="getShippingOptionRequest">A request for getting shipping options</param>+ /// <returns>Represents a response of getting shipping rate options</returns>+ public async Task<GetShippingOptionResponse> GetShippingOptions(GetShippingOptionRequest getShippingOptionRequest)+ {+ ArgumentNullException.ThrowIfNull(getShippingOptionRequest);- var response = new GetShippingOptionResponse();+ var response = new GetShippingOptionResponse();- if (getShippingOptionRequest.Items == null || getShippingOptionRequest.Items.Count == 0)- {- response.AddError("No shipment items");- return response;- }- if (getShippingOptionRequest.ShippingAddress == null)- {- response.AddError("Shipping address is not set");- return response;- }+ if (getShippingOptionRequest.Items == null || getShippingOptionRequest.Items.Count == 0)+ {+ response.AddError("No shipment items");+ return response;+ }- var storeId = getShippingOptionRequest.StoreId;- if (string.IsNullOrEmpty(storeId))- storeId = _workContext.CurrentStore.Id;- var countryId = getShippingOptionRequest.ShippingAddress.CountryId;- var stateProvinceId = getShippingOptionRequest.ShippingAddress.StateProvinceId;+ if (getShippingOptionRequest.ShippingAddress == null)+ {+ response.AddError("Shipping address is not set");+ return response;+ }- //string warehouseId = getShippingOptionRequest.WarehouseFrom != null ? getShippingOptionRequest.WarehouseFrom.Id : "";+ var storeId = getShippingOptionRequest.StoreId;+ if (string.IsNullOrEmpty(storeId))+ storeId = _workContext.CurrentStore.Id;+ var countryId = getShippingOptionRequest.ShippingAddress.CountryId;+ var stateProvinceId = getShippingOptionRequest.ShippingAddress.StateProvinceId;- var zip = getShippingOptionRequest.ShippingAddress.ZipPostalCode;- double subTotal = 0;- var priceCalculationService = _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<IPricingService>();+ //string warehouseId = getShippingOptionRequest.WarehouseFrom != null ? getShippingOptionRequest.WarehouseFrom.Id : "";- foreach (var packageItem in getShippingOptionRequest.Items)- {- if (packageItem.ShoppingCartItem.IsFreeShipping)- continue;+ var zip = getShippingOptionRequest.ShippingAddress.ZipPostalCode;+ double subTotal = 0;+ var priceCalculationService =+ _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<IPricingService>();- var product = await _productService.GetProductById(packageItem.ShoppingCartItem.ProductId);- if (product != null)- subTotal += (await priceCalculationService.GetSubTotal(packageItem.ShoppingCartItem, product)).subTotal;- }+ foreach (var packageItem in getShippingOptionRequest.Items)+ {+ if (packageItem.ShoppingCartItem.IsFreeShipping)+ continue;- var weight = await GetTotalWeight(getShippingOptionRequest);+ var product = await _productService.GetProductById(packageItem.ShoppingCartItem.ProductId);+ if (product != null)+ subTotal += (await priceCalculationService.GetSubTotal(packageItem.ShoppingCartItem, product)).subTotal;+ }- var shippingMethods = await _shippingMethodService.GetAllShippingMethods(countryId, _workContext.CurrentCustomer);- foreach (var shippingMethod in shippingMethods)+ var weight = await GetTotalWeight(getShippingOptionRequest);++ var shippingMethods =+ await _shippingMethodService.GetAllShippingMethods(countryId, _workContext.CurrentCustomer);+ foreach (var shippingMethod in shippingMethods)+ {+ double? rate = null;+ foreach (var item in getShippingOptionRequest.Items.GroupBy(x => x.ShoppingCartItem.WarehouseId)+ .Select(x => x.Key)){- double? rate = null;- foreach (var item in getShippingOptionRequest.Items.GroupBy(x => x.ShoppingCartItem.WarehouseId).Select(x=>x.Key))+ var _rate = await GetRate(subTotal, weight, shippingMethod.Id, storeId, item, countryId,+ stateProvinceId, zip);+ if (_rate.HasValue){- var _rate = await GetRate(subTotal, weight, shippingMethod.Id, storeId, item, countryId, stateProvinceId, zip);- if (_rate.HasValue)- {- rate ??= 0;+ rate ??= 0;- rate += _rate.Value;- }- }-- if (rate is { })- {- var shippingOption = new ShippingOption {- Name = shippingMethod.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),- Description = shippingMethod.GetTranslation(x => x.Description, _workContext.WorkingLanguage.Id),- Rate = await _currencyService.ConvertFromPrimaryStoreCurrency(rate.Value, _workContext.WorkingCurrency)- };- response.ShippingOptions.Add(shippingOption);+ rate += _rate.Value;}}-- return response;+ if (rate is not null)+ {+ var shippingOption = new ShippingOption {+ Name = shippingMethod.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),+ Description = shippingMethod.GetTranslation(x => x.Description, _workContext.WorkingLanguage.Id),+ Rate = await _currencyService.ConvertFromPrimaryStoreCurrency(rate.Value,+ _workContext.WorkingCurrency)+ };+ response.ShippingOptions.Add(shippingOption);+ }}- /// <summary>- /// Gets fixed shipping rate (if Shipping rate method allows it and the rate can be calculated before checkout).- /// </summary>- /// <param name="getShippingOptionRequest">A request for getting shipping options</param>- /// <returns>Fixed shipping rate; or null in case there's no fixed shipping rate</returns>- public async Task<double?> GetFixedRate(GetShippingOptionRequest getShippingOptionRequest)- {- return await Task.FromResult(default(double?));- }- /// <summary>- /// Returns a value indicating whether shipping methods should be hidden during checkout- /// </summary>- /// <param name="cart">Shopping cart</param>- /// <returns>true - hide; false - display.</returns>- public async Task<bool> HideShipmentMethods(IList<ShoppingCartItem> cart)- {- //you can put any logic here- //for example, hide this shipping methods if all products in the cart are downloadable- //or hide this shipping methods if current customer is from certain country- return await Task.FromResult(false);- }+ return response;+ }- #endregion+ /// <summary>+ /// Gets fixed shipping rate (if Shipping rate method allows it and the rate can be calculated before checkout).+ /// </summary>+ /// <param name="getShippingOptionRequest">A request for getting shipping options</param>+ /// <returns>Fixed shipping rate; or null in case there's no fixed shipping rate</returns>+ public async Task<double?> GetFixedRate(GetShippingOptionRequest getShippingOptionRequest)+ {+ return await Task.FromResult(default(double?));+ }- #region Properties+ /// <summary>+ /// Returns a value indicating whether shipping methods should be hidden during checkout+ /// </summary>+ /// <param name="cart">Shopping cart</param>+ /// <returns>true - hide; false - display.</returns>+ public async Task<bool> HideShipmentMethods(IList<ShoppingCartItem> cart)+ {+ //you can put any logic here+ //for example, hide this shipping methods if all products in the cart are downloadable+ //or hide this shipping methods if current customer is from certain country+ return await Task.FromResult(false);+ }+ #endregion- /// <summary>- /// Gets a shipment tracker- /// </summary>- public IShipmentTracker ShipmentTracker => null;+ #region Properties- public ShippingRateCalculationType ShippingRateCalculationType => ShippingRateCalculationType.Off;+ /// <summary>+ /// Gets a shipment tracker+ /// </summary>+ public IShipmentTracker ShipmentTracker => null;- public string ConfigurationUrl => ByWeightShippingDefaults.ConfigurationUrl;+ public ShippingRateCalculationType ShippingRateCalculationType => ShippingRateCalculationType.Off;- public string SystemName => ByWeightShippingDefaults.ProviderSystemName;+ public string ConfigurationUrl => ByWeightShippingDefaults.ConfigurationUrl;- public string FriendlyName => _translationService.GetResource(ByWeightShippingDefaults.FriendlyName);+ public string SystemName => ByWeightShippingDefaults.ProviderSystemName;- public int Priority => _byWeightShippingSettings.DisplayOrder;+ public string FriendlyName => _translationService.GetResource(ByWeightShippingDefaults.FriendlyName);- public IList<string> LimitedToStores => new List<string>();+ public int Priority => _byWeightShippingSettings.DisplayOrder;- public IList<string> LimitedToGroups => new List<string>();+ public IList<string> LimitedToStores => new List<string>();- public async Task<IList<string>> ValidateShippingForm(string shippingOption, IDictionary<string, string> data)- {- //you can implement here any validation logic- return await Task.FromResult(new List<string>());- }+ public IList<string> LimitedToGroups => new List<string>();- public async Task<string> GetControllerRouteName()- {- return await Task.FromResult("");- }+ public async Task<IList<string>> ValidateShippingForm(string shippingOption, IDictionary<string, string> data)+ {+ //you can implement here any validation logic+ return await Task.FromResult(new List<string>());+ }- #endregion+ public async Task<string> GetControllerRouteName()+ {+ return await Task.FromResult("");}-}+ #endregion+}\ No newline at end of filediff --git a/src/Plugins/Shipping.ByWeight/ByWeightShippingSettings.cs b/src/Plugins/Shipping.ByWeight/ByWeightShippingSettings.csindex 0718cb84a..e1bc06f57 100644--- a/src/Plugins/Shipping.ByWeight/ByWeightShippingSettings.cs+++ b/src/Plugins/Shipping.ByWeight/ByWeightShippingSettings.cs@@ -1,11 +1,9 @@using Grand.Domain.Configuration;-namespace Shipping.ByWeight-{- public class ByWeightShippingSettings : ISettings- {- public bool LimitMethodsToCreated { get; set; }- public int DisplayOrder { get; set; }+namespace Shipping.ByWeight;- }-}+public class ByWeightShippingSettings : ISettings+{+ public bool LimitMethodsToCreated { get; set; }+ public int DisplayOrder { get; set; }+}\ No newline at end of filediff --git a/src/Plugins/Shipping.ByWeight/Domain/ShippingByWeightRecord.cs b/src/Plugins/Shipping.ByWeight/Domain/ShippingByWeightRecord.csindex 994fa81af..c8bc68d6f 100644--- a/src/Plugins/Shipping.ByWeight/Domain/ShippingByWeightRecord.cs+++ b/src/Plugins/Shipping.ByWeight/Domain/ShippingByWeightRecord.cs@@ -1,70 +1,69 @@using Grand.Domain;-namespace Shipping.ByWeight.Domain+namespace Shipping.ByWeight.Domain;++/// <summary>+/// Represents a shipping by weight record+/// </summary>+public class ShippingByWeightRecord : BaseEntity{/// <summary>- /// Represents a shipping by weight record+ /// Gets or sets the store identifier/// </summary>- public class ShippingByWeightRecord : BaseEntity- {- /// <summary>- /// Gets or sets the store identifier- /// </summary>- public string StoreId { get; set; }+ public string StoreId { get; set; }- /// <summary>- /// Gets or sets the warehouse identifier- /// </summary>- public string WarehouseId { get; set; }+ /// <summary>+ /// Gets or sets the warehouse identifier+ /// </summary>+ public string WarehouseId { get; set; }- /// <summary>- /// Gets or sets the country identifier- /// </summary>- public string CountryId { get; set; }+ /// <summary>+ /// Gets or sets the country identifier+ /// </summary>+ public string CountryId { get; set; }- /// <summary>- /// Gets or sets the state/province identifier- /// </summary>- public string StateProvinceId { get; set; }+ /// <summary>+ /// Gets or sets the state/province identifier+ /// </summary>+ public string StateProvinceId { get; set; }- /// <summary>- /// Gets or sets the zip- /// </summary>- public string Zip { get; set; }+ /// <summary>+ /// Gets or sets the zip+ /// </summary>+ public string Zip { get; set; }- /// <summary>- /// Gets or sets the shipping method identifier- /// </summary>- public string ShippingMethodId { get; set; }+ /// <summary>+ /// Gets or sets the shipping method identifier+ /// </summary>+ public string ShippingMethodId { get; set; }- /// <summary>- /// Gets or sets the "from" value- /// </summary>- public double From { get; set; }+ /// <summary>+ /// Gets or sets the "from" value+ /// </summary>+ public double From { get; set; }- /// <summary>- /// Gets or sets the "to" value- /// </summary>- public double To { get; set; }+ /// <summary>+ /// Gets or sets the "to" value+ /// </summary>+ public double To { get; set; }- /// <summary>- /// Gets or sets the additional fixed cost- /// </summary>- public double AdditionalFixedCost { get; set; }+ /// <summary>+ /// Gets or sets the additional fixed cost+ /// </summary>+ public double AdditionalFixedCost { get; set; }- /// <summary>- /// Gets or sets the shipping charge percentage (of subtotal)- /// </summary>- public double PercentageRateOfSubtotal { get; set; }+ /// <summary>+ /// Gets or sets the shipping charge percentage (of subtotal)+ /// </summary>+ public double PercentageRateOfSubtotal { get; set; }- /// <summary>- /// Gets or sets the shipping charge amount (per weight unit)- /// </summary>- public double RatePerWeightUnit { get; set; }+ /// <summary>+ /// Gets or sets the shipping charge amount (per weight unit)+ /// </summary>+ public double RatePerWeightUnit { get; set; }- /// <summary>- /// Gets or sets the lower weight limit- /// </summary>- public double LowerWeightLimit { get; set; }- }+ /// <summary>+ /// Gets or sets the lower weight limit+ /// </summary>+ public double LowerWeightLimit { get; set; }}\ No newline at end of filediff --git a/src/Plugins/Shipping.ByWeight/Models/ShippingByWeightListModel.cs b/src/Plugins/Shipping.ByWeight/Models/ShippingByWeightListModel.csindex 3d56b4cea..2488c68fe 100644--- a/src/Plugins/Shipping.ByWeight/Models/ShippingByWeightListModel.cs+++ b/src/Plugins/Shipping.ByWeight/Models/ShippingByWeightListModel.cs@@ -1,14 +1,13 @@using Grand.Infrastructure.ModelBinding;using Grand.Infrastructure.Models;-namespace Shipping.ByWeight.Models+namespace Shipping.ByWeight.Models;++public class ShippingByWeightListModel : BaseModel{- public class ShippingByWeightListModel : BaseModel- {- [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.LimitMethodsToCreated")]- public bool LimitMethodsToCreated { get; set; }+ [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.LimitMethodsToCreated")]+ public bool LimitMethodsToCreated { get; set; }- [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.DisplayOrder")]- public int DisplayOrder { 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/Models/ShippingByWeightModel.cs b/src/Plugins/Shipping.ByWeight/Models/ShippingByWeightModel.csindex 0e2dd4ce5..7e85707c2 100644--- a/src/Plugins/Shipping.ByWeight/Models/ShippingByWeightModel.cs+++ b/src/Plugins/Shipping.ByWeight/Models/ShippingByWeightModel.cs@@ -2,67 +2,71 @@using Grand.Infrastructure.Models;using Microsoft.AspNetCore.Mvc.Rendering;-namespace Shipping.ByWeight.Models+namespace Shipping.ByWeight.Models;++public class ShippingByWeightModel : BaseEntityModel{- public class ShippingByWeightModel : BaseEntityModel- {- [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.Store")]- public string StoreId { get; set; }- [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.Store")]- public string StoreName { get; set; }+ [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.Store")]+ public string StoreId { get; set; }++ [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.Store")]+ public string StoreName { get; set; }++ [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.Warehouse")]+ public string WarehouseId { get; set; }++ [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.Warehouse")]+ public string WarehouseName { get; set; }++ [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.Country")]+ public string CountryId { get; set; }++ [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.Country")]+ public string CountryName { get; set; }- [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.Warehouse")]- public string WarehouseId { get; set; }- [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.Warehouse")]- public string WarehouseName { get; set; }+ [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.StateProvince")]+ public string StateProvinceId { get; set; }- [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.Country")]- public string CountryId { get; set; }- [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.Country")]- public string CountryName { get; set; }+ [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.StateProvince")]+ public string StateProvinceName { get; set; }- [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.StateProvince")]- public string StateProvinceId { get; set; }- [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.StateProvince")]- public string StateProvinceName { get; set; }+ [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.Zip")]+ public string Zip { get; set; }- [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.Zip")]- public string Zip { get; set; }+ [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.ShippingMethod")]+ public string ShippingMethodId { get; set; }- [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.ShippingMethod")]- public string ShippingMethodId { get; set; }- [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.ShippingMethod")]- public string ShippingMethodName { get; set; }+ [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.ShippingMethod")]+ public string ShippingMethodName { get; set; }- [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.From")]- public double From { get; set; }+ [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.From")]+ public double From { get; set; }- [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.To")]- public double To { get; set; }+ [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.To")]+ public double To { get; set; }- [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.AdditionalFixedCost")]- public double AdditionalFixedCost { get; set; }+ [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.AdditionalFixedCost")]+ public double AdditionalFixedCost { get; set; }- [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.PercentageRateOfSubtotal")]- public double PercentageRateOfSubtotal { get; set; }+ [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.PercentageRateOfSubtotal")]+ public double PercentageRateOfSubtotal { get; set; }- [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.RatePerWeightUnit")]- public double RatePerWeightUnit { get; set; }+ [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.RatePerWeightUnit")]+ public double RatePerWeightUnit { get; set; }- [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.LowerWeightLimit")]- public double LowerWeightLimit { get; set; }+ [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.LowerWeightLimit")]+ public double LowerWeightLimit { get; set; }- [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.DataHtml")]- public string DataHtml { get; set; }+ [GrandResourceDisplayName("Plugins.Shipping.ByWeight.Fields.DataHtml")]+ public string DataHtml { get; set; }- public string PrimaryStoreCurrencyCode { get; set; }- public string BaseWeightIn { get; set; }+ public string PrimaryStoreCurrencyCode { get; set; }+ public string BaseWeightIn { get; set; }- public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();- public IList<SelectListItem> AvailableStates { get; set; } = new List<SelectListItem>();- public IList<SelectListItem> AvailableShippingMethods { get; set; } = new List<SelectListItem>();- public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();- public IList<SelectListItem> AvailableWarehouses { get; set; } = new List<SelectListItem>();- }+ public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();+ public IList<SelectListItem> AvailableStates { get; set; } = new List<SelectListItem>();+ public IList<SelectListItem> AvailableShippingMethods { get; set; } = new List<SelectListItem>();+ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();+ public IList<SelectListItem> AvailableWarehouses { get; set; } = new List<SelectListItem>();}\ No newline at end of filediff --git a/src/Plugins/Shipping.ByWeight/Services/IShippingByWeightService.cs b/src/Plugins/Shipping.ByWeight/Services/IShippingByWeightService.csindex 903e03e8d..38b269f5b 100644--- a/src/Plugins/Shipping.ByWeight/Services/IShippingByWeightService.cs+++ b/src/Plugins/Shipping.ByWeight/Services/IShippingByWeightService.cs@@ -1,23 +1,21 @@using Grand.Domain;using Shipping.ByWeight.Domain;-namespace Shipping.ByWeight.Services-{- public interface IShippingByWeightService- {- Task DeleteShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord);+namespace Shipping.ByWeight.Services;- Task<IPagedList<ShippingByWeightRecord>> GetAll(int pageIndex = 0, int pageSize = int.MaxValue);+public interface IShippingByWeightService+{+ Task DeleteShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord);- Task<ShippingByWeightRecord> FindRecord(string shippingMethodId,- string storeId, string warehouseId,- string countryId, string stateProvinceId, string zip, double weight);+ Task<IPagedList<ShippingByWeightRecord>> GetAll(int pageIndex = 0, int pageSize = int.MaxValue);- Task<ShippingByWeightRecord> GetById(string shippingByWeightRecordId);+ Task<ShippingByWeightRecord> FindRecord(string shippingMethodId,+ string storeId, string warehouseId,+ string countryId, string stateProvinceId, string zip, double weight);- Task InsertShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord);+ Task<ShippingByWeightRecord> GetById(string shippingByWeightRecordId);- Task UpdateShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord);- }+ Task InsertShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord);-}+ Task UpdateShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord);+}\ No newline at end of filediff --git a/src/Plugins/Shipping.ByWeight/Services/ShippingByWeightService.cs b/src/Plugins/Shipping.ByWeight/Services/ShippingByWeightService.csindex a847ade3e..3fea1f3df 100644--- a/src/Plugins/Shipping.ByWeight/Services/ShippingByWeightService.cs+++ b/src/Plugins/Shipping.ByWeight/Services/ShippingByWeightService.cs@@ -1,122 +1,121 @@-using Grand.Domain;-using Grand.Data;+using Grand.Data;+using Grand.Domain;using Grand.Infrastructure.Caching;using Shipping.ByWeight.Domain;-namespace Shipping.ByWeight.Services+namespace Shipping.ByWeight.Services;++public class ShippingByWeightService : IShippingByWeightService{- public class ShippingByWeightService : IShippingByWeightService+ #region Ctor++ public ShippingByWeightService(ICacheBase cacheBase,+ IRepository<ShippingByWeightRecord> sbwRepository){- #region Constants- private const string SHIPPINGBYWEIGHT_ALL_KEY = "Grand.shippingbyweight.all-{0}-{1}";- private const string SHIPPINGBYWEIGHT_PATTERN_KEY = "Grand.shippingbyweight.";- #endregion+ _cacheBase = cacheBase;+ _sbwRepository = sbwRepository;+ }- #region Fields+ #endregion- private readonly IRepository<ShippingByWeightRecord> _sbwRepository;- private readonly ICacheBase _cacheBase;+ #region Constants- #endregion+ private const string SHIPPINGBYWEIGHT_ALL_KEY = "Grand.shippingbyweight.all-{0}-{1}";+ private const string SHIPPINGBYWEIGHT_PATTERN_KEY = "Grand.shippingbyweight.";- #region Ctor+ #endregion- public ShippingByWeightService(ICacheBase cacheBase,- IRepository<ShippingByWeightRecord> sbwRepository)- {- _cacheBase = cacheBase;- _sbwRepository = sbwRepository;- }+ #region Fields- #endregion+ private readonly IRepository<ShippingByWeightRecord> _sbwRepository;+ private readonly ICacheBase _cacheBase;- #region Methods+ #endregion- public virtual async Task DeleteShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord)- {- ArgumentNullException.ThrowIfNull(shippingByWeightRecord);+ #region Methods- await _sbwRepository.DeleteAsync(shippingByWeightRecord);+ public virtual async Task DeleteShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord)+ {+ ArgumentNullException.ThrowIfNull(shippingByWeightRecord);- await _cacheBase.RemoveByPrefix(SHIPPINGBYWEIGHT_PATTERN_KEY);- }+ await _sbwRepository.DeleteAsync(shippingByWeightRecord);- public virtual async Task<IPagedList<ShippingByWeightRecord>> GetAll(int pageIndex = 0, int pageSize = int.MaxValue)- {- var key = string.Format(SHIPPINGBYWEIGHT_ALL_KEY, pageIndex, pageSize);- return await _cacheBase.GetAsync(key, () =>- {- var query = from sbw in _sbwRepository.Table- select sbw;-- return Task.FromResult(new PagedList<ShippingByWeightRecord>(query, pageIndex, pageSize));- });- }-- public virtual async Task<ShippingByWeightRecord> FindRecord(string shippingMethodId,- string storeId, string warehouseId,- string countryId, string stateProvinceId, string zip, double weight)- {- zip ??= string.Empty;- zip = zip.Trim();-- var existingRates = (await GetAll())- .Where(sbw => sbw.ShippingMethodId == shippingMethodId && weight >= sbw.From && weight <= sbw.To)- .ToList();-- if (!string.IsNullOrEmpty(warehouseId))- existingRates = existingRates.Any(x => x.WarehouseId == warehouseId)- ? existingRates.Where(x => x.WarehouseId == warehouseId).ToList()- : existingRates.Where(x => string.IsNullOrEmpty(x.WarehouseId)).ToList();-- if (!string.IsNullOrEmpty(storeId))- existingRates = existingRates.Any(x => x.StoreId == storeId)- ? existingRates.Where(x => x.StoreId == storeId).ToList()- : existingRates.Where(x => string.IsNullOrEmpty(x.StoreId)).ToList();-- if (!string.IsNullOrEmpty(countryId))- existingRates = existingRates.Any(x => x.CountryId == countryId)- ? existingRates.Where(x => x.CountryId == countryId).ToList()- : existingRates.Where(x => string.IsNullOrEmpty(x.CountryId)).ToList();-- if (!string.IsNullOrEmpty(stateProvinceId))- existingRates = existingRates.Any(x => x.StateProvinceId == stateProvinceId)- ? existingRates.Where(x => x.StateProvinceId == stateProvinceId).ToList()- : existingRates.Where(x => string.IsNullOrEmpty(x.StateProvinceId)).ToList();-- if (!string.IsNullOrEmpty(zip))- existingRates = existingRates.Any(x => x.Zip == zip)- ? existingRates.Where(x => x.Zip == zip).ToList()- : existingRates.Where(x => string.IsNullOrEmpty(x.Zip)).ToList();-- return existingRates.FirstOrDefault();-- }-- public virtual Task<ShippingByWeightRecord> GetById(string shippingByWeightRecordId)- {- return _sbwRepository.GetByIdAsync(shippingByWeightRecordId);- }+ await _cacheBase.RemoveByPrefix(SHIPPINGBYWEIGHT_PATTERN_KEY);+ }- public virtual async Task InsertShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord)+ public virtual async Task<IPagedList<ShippingByWeightRecord>> GetAll(int pageIndex = 0, int pageSize = int.MaxValue)+ {+ var key = string.Format(SHIPPINGBYWEIGHT_ALL_KEY, pageIndex, pageSize);+ return await _cacheBase.GetAsync(key, () =>{- ArgumentNullException.ThrowIfNull(shippingByWeightRecord);+ var query = from sbw in _sbwRepository.Table+ select sbw;- await _sbwRepository.InsertAsync(shippingByWeightRecord);+ return Task.FromResult(new PagedList<ShippingByWeightRecord>(query, pageIndex, pageSize));+ });+ }- await _cacheBase.RemoveByPrefix(SHIPPINGBYWEIGHT_PATTERN_KEY);- }+ public virtual async Task<ShippingByWeightRecord> FindRecord(string shippingMethodId,+ string storeId, string warehouseId,+ string countryId, string stateProvinceId, string zip, double weight)+ {+ zip ??= string.Empty;+ zip = zip.Trim();++ var existingRates = (await GetAll())+ .Where(sbw => sbw.ShippingMethodId == shippingMethodId && weight >= sbw.From && weight <= sbw.To)+ .ToList();++ if (!string.IsNullOrEmpty(warehouseId))+ existingRates = existingRates.Any(x => x.WarehouseId == warehouseId)+ ? existingRates.Where(x => x.WarehouseId == warehouseId).ToList()+ : existingRates.Where(x => string.IsNullOrEmpty(x.WarehouseId)).ToList();++ if (!string.IsNullOrEmpty(storeId))+ existingRates = existingRates.Any(x => x.StoreId == storeId)+ ? existingRates.Where(x => x.StoreId == storeId).ToList()+ : existingRates.Where(x => string.IsNullOrEmpty(x.StoreId)).ToList();++ if (!string.IsNullOrEmpty(countryId))+ existingRates = existingRates.Any(x => x.CountryId == countryId)+ ? existingRates.Where(x => x.CountryId == countryId).ToList()+ : existingRates.Where(x => string.IsNullOrEmpty(x.CountryId)).ToList();++ if (!string.IsNullOrEmpty(stateProvinceId))+ existingRates = existingRates.Any(x => x.StateProvinceId == stateProvinceId)+ ? existingRates.Where(x => x.StateProvinceId == stateProvinceId).ToList()+ : existingRates.Where(x => string.IsNullOrEmpty(x.StateProvinceId)).ToList();++ if (!string.IsNullOrEmpty(zip))+ existingRates = existingRates.Any(x => x.Zip == zip)+ ? existingRates.Where(x => x.Zip == zip).ToList()+ : existingRates.Where(x => string.IsNullOrEmpty(x.Zip)).ToList();++ return existingRates.FirstOrDefault();+ }- public virtual async Task UpdateShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord)- {- ArgumentNullException.ThrowIfNull(shippingByWeightRecord);+ public virtual Task<ShippingByWeightRecord> GetById(string shippingByWeightRecordId)+ {+ return _sbwRepository.GetByIdAsync(shippingByWeightRecordId);+ }- await _sbwRepository.UpdateAsync(shippingByWeightRecord);+ public virtual async Task InsertShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord)+ {+ ArgumentNullException.ThrowIfNull(shippingByWeightRecord);++ await _sbwRepository.InsertAsync(shippingByWeightRecord);++ await _cacheBase.RemoveByPrefix(SHIPPINGBYWEIGHT_PATTERN_KEY);+ }++ public virtual async Task UpdateShippingByWeightRecord(ShippingByWeightRecord shippingByWeightRecord)+ {+ ArgumentNullException.ThrowIfNull(shippingByWeightRecord);- await _cacheBase.RemoveByPrefix(SHIPPINGBYWEIGHT_PATTERN_KEY);- }+ await _sbwRepository.UpdateAsync(shippingByWeightRecord);- #endregion+ await _cacheBase.RemoveByPrefix(SHIPPINGBYWEIGHT_PATTERN_KEY);}-}+ #endregion+}\ No newline at end of filediff --git a/src/Plugins/Shipping.ByWeight/StartupApplication.cs b/src/Plugins/Shipping.ByWeight/StartupApplication.csindex 3d0f4f745..caf930020 100644--- a/src/Plugins/Shipping.ByWeight/StartupApplication.cs+++ b/src/Plugins/Shipping.ByWeight/StartupApplication.cs@@ -6,22 +6,21 @@ using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;using Shipping.ByWeight.Services;-namespace Shipping.ByWeight+namespace Shipping.ByWeight;++public class StartupApplication : IStartupApplication{- public class StartupApplication : IStartupApplication+ public void ConfigureServices(IServiceCollection services, IConfiguration configuration){- public void ConfigureServices(IServiceCollection services, IConfiguration configuration)- {- services.AddScoped<IShippingByWeightService, ShippingByWeightService>();- services.AddScoped<IShippingRateCalculationProvider, ByWeightShippingCalcPlugin>();- }-- public int Priority => 10;- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)- {+ services.AddScoped<IShippingByWeightService, ShippingByWeightService>();+ services.AddScoped<IShippingRateCalculationProvider, ByWeightShippingCalcPlugin>();+ }- }- public bool BeforeConfigure => false;+ public int Priority => 10;+ public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)+ {}-}++ public bool BeforeConfigure => false;+}\ No newline at end of filediff --git a/src/Plugins/Shipping.FixedRateShipping/Areas/Admin/Controllers/ShippingFixedRateController.cs b/src/Plugins/Shipping.FixedRateShipping/Areas/Admin/Controllers/ShippingFixedRateController.csindex 9eae61f0a..9a8111bc8 100644--- a/src/Plugins/Shipping.FixedRateShipping/Areas/Admin/Controllers/ShippingFixedRateController.cs+++ b/src/Plugins/Shipping.FixedRateShipping/Areas/Admin/Controllers/ShippingFixedRateController.cs@@ -8,79 +8,76 @@ using Grand.Web.Common.Filters;using Microsoft.AspNetCore.Mvc;using Shipping.FixedRateShipping.Models;-namespace Shipping.FixedRateShipping.Areas.Admin.Controllers+namespace Shipping.FixedRateShipping.Areas.Admin.Controllers;++[Area("Admin")]+[AuthorizeAdmin]+public class ShippingFixedRateController : BaseShippingController{- [Area("Admin")]- [AuthorizeAdmin]- public class ShippingFixedRateController : BaseShippingController+ private readonly IPermissionService _permissionService;+ private readonly ISettingService _settingService;+ private readonly IShippingMethodService _shippingMethodService;++ public ShippingFixedRateController(+ IShippingMethodService shippingMethodService,+ ISettingService settingService,+ IPermissionService permissionService){- private readonly IShippingMethodService _shippingMethodService;- private readonly ISettingService _settingService;- private readonly IPermissionService _permissionService;+ _shippingMethodService = shippingMethodService;+ _settingService = settingService;+ _permissionService = permissionService;+ }- public ShippingFixedRateController(- IShippingMethodService shippingMethodService,- ISettingService settingService,- IPermissionService permissionService)- {- _shippingMethodService = shippingMethodService;- _settingService = settingService;- _permissionService = permissionService;- }+ public IActionResult Configure()+ {+ return View();+ }- public IActionResult Configure()- {- return View();- }+ [HttpPost]+ public async Task<IActionResult> Configure(DataSourceRequest command)+ {+ if (!await _permissionService.Authorize(StandardPermission.ManageShippingSettings))+ return Content("Access denied");- [HttpPost]- public async Task<IActionResult> Configure(DataSourceRequest command)- {- if (!await _permissionService.Authorize(StandardPermission.ManageShippingSettings))- return Content("Access denied");+ var rateModels = new List<FixedShippingRateModel>();+ foreach (var shippingMethod in await _shippingMethodService.GetAllShippingMethods())+ rateModels.Add(new FixedShippingRateModel {+ ShippingMethodId = shippingMethod.Id,+ ShippingMethodName = shippingMethod.Name,+ Rate = GetShippingRate(shippingMethod.Id)+ });- var rateModels = new List<FixedShippingRateModel>();- foreach (var shippingMethod in await _shippingMethodService.GetAllShippingMethods())- rateModels.Add(new FixedShippingRateModel- {- ShippingMethodId = shippingMethod.Id,- ShippingMethodName = shippingMethod.Name,- Rate = GetShippingRate(shippingMethod.Id)- });+ var gridModel = new DataSourceResult {+ Data = rateModels,+ Total = rateModels.Count+ };+ return Json(gridModel);+ }- var gridModel = new DataSourceResult- {- Data = rateModels,- Total = rateModels.Count- };- return Json(gridModel);- }-- [HttpPost]- [AutoValidateAntiforgeryToken]- public async Task<IActionResult> ShippingRateUpdate(FixedShippingRateModel model)- {- if (!await _permissionService.Authorize(StandardPermission.ManageShippingSettings))- return Content("Access denied");+ [HttpPost]+ [AutoValidateAntiforgeryToken]+ public async Task<IActionResult> ShippingRateUpdate(FixedShippingRateModel model)+ {+ if (!await _permissionService.Authorize(StandardPermission.ManageShippingSettings))+ return Content("Access denied");- var shippingMethodId = model.ShippingMethodId;- var rate = new FixedShippingRate {- Rate = model.Rate- };+ var shippingMethodId = model.ShippingMethodId;+ var rate = new FixedShippingRate {+ Rate = model.Rate+ };- await _settingService.SetSetting(- $"ShippingRateComputationMethod.FixedRate.Rate.ShippingMethodId{shippingMethodId}", rate);+ await _settingService.SetSetting(+ $"ShippingRateComputationMethod.FixedRate.Rate.ShippingMethodId{shippingMethodId}", rate);- return new JsonResult("");- }+ return new JsonResult("");+ }- [NonAction]- private double GetShippingRate(string shippingMethodId)- {- var rate = _settingService.GetSettingByKey<FixedShippingRate>(- $"ShippingRateComputationMethod.FixedRate.Rate.ShippingMethodId{shippingMethodId}")?.Rate;- return rate ?? 0;- }+ [NonAction]+ private double GetShippingRate(string shippingMethodId)+ {+ var rate = _settingService.GetSettingByKey<FixedShippingRate>(+ $"ShippingRateComputationMethod.FixedRate.Rate.ShippingMethodId{shippingMethodId}")?.Rate;+ return rate ?? 0;}}\ No newline at end of filediff --git a/src/Plugins/Shipping.FixedRateShipping/Areas/Admin/Views/ShippingFixedRate/Configure.cshtml b/src/Plugins/Shipping.FixedRateShipping/Areas/Admin/Views/ShippingFixedRate/Configure.cshtmlindex 29cc37933..5061dd7bd 100644--- a/src/Plugins/Shipping.FixedRateShipping/Areas/Admin/Views/ShippingFixedRate/Configure.cshtml+++ b/src/Plugins/Shipping.FixedRateShipping/Areas/Admin/Views/ShippingFixedRate/Configure.cshtml@@ -1,7 +1,7 @@@{Layout = "_ConfigurePlugin";}-<input id="active-menu-item" type="hidden" value="/Admin/Shipping/Providers" />+<input id="active-menu-item" type="hidden" value="/Admin/Shipping/Providers"/><div class="panel-group"><div class="panel panel-default"><div class="panel-body">diff --git a/src/Plugins/Shipping.FixedRateShipping/Areas/Admin/Views/ShippingFixedRate/_ViewImports.cshtml b/src/Plugins/Shipping.FixedRateShipping/Areas/Admin/Views/ShippingFixedRate/_ViewImports.cshtmlindex 2fb08c043..fb3b84aa9 100644--- a/src/Plugins/Shipping.FixedRateShipping/Areas/Admin/Views/ShippingFixedRate/_ViewImports.cshtml+++ b/src/Plugins/Shipping.FixedRateShipping/Areas/Admin/Views/ShippingFixedRate/_ViewImports.cshtml@@ -4,5 +4,6 @@@using Microsoft.AspNetCore.Mvc.ViewFeatures@using Grand.Infrastructure.Extensions+@using Grand.Web.Common.Localization-@inject Grand.Web.Common.Localization.LocService Loc+@inject LocService Loc\ No newline at end of filediff --git a/src/Plugins/Shipping.FixedRateShipping/FixedRateShippingDefaults.cs b/src/Plugins/Shipping.FixedRateShipping/FixedRateShippingDefaults.csindex 5d4efae35..b6b5dd4dd 100644--- a/src/Plugins/Shipping.FixedRateShipping/FixedRateShippingDefaults.cs+++ b/src/Plugins/Shipping.FixedRateShipping/FixedRateShippingDefaults.cs@@ -1,9 +1,8 @@-namespace Shipping.FixedRateShipping+namespace Shipping.FixedRateShipping;++public static class FixedRateShippingDefaults{- public static class FixedRateShippingDefaults- {- public const string ProviderSystemName = "Shipping.FixedRate";- public const string FriendlyName = "Shipping.FixedRate.FriendlyName";- public const string ConfigurationUrl = "../ShippingFixedRate/Configure";- }-}+ public const string ProviderSystemName = "Shipping.FixedRate";+ public const string FriendlyName = "Shipping.FixedRate.FriendlyName";+ public const string ConfigurationUrl = "../ShippingFixedRate/Configure";+}\ No newline at end of filediff --git a/src/Plugins/Shipping.FixedRateShipping/FixedRateShippingPlugin.cs b/src/Plugins/Shipping.FixedRateShipping/FixedRateShippingPlugin.csindex b3505dc11..c22f9e9d1 100644--- a/src/Plugins/Shipping.FixedRateShipping/FixedRateShippingPlugin.cs+++ b/src/Plugins/Shipping.FixedRateShipping/FixedRateShippingPlugin.cs@@ -2,60 +2,66 @@using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Infrastructure.Plugins;-namespace Shipping.FixedRateShipping+namespace Shipping.FixedRateShipping;++/// <summary>+/// Fixed rate shipping computation method+/// </summary>+public class FixedRateShippingPlugin : BasePlugin, IPlugin{+ #region Ctor++ public FixedRateShippingPlugin(+ ITranslationService translationService,+ ILanguageService languageService)+ {+ _translationService = translationService;+ _languageService = languageService;+ }++ #endregion++ #region Fields++ private readonly ITranslationService _translationService;+ private readonly ILanguageService _languageService;++ #endregion++ #region Methods+/// <summary>- /// Fixed rate shipping computation method+ /// Install plugin/// </summary>- public class FixedRateShippingPlugin : BasePlugin, IPlugin+ public override async Task Install(){- #region Fields-- private readonly ITranslationService _translationService;- private readonly ILanguageService _languageService;- #endregion-- #region Ctor- public FixedRateShippingPlugin(- ITranslationService translationService,- ILanguageService languageService)- {- _translationService = translationService;- _languageService = languageService;- }- #endregion-- #region Methods-- /// <summary>- /// Install plugin- /// </summary>- public override async Task Install()- {- //locales- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.FixedRate.FriendlyName", "Shipping fixed rate");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Shipping.FixedRateShipping.Fields.ShippingMethodName", "Shipping method");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Shipping.FixedRateShipping.Fields.Rate", "Rate");-- await base.Install();- }--- /// <summary>- /// Uninstall plugin- /// </summary>- public override async Task Uninstall()- {- //locales- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Shipping.FixedRateShipping.Fields.ShippingMethodName");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Shipping.FixedRateShipping.Fields.Rate");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.FixedRate.FriendlyName");-- await base.Uninstall();- }--- #endregion+ //locales+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.FixedRate.FriendlyName", "Shipping fixed rate");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Shipping.FixedRateShipping.Fields.ShippingMethodName", "Shipping method");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Shipping.FixedRateShipping.Fields.Rate", "Rate");+ await base.Install();}+++ /// <summary>+ /// Uninstall plugin+ /// </summary>+ public override async Task Uninstall()+ {+ //locales+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Shipping.FixedRateShipping.Fields.ShippingMethodName");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Shipping.FixedRateShipping.Fields.Rate");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.FixedRate.FriendlyName");++ await base.Uninstall();+ }++ #endregion}\ No newline at end of filediff --git a/src/Plugins/Shipping.FixedRateShipping/FixedRateShippingProvider.cs b/src/Plugins/Shipping.FixedRateShipping/FixedRateShippingProvider.csindex d1e3d2f68..7629720cb 100644--- a/src/Plugins/Shipping.FixedRateShipping/FixedRateShippingProvider.cs+++ b/src/Plugins/Shipping.FixedRateShipping/FixedRateShippingProvider.cs@@ -1,140 +1,149 @@using Grand.Business.Core.Enums.Checkout;-using Grand.Business.Core.Interfaces.Checkout.Shipping;-using Grand.Business.Core.Utilities.Checkout;using Grand.Business.Core.Extensions;+using Grand.Business.Core.Interfaces.Checkout.Shipping;using Grand.Business.Core.Interfaces.Common.Configuration;using Grand.Business.Core.Interfaces.Common.Directory;using Grand.Business.Core.Interfaces.Common.Localization;+using Grand.Business.Core.Utilities.Checkout;using Grand.Domain.Orders;using Grand.Domain.Shipping;using Grand.Infrastructure;using Shipping.FixedRateShipping.Models;-namespace Shipping.FixedRateShipping+namespace Shipping.FixedRateShipping;++public class FixedRateShippingProvider : IShippingRateCalculationProvider{- public class FixedRateShippingProvider : IShippingRateCalculationProvider+ private readonly ICurrencyService _currencyService;+ private readonly ISettingService _settingService;+ private readonly ShippingFixedRateSettings _shippingFixedRateSettings;++ private readonly IShippingMethodService _shippingMethodService;+ private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;+++ public FixedRateShippingProvider(+ IShippingMethodService shippingMethodService,+ IWorkContext workContext,+ ISettingService settingService,+ ICurrencyService currencyService,+ ITranslationService translationService,+ ShippingFixedRateSettings shippingFixedRateSettings+ )+ {+ _shippingMethodService = shippingMethodService;+ _workContext = workContext;+ _settingService = settingService;+ _currencyService = currencyService;+ _translationService = translationService;+ _shippingFixedRateSettings = shippingFixedRateSettings;+ }+++ /// <summary>+ /// Gets available shipping options+ /// </summary>+ /// <param name="getShippingOptionRequest">A request for getting shipping options</param>+ /// <returns>Represents a response of getting shipping rate options</returns>+ public async Task<GetShippingOptionResponse> GetShippingOptions(GetShippingOptionRequest getShippingOptionRequest){+ ArgumentNullException.ThrowIfNull(getShippingOptionRequest);- private readonly IShippingMethodService _shippingMethodService;- private readonly IWorkContext _workContext;- private readonly ISettingService _settingService;- private readonly ICurrencyService _currencyService;- private readonly ITranslationService _translationService;- private readonly ShippingFixedRateSettings _shippingFixedRateSettings;--- public FixedRateShippingProvider(- IShippingMethodService shippingMethodService,- IWorkContext workContext,- ISettingService settingService,- ICurrencyService currencyService,- ITranslationService translationService,- ShippingFixedRateSettings shippingFixedRateSettings- )+ var response = new GetShippingOptionResponse();++ if (getShippingOptionRequest.Items == null || getShippingOptionRequest.Items.Count == 0){- _shippingMethodService = shippingMethodService;- _workContext = workContext;- _settingService = settingService;- _currencyService = currencyService;- _translationService = translationService;- _shippingFixedRateSettings = shippingFixedRateSettings;+ response.AddError("No shipment items");+ return response;}- #region Utilities- private double GetRate(string shippingMethodId)+ var restrictByCountryId =+ getShippingOptionRequest.ShippingAddress != null &&+ !string.IsNullOrEmpty(getShippingOptionRequest.ShippingAddress.CountryId)+ ? getShippingOptionRequest.ShippingAddress.CountryId+ : "";+ var shippingMethods =+ await _shippingMethodService.GetAllShippingMethods(restrictByCountryId, getShippingOptionRequest.Customer);+ foreach (var shippingMethod in shippingMethods){- var key = $"ShippingRateComputationMethod.FixedRate.Rate.ShippingMethodId{shippingMethodId}";- var rate = this._settingService.GetSettingByKey<FixedShippingRate>(key)?.Rate;- return rate ?? 0;+ var shippingOption = new ShippingOption {+ Name = shippingMethod.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),+ Description = shippingMethod.GetTranslation(x => x.Description, _workContext.WorkingLanguage.Id),+ Rate = await _currencyService.ConvertFromPrimaryStoreCurrency(GetRate(shippingMethod.Id),+ _workContext.WorkingCurrency)+ };+ response.ShippingOptions.Add(shippingOption);}- #endregion+ return response;+ }-- /// <summary>- /// Gets available shipping options- /// </summary>- /// <param name="getShippingOptionRequest">A request for getting shipping options</param>- /// <returns>Represents a response of getting shipping rate options</returns>- public async Task<GetShippingOptionResponse> GetShippingOptions(GetShippingOptionRequest getShippingOptionRequest)- {- ArgumentNullException.ThrowIfNull(getShippingOptionRequest);-- var response = new GetShippingOptionResponse();-- if (getShippingOptionRequest.Items == null || getShippingOptionRequest.Items.Count == 0)- {- response.AddError("No shipment items");- return response;- }-- var restrictByCountryId = getShippingOptionRequest.ShippingAddress != null && !string.IsNullOrEmpty(getShippingOptionRequest.ShippingAddress.CountryId) ? getShippingOptionRequest.ShippingAddress.CountryId : "";- var shippingMethods = await _shippingMethodService.GetAllShippingMethods(restrictByCountryId, getShippingOptionRequest.Customer);- foreach (var shippingMethod in shippingMethods)- {- var shippingOption = new ShippingOption- {- Name = shippingMethod.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),- Description = shippingMethod.GetTranslation(x => x.Description, _workContext.WorkingLanguage.Id),- Rate = await _currencyService.ConvertFromPrimaryStoreCurrency(GetRate(shippingMethod.Id), _workContext.WorkingCurrency)- };- response.ShippingOptions.Add(shippingOption);- }+ /// <summary>+ /// Gets fixed shipping rate (if Shipping rate method allows it and the rate can be calculated before checkout).+ /// </summary>+ /// <param name="getShippingOptionRequest">A request for getting shipping options</param>+ /// <returns>Fixed shipping rate; or null in case there's no fixed shipping rate</returns>+ public async Task<double?> GetFixedRate(GetShippingOptionRequest getShippingOptionRequest)+ {+ ArgumentNullException.ThrowIfNull(getShippingOptionRequest);- return response;- }+ var restrictByCountryId =+ getShippingOptionRequest.ShippingAddress != null &&+ !string.IsNullOrEmpty(getShippingOptionRequest.ShippingAddress.CountryId)+ ? getShippingOptionRequest.ShippingAddress.CountryId+ : "";+ var shippingMethods = await _shippingMethodService.GetAllShippingMethods(restrictByCountryId);- /// <summary>- /// Gets fixed shipping rate (if Shipping rate method allows it and the rate can be calculated before checkout).- /// </summary>- /// <param name="getShippingOptionRequest">A request for getting shipping options</param>- /// <returns>Fixed shipping rate; or null in case there's no fixed shipping rate</returns>- public async Task<double?> GetFixedRate(GetShippingOptionRequest getShippingOptionRequest)+ var rates = new List<double>();+ foreach (var shippingMethod in shippingMethods){- ArgumentNullException.ThrowIfNull(getShippingOptionRequest);+ var rate = GetRate(shippingMethod.Id);+ if (!rates.Contains(rate))+ rates.Add(rate);+ }- var restrictByCountryId = getShippingOptionRequest.ShippingAddress != null && !string.IsNullOrEmpty(getShippingOptionRequest.ShippingAddress.CountryId) ? getShippingOptionRequest.ShippingAddress.CountryId : "";- var shippingMethods = await _shippingMethodService.GetAllShippingMethods(restrictByCountryId);+ //return default rate if all of them equal+ if (rates.Count == 1)+ return rates[0];- var rates = new List<double>();- foreach (var shippingMethod in shippingMethods)- {- var rate = GetRate(shippingMethod.Id);- if (!rates.Contains(rate))- rates.Add(rate);- }+ return null;+ }- //return default rate if all of them equal- if (rates.Count == 1)- return rates[0];+ public ShippingRateCalculationType ShippingRateCalculationType => ShippingRateCalculationType.Off;- return null;- }+ public IShipmentTracker ShipmentTracker => null;- public ShippingRateCalculationType ShippingRateCalculationType => ShippingRateCalculationType.Off;+ public async Task<IList<string>> ValidateShippingForm(string shippingOption, IDictionary<string, string> data)+ {+ return await Task.FromResult(new List<string>());+ }- public IShipmentTracker ShipmentTracker => null;+ public async Task<string> GetControllerRouteName()+ {+ return await Task.FromResult("");+ }- public async Task<IList<string>> ValidateShippingForm(string shippingOption, IDictionary<string, string> data)- {- return await Task.FromResult(new List<string>());- }+ public async Task<bool> HideShipmentMethods(IList<ShoppingCartItem> cart)+ {+ return await Task.FromResult(false);+ }- public async Task<string> GetControllerRouteName()- {- return await Task.FromResult("");- }+ public string ConfigurationUrl => FixedRateShippingDefaults.ConfigurationUrl;+ public string SystemName => FixedRateShippingDefaults.ProviderSystemName;+ public string FriendlyName => _translationService.GetResource(FixedRateShippingDefaults.FriendlyName);+ public int Priority => _shippingFixedRateSettings.DisplayOrder;+ public IList<string> LimitedToStores => new List<string>();+ public IList<string> LimitedToGroups => new List<string>();- public async Task<bool> HideShipmentMethods(IList<ShoppingCartItem> cart)- {- return await Task.FromResult(false);- }- public string ConfigurationUrl => FixedRateShippingDefaults.ConfigurationUrl;- public string SystemName => FixedRateShippingDefaults.ProviderSystemName;- public string FriendlyName => _translationService.GetResource(FixedRateShippingDefaults.FriendlyName);- public int Priority => _shippingFixedRateSettings.DisplayOrder;- public IList<string> LimitedToStores => new List<string>();- public IList<string> LimitedToGroups => new List<string>();+ #region Utilities+ private double GetRate(string shippingMethodId)+ {+ var key = $"ShippingRateComputationMethod.FixedRate.Rate.ShippingMethodId{shippingMethodId}";+ var rate = _settingService.GetSettingByKey<FixedShippingRate>(key)?.Rate;+ return rate ?? 0;}-}++ #endregion+}\ No newline at end of filediff --git a/src/Plugins/Shipping.FixedRateShipping/Models/FixedShippingRate.cs b/src/Plugins/Shipping.FixedRateShipping/Models/FixedShippingRate.csindex 6a12ccadb..629474529 100644--- a/src/Plugins/Shipping.FixedRateShipping/Models/FixedShippingRate.cs+++ b/src/Plugins/Shipping.FixedRateShipping/Models/FixedShippingRate.cs@@ -1,7 +1,6 @@-namespace Shipping.FixedRateShipping.Models+namespace Shipping.FixedRateShipping.Models;++public class FixedShippingRate{- public class FixedShippingRate- {- public double Rate { get; set; }- }-}+ public double Rate { get; set; }+}\ No newline at end of filediff --git a/src/Plugins/Shipping.FixedRateShipping/Models/FixedShippingRateModel.cs b/src/Plugins/Shipping.FixedRateShipping/Models/FixedShippingRateModel.csindex 321e33cdb..5441bcef5 100644--- a/src/Plugins/Shipping.FixedRateShipping/Models/FixedShippingRateModel.cs+++ b/src/Plugins/Shipping.FixedRateShipping/Models/FixedShippingRateModel.cs@@ -1,15 +1,14 @@using Grand.Infrastructure.ModelBinding;-namespace Shipping.FixedRateShipping.Models+namespace Shipping.FixedRateShipping.Models;++public class FixedShippingRateModel{- public class FixedShippingRateModel- {- public string ShippingMethodId { get; set; }+ public string ShippingMethodId { get; set; }- [GrandResourceDisplayName("Plugins.Shipping.FixedRateShipping.Fields.ShippingMethodName")]- public string ShippingMethodName { get; set; }+ [GrandResourceDisplayName("Plugins.Shipping.FixedRateShipping.Fields.ShippingMethodName")]+ public string ShippingMethodName { get; set; }- [GrandResourceDisplayName("Plugins.Shipping.FixedRateShipping.Fields.Rate")]- public double Rate { get; set; }- }+ [GrandResourceDisplayName("Plugins.Shipping.FixedRateShipping.Fields.Rate")]+ public double Rate { get; set; }}\ No newline at end of filediff --git a/src/Plugins/Shipping.FixedRateShipping/ShippingFixedRateSettings.cs b/src/Plugins/Shipping.FixedRateShipping/ShippingFixedRateSettings.csindex 364da9b3c..8ed44818c 100644--- a/src/Plugins/Shipping.FixedRateShipping/ShippingFixedRateSettings.cs+++ b/src/Plugins/Shipping.FixedRateShipping/ShippingFixedRateSettings.cs@@ -1,10 +1,8 @@using Grand.Domain.Configuration;-namespace Shipping.FixedRateShipping-{- public class ShippingFixedRateSettings : ISettings- {- public int DisplayOrder { get; set; }+namespace Shipping.FixedRateShipping;- }-}+public class ShippingFixedRateSettings : ISettings+{+ public int DisplayOrder { get; set; }+}\ No newline at end of filediff --git a/src/Plugins/Shipping.FixedRateShipping/StartupApplication.cs b/src/Plugins/Shipping.FixedRateShipping/StartupApplication.csindex 8672760ae..2b9ff384c 100644--- a/src/Plugins/Shipping.FixedRateShipping/StartupApplication.cs+++ b/src/Plugins/Shipping.FixedRateShipping/StartupApplication.cs@@ -5,21 +5,20 @@ using Microsoft.AspNetCore.Hosting;using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;-namespace Shipping.FixedRateShipping+namespace Shipping.FixedRateShipping;++public class StartupApplication : IStartupApplication{- public class StartupApplication : IStartupApplication+ public void ConfigureServices(IServiceCollection services, IConfiguration configuration){- public void ConfigureServices(IServiceCollection services, IConfiguration configuration)- {- services.AddScoped<IShippingRateCalculationProvider, FixedRateShippingProvider>();- }-- public int Priority => 10;- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)- {+ services.AddScoped<IShippingRateCalculationProvider, FixedRateShippingProvider>();+ }- }- public bool BeforeConfigure => false;+ public int Priority => 10;+ public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)+ {}-}++ public bool BeforeConfigure => false;+}\ No newline at end of filediff --git a/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Controllers/ShippingPointController.cs b/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Controllers/ShippingPointController.csindex 2e047209b..c5be89072 100644--- a/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Controllers/ShippingPointController.cs+++ b/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Controllers/ShippingPointController.cs@@ -11,134 +11,133 @@ using Microsoft.AspNetCore.Mvc.Rendering;using Shipping.ShippingPoint.Models;using Shipping.ShippingPoint.Services;-namespace Shipping.ShippingPoint.Areas.Admin.Controllers+namespace Shipping.ShippingPoint.Areas.Admin.Controllers;++[AuthorizeAdmin]+[Area("Admin")]+[PermissionAuthorize(PermissionSystemName.ShippingSettings)]+public class ShippingPointController : BaseShippingController{- [AuthorizeAdmin]- [Area("Admin")]- [PermissionAuthorize(PermissionSystemName.ShippingSettings)]- public class ShippingPointController : BaseShippingController+ private readonly ICountryService _countryService;+ private readonly IShippingPointService _shippingPointService;+ private readonly IStoreService _storeService;+ private readonly ITranslationService _translationService;++ public ShippingPointController(+ ITranslationService translationService,+ IShippingPointService shippingPointService,+ ICountryService countryService,+ IStoreService storeService+ ){- private readonly ITranslationService _translationService;- private readonly IShippingPointService _shippingPointService;- private readonly ICountryService _countryService;- private readonly IStoreService _storeService;-- public ShippingPointController(- ITranslationService translationService,- IShippingPointService shippingPointService,- ICountryService countryService,- IStoreService storeService- )- {- _translationService = translationService;- _shippingPointService = shippingPointService;- _countryService = countryService;- _storeService = storeService;- }+ _translationService = translationService;+ _shippingPointService = shippingPointService;+ _countryService = countryService;+ _storeService = storeService;+ }- public IActionResult Configure()- {- return View();- }+ public IActionResult Configure()+ {+ return View();+ }- [HttpPost]- public async Task<IActionResult> List(DataSourceRequest command)- {- var shippingPoints = await _shippingPointService.GetAllStoreShippingPoint(storeId: "",- pageIndex: command.Page - 1, pageSize: command.PageSize);- var viewModel = new List<ShippingPointModel>();-- foreach (var shippingPoint in shippingPoints)- {- var storeName = await _storeService.GetStoreById(shippingPoint.StoreId);- viewModel.Add(new ShippingPointModel {- ShippingPointName = shippingPoint.ShippingPointName,- Description = shippingPoint.Description,- Id = shippingPoint.Id,- OpeningHours = shippingPoint.OpeningHours,- PickupFee = shippingPoint.PickupFee,- StoreName = storeName != null- ? storeName.Shortcut- : _translationService.GetResource("Admin.Settings.StoreScope.AllStores")- });- }-- return Json(new DataSourceResult {- Data = viewModel,- Total = shippingPoints.TotalCount- });- }+ [HttpPost]+ public async Task<IActionResult> List(DataSourceRequest command)+ {+ var shippingPoints = await _shippingPointService.GetAllStoreShippingPoint("",+ command.Page - 1, command.PageSize);+ var viewModel = new List<ShippingPointModel>();- private async Task PrepareShippingPointModel(ShippingPointModel model)+ foreach (var shippingPoint in shippingPoints){- model.AvailableCountries.Add(new SelectListItem- { Text = _translationService.GetResource("Admin.Address.SelectCountry"), Value = string.Empty });- foreach (var country in await _countryService.GetAllCountries(showHidden: true))- model.AvailableCountries.Add(new SelectListItem { Text = country.Name, Value = country.Id });- model.AvailableStores.Add(new SelectListItem {- Text = _translationService.GetResource("Admin.Settings.StoreScope.AllStores"), Value = string.Empty+ var storeName = await _storeService.GetStoreById(shippingPoint.StoreId);+ viewModel.Add(new ShippingPointModel {+ ShippingPointName = shippingPoint.ShippingPointName,+ Description = shippingPoint.Description,+ Id = shippingPoint.Id,+ OpeningHours = shippingPoint.OpeningHours,+ PickupFee = shippingPoint.PickupFee,+ StoreName = storeName != null+ ? storeName.Shortcut+ : _translationService.GetResource("Admin.Settings.StoreScope.AllStores")});- foreach (var store in await _storeService.GetAllStores())- model.AvailableStores.Add(new SelectListItem { Text = store.Shortcut, Value = store.Id });}- public async Task<IActionResult> Create()- {- var model = new ShippingPointModel();- await PrepareShippingPointModel(model);- return View(model);- }+ return Json(new DataSourceResult {+ Data = viewModel,+ Total = shippingPoints.TotalCount+ });+ }- [HttpPost]- public async Task<IActionResult> Create(ShippingPointModel model)- {- if (ModelState.IsValid)- {- var shippingPoint = model.ToEntity();- await _shippingPointService.InsertStoreShippingPoint(shippingPoint);+ private async Task PrepareShippingPointModel(ShippingPointModel model)+ {+ model.AvailableCountries.Add(new SelectListItem+ { Text = _translationService.GetResource("Admin.Address.SelectCountry"), Value = string.Empty });+ foreach (var country in await _countryService.GetAllCountries(showHidden: true))+ model.AvailableCountries.Add(new SelectListItem { Text = country.Name, Value = country.Id });+ model.AvailableStores.Add(new SelectListItem {+ Text = _translationService.GetResource("Admin.Settings.StoreScope.AllStores"), Value = string.Empty+ });+ foreach (var store in await _storeService.GetAllStores())+ model.AvailableStores.Add(new SelectListItem { Text = store.Shortcut, Value = store.Id });+ }- ViewBag.RefreshPage = true;- return Content("");- }+ public async Task<IActionResult> Create()+ {+ var model = new ShippingPointModel();+ await PrepareShippingPointModel(model);+ return View(model);+ }- await PrepareShippingPointModel(model);+ [HttpPost]+ public async Task<IActionResult> Create(ShippingPointModel model)+ {+ if (ModelState.IsValid)+ {+ var shippingPoint = model.ToEntity();+ await _shippingPointService.InsertStoreShippingPoint(shippingPoint);- return View(model);+ ViewBag.RefreshPage = true;+ return Content("");}- public async Task<IActionResult> Edit(string id)- {- var shippingPoints = await _shippingPointService.GetStoreShippingPointById(id);- var model = shippingPoints.ToModel();- await PrepareShippingPointModel(model);- return View(model);- }+ await PrepareShippingPointModel(model);++ return View(model);+ }- [HttpPost]- public async Task<IActionResult> Edit(ShippingPointModel model)+ public async Task<IActionResult> Edit(string id)+ {+ var shippingPoints = await _shippingPointService.GetStoreShippingPointById(id);+ var model = shippingPoints.ToModel();+ await PrepareShippingPointModel(model);+ return View(model);+ }++ [HttpPost]+ public async Task<IActionResult> Edit(ShippingPointModel model)+ {+ if (ModelState.IsValid){- if (ModelState.IsValid)- {- var shippingPoint = model.ToEntity();- await _shippingPointService.UpdateStoreShippingPoint(shippingPoint);+ var shippingPoint = model.ToEntity();+ await _shippingPointService.UpdateStoreShippingPoint(shippingPoint);- return Content("");- }+ return Content("");+ }- ViewBag.RefreshPage = true;+ ViewBag.RefreshPage = true;- await PrepareShippingPointModel(model);+ await PrepareShippingPointModel(model);- return View(model);- }+ return View(model);+ }- [HttpPost]- public async Task<IActionResult> Delete(string id)- {- var model = await _shippingPointService.GetStoreShippingPointById(id);- await _shippingPointService.DeleteStoreShippingPoint(model);+ [HttpPost]+ public async Task<IActionResult> Delete(string id)+ {+ var model = await _shippingPointService.GetStoreShippingPointById(id);+ await _shippingPointService.DeleteStoreShippingPoint(model);- return new JsonResult("");- }+ return new JsonResult("");}}\ No newline at end of filediff --git a/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Views/ShippingPoint/Configure.cshtml b/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Views/ShippingPoint/Configure.cshtmlindex c340d91aa..1f279b129 100644--- a/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Views/ShippingPoint/Configure.cshtml+++ b/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Views/ShippingPoint/Configure.cshtml@@ -1,8 +1,7 @@@{Layout = "_ConfigurePlugin";-}-<input id="active-menu-item" type="hidden" value="/Admin/Shipping/Providers" />+<input id="active-menu-item" type="hidden" value="/Admin/Shipping/Providers"/><form asp-controller="ShippingPoint" asp-action="Configure" method="post" id="shipping-instore-form"><div class="panel-group"><div class="panel panel-default">@@ -121,7 +120,7 @@<a id="btnAddNewOption" class="btn btn-primary" href="@(Url.Action("Create", "ShippingPoint") + "?btnId=btnRefresh&formId=shipping-instore-form")">@Loc["Admin.Common.AddNew"]</a>- <input type="submit" id="btnRefresh" class="btn btn-default" style="display: none" />+ <input type="submit" id="btnRefresh" class="btn btn-default" style="display: none"/></div><script>diff --git a/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Views/ShippingPoint/Create.cshtml b/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Views/ShippingPoint/Create.cshtmlindex 715e348e4..f91d1340b 100644--- a/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Views/ShippingPoint/Create.cshtml+++ b/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Views/ShippingPoint/Create.cshtml@@ -17,7 +17,9 @@</div><div class="actions"><div class="btn-group btn-group-devided">- <button class="btn btn-success" type="submit" name="save"><i class="fa fa-check"></i> @Loc["Admin.Common.Save"] </button>+ <button class="btn btn-success" type="submit" name="save">+ <i class="fa fa-check"></i> @Loc["Admin.Common.Save"]+ </button></div></div></div>@@ -26,7 +28,7 @@</div><div class="content"><div class="form-horizontal">- <partial name="_CreateOrUpdate" model="Model" />+ <partial name="_CreateOrUpdate" model="Model"/></div></div><script>diff --git a/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Views/ShippingPoint/Edit.cshtml b/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Views/ShippingPoint/Edit.cshtmlindex ddb335bf6..d49be067c 100644--- a/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Views/ShippingPoint/Edit.cshtml+++ b/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Views/ShippingPoint/Edit.cshtml@@ -17,7 +17,9 @@</div><div class="actions"><div class="btn-group btn-group-devided">- <button class="btn btn-success" type="submit" name="save"><i class="fa fa-check"></i> @Loc["Admin.Common.Save"] </button>+ <button class="btn btn-success" type="submit" name="save">+ <i class="fa fa-check"></i> @Loc["Admin.Common.Save"]+ </button></div></div></div>@@ -26,7 +28,7 @@</div><div class="content"><div class="form-horizontal">- <partial name="_CreateOrUpdate" model="Model" />+ <partial name="_CreateOrUpdate" model="Model"/></div></div><script>diff --git a/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Views/ShippingPoint/_CreateOrUpdate.cshtml b/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Views/ShippingPoint/_CreateOrUpdate.cshtmlindex ed18d0795..3f3d28550 100644--- a/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Views/ShippingPoint/_CreateOrUpdate.cshtml+++ b/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Views/ShippingPoint/_CreateOrUpdate.cshtml@@ -1,7 +1,7 @@@model Shipping.ShippingPoint.Models.ShippingPointModel<div asp-validation-summary="All"></div>-<input asp-for="Id" type="hidden" />+<input asp-for="Id" type="hidden"/>@if (ViewBag.RefreshPage == true){@@ -15,65 +15,65 @@<div class="form-horizontal"><div class="form-body"><div class="form-group">- <admin-label asp-for="ShippingPointName" />+ <admin-label asp-for="ShippingPointName"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="ShippingPointName" />+ <admin-input asp-for="ShippingPointName"/><span asp-validation-for="ShippingPointName"></span></div></div><div class="form-group">- <admin-label asp-for="Description" />+ <admin-label asp-for="Description"/><div class="col-md-9 col-sm-9"><admin-textarea asp-for="Description"></admin-textarea><span asp-validation-for="Description"></span></div></div><div class="form-group">- <admin-label asp-for="CountryId" />+ <admin-label asp-for="CountryId"/><div class="col-md-9 col-sm-9">- <admin-select asp-for="CountryId" asp-items="Model.AvailableCountries" />+ <admin-select asp-for="CountryId" asp-items="Model.AvailableCountries"/><span asp-validation-for="CountryId"></span></div></div><div class="form-group">- <admin-label asp-for="City" />+ <admin-label asp-for="City"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="City" />+ <admin-input asp-for="City"/><span asp-validation-for="City"></span></div></div><div class="form-group">- <admin-label asp-for="Address1" />+ <admin-label asp-for="Address1"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="Address1" />+ <admin-input asp-for="Address1"/><span asp-validation-for="Address1"></span></div></div><div class="form-group">- <admin-label asp-for="ZipPostalCode" />+ <admin-label asp-for="ZipPostalCode"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="ZipPostalCode" />+ <admin-input asp-for="ZipPostalCode"/><span asp-validation-for="ZipPostalCode"></span></div></div><div class="form-group">- <admin-label asp-for="OpeningHours" />+ <admin-label asp-for="OpeningHours"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="OpeningHours" />+ <admin-input asp-for="OpeningHours"/><span asp-validation-for="OpeningHours"></span></div></div><div class="form-group">- <admin-label asp-for="PickupFee" />+ <admin-label asp-for="PickupFee"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="PickupFee" />+ <admin-input asp-for="PickupFee"/><span asp-validation-for="PickupFee"></span></div></div><div class="form-group">- <admin-label asp-for="StoreId" />+ <admin-label asp-for="StoreId"/><div class="col-md-9 col-sm-9">- <admin-select asp-for="StoreId" asp-items="Model.AvailableStores" />+ <admin-select asp-for="StoreId" asp-items="Model.AvailableStores"/><span asp-validation-for="StoreId"></span></div></div>diff --git a/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Views/_ViewImports.cshtml b/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Views/_ViewImports.cshtmlindex 20cb126bd..0d1dc3574 100644--- a/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Views/_ViewImports.cshtml+++ b/src/Plugins/Shipping.ShippingPoint/Areas/Admin/Views/_ViewImports.cshtml@@ -4,5 +4,6 @@@using Microsoft.AspNetCore.Mvc.ViewFeatures@using Grand.Infrastructure.Extensions-@using Grand.Web.Common-@inject Grand.Web.Common.Localization.LocService Loc+@using Grand.Web.Common+@using Grand.Web.Common.Localization+@inject LocService Loc\ No newline at end of filediff --git a/src/Plugins/Shipping.ShippingPoint/Controllers/SelectedShippingPointController.cs b/src/Plugins/Shipping.ShippingPoint/Controllers/SelectedShippingPointController.csindex 94d8f3dcd..a4d6138fe 100644--- a/src/Plugins/Shipping.ShippingPoint/Controllers/SelectedShippingPointController.cs+++ b/src/Plugins/Shipping.ShippingPoint/Controllers/SelectedShippingPointController.cs@@ -7,67 +7,69 @@ using Microsoft.AspNetCore.Mvc.Rendering;using Shipping.ShippingPoint.Models;using Shipping.ShippingPoint.Services;-namespace Shipping.ShippingPoint.Controllers+namespace Shipping.ShippingPoint.Controllers;++public class SelectedShippingPointController : Controller{- public class SelectedShippingPointController : Controller- {- private readonly IShippingPointService _shippingPointService;- private readonly ICountryService _countryService;- private readonly IPriceFormatter _priceFormatter;- private readonly IWorkContext _workContext;- private readonly ICurrencyService _currencyService;- private readonly ITranslationService _translationService;+ private readonly ICountryService _countryService;+ private readonly ICurrencyService _currencyService;+ private readonly IPriceFormatter _priceFormatter;+ private readonly IShippingPointService _shippingPointService;+ private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;- public SelectedShippingPointController(- IShippingPointService shippingPointService,- ICountryService countryService,- IPriceFormatter priceFormatter,- IWorkContext workContext,- ICurrencyService currencyService,- ITranslationService translationService)- {- _shippingPointService = shippingPointService;- _countryService = countryService;- _priceFormatter = priceFormatter;- _workContext = workContext;- _currencyService = currencyService;- _translationService = translationService;- }- public async Task<IActionResult> Get(string shippingOptionId)- {- var shippingPoint = await _shippingPointService.GetStoreShippingPointById(shippingOptionId);- if (shippingPoint == null) return Content("ShippingPointController: given Shipping Option doesn't exist");- var rateBase = await _currencyService.ConvertFromPrimaryStoreCurrency(shippingPoint.PickupFee, _workContext.WorkingCurrency);- var fee = _priceFormatter.FormatPrice(rateBase, _workContext.WorkingCurrency);+ public SelectedShippingPointController(+ IShippingPointService shippingPointService,+ ICountryService countryService,+ IPriceFormatter priceFormatter,+ IWorkContext workContext,+ ICurrencyService currencyService,+ ITranslationService translationService)+ {+ _shippingPointService = shippingPointService;+ _countryService = countryService;+ _priceFormatter = priceFormatter;+ _workContext = workContext;+ _currencyService = currencyService;+ _translationService = translationService;+ }- var viewModel = new PointModel {- ShippingPointName = shippingPoint.ShippingPointName,- Description = shippingPoint.Description,- PickupFee = fee,- OpeningHours = shippingPoint.OpeningHours,- Address1 = shippingPoint.Address1,- City = shippingPoint.City,- CountryName = (await _countryService.GetCountryById(shippingPoint.CountryId))?.Name,- ZipPostalCode = shippingPoint.ZipPostalCode- };- return View(viewModel);- }+ public async Task<IActionResult> Get(string shippingOptionId)+ {+ var shippingPoint = await _shippingPointService.GetStoreShippingPointById(shippingOptionId);+ if (shippingPoint == null) return Content("ShippingPointController: given Shipping Option doesn't exist");+ var rateBase =+ await _currencyService.ConvertFromPrimaryStoreCurrency(shippingPoint.PickupFee,+ _workContext.WorkingCurrency);+ var fee = _priceFormatter.FormatPrice(rateBase, _workContext.WorkingCurrency);- public async Task<IActionResult> Points(string shippingOption)- {- var parameter = shippingOption.Split([":"], StringSplitOptions.RemoveEmptyEntries)[0];+ var viewModel = new PointModel {+ ShippingPointName = shippingPoint.ShippingPointName,+ Description = shippingPoint.Description,+ PickupFee = fee,+ OpeningHours = shippingPoint.OpeningHours,+ Address1 = shippingPoint.Address1,+ City = shippingPoint.City,+ CountryName = (await _countryService.GetCountryById(shippingPoint.CountryId))?.Name,+ ZipPostalCode = shippingPoint.ZipPostalCode+ };+ return View(viewModel);+ }- if (parameter != _translationService.GetResource("Shipping.ShippingPoint.PluginName"))- return Content("ShippingPointController: given Shipping Option doesn't exist");- var shippingPoints = await _shippingPointService.GetAllStoreShippingPoint(_workContext.CurrentStore.Id);+ public async Task<IActionResult> Points(string shippingOption)+ {+ var parameter = shippingOption.Split([":"], StringSplitOptions.RemoveEmptyEntries)[0];- var shippingPointsModel = new List<SelectListItem> {- new() { Value = "", Text = _translationService.GetResource("Shipping.ShippingPoint.SelectShippingOption") }- };- shippingPointsModel.AddRange(shippingPoints.Select(shippingPoint => new SelectListItem { Value = shippingPoint.Id, Text = shippingPoint.ShippingPointName }));+ if (parameter != _translationService.GetResource("Shipping.ShippingPoint.PluginName"))+ return Content("ShippingPointController: given Shipping Option doesn't exist");+ var shippingPoints = await _shippingPointService.GetAllStoreShippingPoint(_workContext.CurrentStore.Id);- return View(shippingPointsModel);+ var shippingPointsModel = new List<SelectListItem> {+ new() { Value = "", Text = _translationService.GetResource("Shipping.ShippingPoint.SelectShippingOption") }+ };+ shippingPointsModel.AddRange(shippingPoints.Select(shippingPoint => new SelectListItem+ { Value = shippingPoint.Id, Text = shippingPoint.ShippingPointName }));- }+ return View(shippingPointsModel);}-}+}\ No newline at end of filediff --git a/src/Plugins/Shipping.ShippingPoint/Domain/ShippingPointSerialization.cs b/src/Plugins/Shipping.ShippingPoint/Domain/ShippingPointSerialization.csindex a1b17d6e4..b32d6d03b 100644--- a/src/Plugins/Shipping.ShippingPoint/Domain/ShippingPointSerialization.cs+++ b/src/Plugins/Shipping.ShippingPoint/Domain/ShippingPointSerialization.cs@@ -1,16 +1,15 @@-namespace Shipping.ShippingPoint.Domain+namespace Shipping.ShippingPoint.Domain;++public class ShippingPointSerializable{- public class ShippingPointSerializable- {- public string Id { get; set; }- public string ShippingPointName { get; set; }- public string Description { get; set; }- public string Country { get; set; }- public string City { get; set; }- public string Address1 { get; set; }- public string ZipPostalCode { get; set; }- public double PickupFee { get; set; }- public string OpeningHours { get; set; }- public string StoreId { get; set; }- }+ public string Id { get; set; }+ public string ShippingPointName { get; set; }+ public string Description { get; set; }+ public string Country { get; set; }+ public string City { get; set; }+ public string Address1 { get; set; }+ public string ZipPostalCode { get; set; }+ public double PickupFee { get; set; }+ public string OpeningHours { get; set; }+ public string StoreId { get; set; }}\ No newline at end of filediff --git a/src/Plugins/Shipping.ShippingPoint/Domain/ShippingPoints.cs b/src/Plugins/Shipping.ShippingPoint/Domain/ShippingPoints.csindex ff3894278..779a22aa2 100644--- a/src/Plugins/Shipping.ShippingPoint/Domain/ShippingPoints.cs+++ b/src/Plugins/Shipping.ShippingPoint/Domain/ShippingPoints.cs@@ -1,52 +1,51 @@using Grand.Domain;-namespace Shipping.ShippingPoint.Domain+namespace Shipping.ShippingPoint.Domain;++public class ShippingPoints : BaseEntity{- public class ShippingPoints : BaseEntity- {- /// <summary>- /// Gets or sets a name- /// </summary>- public string ShippingPointName { get; set; }-- /// <summary>- /// Gets or sets a description- /// </summary>- public string Description { get; set; }-- /// <summary>- /// Gets or sets a City- /// </summary>- public string City { get; set; }-- /// <summary>- /// Gets or sets Address1- /// </summary>- public string Address1 { get; set; }-- /// <summary>- /// Gets or sets Zip postal code- /// </summary>- public string ZipPostalCode { get; set; }-- /// <summary>- /// Gets or sets CountryId- /// </summary>- public string CountryId { get; set; }-- /// <summary>- /// Gets or sets a fee for the pickup- /// </summary>- public double PickupFee { get; set; }-- /// <summary>- /// Gets or sets an opening hours- /// </summary>- public string OpeningHours { get; set; }-- /// <summary>- /// Gets or sets a store identifier- /// </summary>- public string StoreId { get; set; }- }+ /// <summary>+ /// Gets or sets a name+ /// </summary>+ public string ShippingPointName { get; set; }++ /// <summary>+ /// Gets or sets a description+ /// </summary>+ public string Description { get; set; }++ /// <summary>+ /// Gets or sets a City+ /// </summary>+ public string City { get; set; }++ /// <summary>+ /// Gets or sets Address1+ /// </summary>+ public string Address1 { get; set; }++ /// <summary>+ /// Gets or sets Zip postal code+ /// </summary>+ public string ZipPostalCode { get; set; }++ /// <summary>+ /// Gets or sets CountryId+ /// </summary>+ public string CountryId { get; set; }++ /// <summary>+ /// Gets or sets a fee for the pickup+ /// </summary>+ public double PickupFee { get; set; }++ /// <summary>+ /// Gets or sets an opening hours+ /// </summary>+ public string OpeningHours { get; set; }++ /// <summary>+ /// Gets or sets a store identifier+ /// </summary>+ public string StoreId { get; set; }}\ No newline at end of filediff --git a/src/Plugins/Shipping.ShippingPoint/EndpointProvider.cs b/src/Plugins/Shipping.ShippingPoint/EndpointProvider.csindex d4538a4e4..cb1cc549c 100644--- a/src/Plugins/Shipping.ShippingPoint/EndpointProvider.cs+++ b/src/Plugins/Shipping.ShippingPoint/EndpointProvider.cs@@ -2,18 +2,17 @@using Microsoft.AspNetCore.Builder;using Microsoft.AspNetCore.Routing;-namespace Shipping.ShippingPoint+namespace Shipping.ShippingPoint;++public class EndpointProvider : IEndpointProvider{- public class EndpointProvider : IEndpointProvider+ public void RegisterEndpoint(IEndpointRouteBuilder endpointRouteBuilder){- public void RegisterEndpoint(IEndpointRouteBuilder endpointRouteBuilder)- {- endpointRouteBuilder.MapControllerRoute("Plugins.ShippingPoint.Points",- "Plugins/SelectedShippingPoint/Points",- new { controller = "SelectedShippingPoint", action = "Points" }- );- }- public int Priority => 0;-+ endpointRouteBuilder.MapControllerRoute("Plugins.ShippingPoint.Points",+ "Plugins/SelectedShippingPoint/Points",+ new { controller = "SelectedShippingPoint", action = "Points" }+ );}-}++ public int Priority => 0;+}\ No newline at end of filediff --git a/src/Plugins/Shipping.ShippingPoint/MapperConfiguration.cs b/src/Plugins/Shipping.ShippingPoint/MapperConfiguration.csindex 4a549e95f..bb454edf8 100644--- a/src/Plugins/Shipping.ShippingPoint/MapperConfiguration.cs+++ b/src/Plugins/Shipping.ShippingPoint/MapperConfiguration.cs@@ -3,21 +3,20 @@ using Grand.Infrastructure.Mapper;using Shipping.ShippingPoint.Domain;using Shipping.ShippingPoint.Models;-namespace Shipping.ShippingPoint+namespace Shipping.ShippingPoint;++public class MapperConfiguration : Profile, IAutoMapperProfile{- public class MapperConfiguration : Profile, IAutoMapperProfile+ public MapperConfiguration(){- public int Order => 0;-- public MapperConfiguration()- {- CreateMap<ShippingPoints, ShippingPointModel>()+ CreateMap<ShippingPoints, ShippingPointModel>().ForMember(dest => dest.AvailableStores, mo => mo.Ignore()).ForMember(dest => dest.StoreName, mo => mo.Ignore()).ForMember(dest => dest.AvailableCountries, mo => mo.Ignore()).ForMember(dest => dest.UserFields, mo => mo.Ignore());- CreateMap<ShippingPointModel, ShippingPoints>();- }+ CreateMap<ShippingPointModel, ShippingPoints>();}-}++ public int Order => 0;+}\ No newline at end of filediff --git a/src/Plugins/Shipping.ShippingPoint/MappingExtensions.cs b/src/Plugins/Shipping.ShippingPoint/MappingExtensions.csindex c70717437..62a9a1705 100644--- a/src/Plugins/Shipping.ShippingPoint/MappingExtensions.cs+++ b/src/Plugins/Shipping.ShippingPoint/MappingExtensions.cs@@ -2,18 +2,17 @@using Shipping.ShippingPoint.Domain;using Shipping.ShippingPoint.Models;-namespace Shipping.ShippingPoint+namespace Shipping.ShippingPoint;++public static class MappingExtensions{- public static class MappingExtensions+ public static ShippingPointModel ToModel(this ShippingPoints entity){- public static ShippingPointModel ToModel(this ShippingPoints entity)- {- return entity.MapTo<ShippingPoints, ShippingPointModel>();- }+ return entity.MapTo<ShippingPoints, ShippingPointModel>();+ }- public static ShippingPoints ToEntity(this ShippingPointModel model)- {- return model.MapTo<ShippingPointModel, ShippingPoints>();- }+ public static ShippingPoints ToEntity(this ShippingPointModel model)+ {+ return model.MapTo<ShippingPointModel, ShippingPoints>();}-}+}\ No newline at end of filediff --git a/src/Plugins/Shipping.ShippingPoint/Models/PointModel.cs b/src/Plugins/Shipping.ShippingPoint/Models/PointModel.csindex d86811d97..6e3408049 100644--- a/src/Plugins/Shipping.ShippingPoint/Models/PointModel.cs+++ b/src/Plugins/Shipping.ShippingPoint/Models/PointModel.cs@@ -1,17 +1,15 @@using Grand.Infrastructure.Models;-namespace Shipping.ShippingPoint.Models-{- public class PointModel : BaseEntityModel- {- public string ShippingPointName { get; set; }- public string Description { get; set; }- public string OpeningHours { get; set; }- public string PickupFee { get; set; }- public string City { get; set; }- public string Address1 { get; set; }- public string ZipPostalCode { get; set; }- public string CountryName { get; set; }- }+namespace Shipping.ShippingPoint.Models;+public class PointModel : BaseEntityModel+{+ public string ShippingPointName { get; set; }+ public string Description { get; set; }+ public string OpeningHours { get; set; }+ public string PickupFee { get; set; }+ public string City { get; set; }+ public string Address1 { get; set; }+ public string ZipPostalCode { get; set; }+ public string CountryName { get; set; }}\ No newline at end of filediff --git a/src/Plugins/Shipping.ShippingPoint/Models/ShippingPointModel.cs b/src/Plugins/Shipping.ShippingPoint/Models/ShippingPointModel.csindex 5de59783b..54a1b3c88 100644--- a/src/Plugins/Shipping.ShippingPoint/Models/ShippingPointModel.cs+++ b/src/Plugins/Shipping.ShippingPoint/Models/ShippingPointModel.cs@@ -2,43 +2,40 @@using Grand.Infrastructure.Models;using Microsoft.AspNetCore.Mvc.Rendering;-namespace Shipping.ShippingPoint.Models-{- public class ShippingPointModel : BaseEntityModel- {- [GrandResourceDisplayName("Shipping.ShippingPoint.Fields.ShippingPointName")]- public string ShippingPointName { get; set; }-- [GrandResourceDisplayName("Shipping.ShippingPoint.Fields.Description")]- public string Description { get; set; }+namespace Shipping.ShippingPoint.Models;- [GrandResourceDisplayName("Shipping.ShippingPoint.Fields.OpeningHours")]- public string OpeningHours { get; set; }+public class ShippingPointModel : BaseEntityModel+{+ [GrandResourceDisplayName("Shipping.ShippingPoint.Fields.ShippingPointName")]+ public string ShippingPointName { get; set; }- [GrandResourceDisplayName("Shipping.ShippingPoint.Fields.PickupFee")]- public double PickupFee { get; set; }+ [GrandResourceDisplayName("Shipping.ShippingPoint.Fields.Description")]+ public string Description { get; set; }- public List<SelectListItem> AvailableStores { get; set; } = new();+ [GrandResourceDisplayName("Shipping.ShippingPoint.Fields.OpeningHours")]+ public string OpeningHours { get; set; }- [GrandResourceDisplayName("Shipping.ShippingPoint.Fields.Store")]- public string StoreId { get; set; }+ [GrandResourceDisplayName("Shipping.ShippingPoint.Fields.PickupFee")]+ public double PickupFee { get; set; }- public string StoreName { get; set; }+ public List<SelectListItem> AvailableStores { get; set; } = new();- [GrandResourceDisplayName("Shipping.ShippingPoint.Fields.City")]- public string City { get; set; }+ [GrandResourceDisplayName("Shipping.ShippingPoint.Fields.Store")]+ public string StoreId { get; set; }- [GrandResourceDisplayName("Shipping.ShippingPoint.Fields.Address1")]- public string Address1 { get; set; }+ public string StoreName { get; set; }- [GrandResourceDisplayName("Shipping.ShippingPoint.Fields.ZipPostalCode")]- public string ZipPostalCode { get; set; }+ [GrandResourceDisplayName("Shipping.ShippingPoint.Fields.City")]+ public string City { get; set; }- [GrandResourceDisplayName("Shipping.ShippingPoint.Fields.Country")]- public string CountryId { get; set; }+ [GrandResourceDisplayName("Shipping.ShippingPoint.Fields.Address1")]+ public string Address1 { get; set; }- public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();- }+ [GrandResourceDisplayName("Shipping.ShippingPoint.Fields.ZipPostalCode")]+ public string ZipPostalCode { get; set; }+ [GrandResourceDisplayName("Shipping.ShippingPoint.Fields.Country")]+ public string CountryId { get; set; }+ public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();}\ No newline at end of filediff --git a/src/Plugins/Shipping.ShippingPoint/Services/IShippingPointService.cs b/src/Plugins/Shipping.ShippingPoint/Services/IShippingPointService.csindex b3592429b..5f1e2f5f8 100644--- a/src/Plugins/Shipping.ShippingPoint/Services/IShippingPointService.cs+++ b/src/Plugins/Shipping.ShippingPoint/Services/IShippingPointService.cs@@ -1,45 +1,45 @@using Grand.Domain;using Shipping.ShippingPoint.Domain;-namespace Shipping.ShippingPoint.Services+namespace Shipping.ShippingPoint.Services;++/// <summary>+/// Store pickup point service interface+/// </summary>+public interface IShippingPointService{/// <summary>- /// Store pickup point service interface+ /// Gets all pickup points/// </summary>- public interface IShippingPointService- {- /// <summary>- /// Gets all pickup points- /// </summary>- /// <param name="storeId">The store identifier; pass "" to load all records</param>- /// <param name="pageIndex">Page index</param>- /// <param name="pageSize">Page size</param>- /// <returns>Pickup points</returns>- Task<IPagedList<ShippingPoints>> GetAllStoreShippingPoint(string storeId = "", int pageIndex = 0, int pageSize = int.MaxValue);+ /// <param name="storeId">The store identifier; pass "" to load all records</param>+ /// <param name="pageIndex">Page index</param>+ /// <param name="pageSize">Page size</param>+ /// <returns>Pickup points</returns>+ Task<IPagedList<ShippingPoints>> GetAllStoreShippingPoint(string storeId = "", int pageIndex = 0,+ int pageSize = int.MaxValue);- /// <summary>- /// Gets a pickup point- /// </summary>- /// <param name="shippingPointId">Pickup point identifier</param>- /// <returns>Pickup point</returns>- Task<ShippingPoints> GetStoreShippingPointById(string shippingPointId);+ /// <summary>+ /// Gets a pickup point+ /// </summary>+ /// <param name="shippingPointId">Pickup point identifier</param>+ /// <returns>Pickup point</returns>+ Task<ShippingPoints> GetStoreShippingPointById(string shippingPointId);- /// <summary>- /// Inserts a pickup point- /// </summary>- /// <param name="shippingPoint">Pickup point</param>- Task InsertStoreShippingPoint(ShippingPoints shippingPoint);+ /// <summary>+ /// Inserts a pickup point+ /// </summary>+ /// <param name="shippingPoint">Pickup point</param>+ Task InsertStoreShippingPoint(ShippingPoints shippingPoint);- /// <summary>- /// Updates a pickup point- /// </summary>- /// <param name="shippingPoint">Pickup point</param>- Task UpdateStoreShippingPoint(ShippingPoints shippingPoint);+ /// <summary>+ /// Updates a pickup point+ /// </summary>+ /// <param name="shippingPoint">Pickup point</param>+ Task UpdateStoreShippingPoint(ShippingPoints shippingPoint);- /// <summary>- /// Deletes a pickup point- /// </summary>- /// <param name="shippingPoint">Pickup point</param>- Task DeleteStoreShippingPoint(ShippingPoints shippingPoint);- }-}+ /// <summary>+ /// Deletes a pickup point+ /// </summary>+ /// <param name="shippingPoint">Pickup point</param>+ Task DeleteStoreShippingPoint(ShippingPoints shippingPoint);+}\ No newline at end of filediff --git a/src/Plugins/Shipping.ShippingPoint/Services/ShippingPointService.cs b/src/Plugins/Shipping.ShippingPoint/Services/ShippingPointService.csindex e152ac84f..703f4d78e 100644--- a/src/Plugins/Shipping.ShippingPoint/Services/ShippingPointService.cs+++ b/src/Plugins/Shipping.ShippingPoint/Services/ShippingPointService.cs@@ -1,119 +1,119 @@-using Grand.Domain;-using Grand.Data;+using Grand.Data;+using Grand.Domain;using Grand.Infrastructure.Caching;using Shipping.ShippingPoint.Domain;-namespace Shipping.ShippingPoint.Services+namespace Shipping.ShippingPoint.Services;++public class ShippingPointService : IShippingPointService{- public class ShippingPointService : IShippingPointService+ #region Constants++ private const string PICKUP_POINT_PATTERN_KEY = "Grand.ShippingPoint.";++ #endregion++ #region Ctor++ /// <summary>+ /// Ctor+ /// </summary>+ /// <param name="cacheBase">Cache base</param>+ /// <param name="ShippingPointRepository">Store pickup point repository</param>+ public ShippingPointService(ICacheBase cacheBase,+ IRepository<ShippingPoints> ShippingPointRepository)+ {+ _cacheBase = cacheBase;+ _shippingPointRepository = ShippingPointRepository;+ }++ #endregion++ #region Fields++ private readonly ICacheBase _cacheBase;+ private readonly IRepository<ShippingPoints> _shippingPointRepository;++ #endregion++ #region Methods++ /// <summary>+ /// Gets all pickup points+ /// </summary>+ /// <param name="storeId">The store identifier; pass "" to load all records</param>+ /// <param name="pageIndex">Page index</param>+ /// <param name="pageSize">Page size</param>+ /// <returns>Pickup points</returns>+ public virtual async Task<IPagedList<ShippingPoints>> GetAllStoreShippingPoint(string storeId = "",+ int pageIndex = 0, int pageSize = int.MaxValue)+ {+ var query = from gp in _shippingPointRepository.Table+ where gp.StoreId == storeId || string.IsNullOrEmpty(gp.StoreId) || storeId == ""+ select gp;++ var records = query.ToList();++ //paging+ return await Task.FromResult(new PagedList<ShippingPoints>(records, pageIndex, pageSize));+ }++ /// <summary>+ /// </summary>+ /// <param name="pointName"></param>+ /// <returns></returns>+ public virtual Task<ShippingPoints> GetStoreShippingPointByPointName(string pointName){- #region Constants-- private const string PICKUP_POINT_PATTERN_KEY = "Grand.ShippingPoint.";-- #endregion-- #region Fields-- private readonly ICacheBase _cacheBase;- private readonly IRepository<ShippingPoints> _shippingPointRepository;-- #endregion-- #region Ctor-- /// <summary>- /// Ctor- /// </summary>- /// <param name="cacheBase">Cache base</param>- /// <param name="ShippingPointRepository">Store pickup point repository</param>- public ShippingPointService(ICacheBase cacheBase,- IRepository<ShippingPoints> ShippingPointRepository)- {- _cacheBase = cacheBase;- _shippingPointRepository = ShippingPointRepository;- }-- #endregion-- #region Methods-- /// <summary>- /// Gets all pickup points- /// </summary>- /// <param name="storeId">The store identifier; pass "" to load all records</param>- /// <param name="pageIndex">Page index</param>- /// <param name="pageSize">Page size</param>- /// <returns>Pickup points</returns>- public virtual async Task<IPagedList<ShippingPoints>> GetAllStoreShippingPoint(string storeId = "", int pageIndex = 0, int pageSize = int.MaxValue)- {- var query = from gp in _shippingPointRepository.Table- where gp.StoreId == storeId || string.IsNullOrEmpty(gp.StoreId) || storeId == ""- select gp;-- var records = query.ToList();-- //paging- return await Task.FromResult(new PagedList<ShippingPoints>(records, pageIndex, pageSize));- }-- /// <summary>- ///- /// </summary>- /// <param name="pointName"></param>- /// <returns></returns>- public virtual Task<ShippingPoints> GetStoreShippingPointByPointName(string pointName)- {- return Task.FromResult((from shippingPoint in _shippingPointRepository.Table- where shippingPoint.ShippingPointName == pointName- select shippingPoint).FirstOrDefault());- }-- /// <summary>- /// Gets a pickup point- /// </summary>- /// <param name="pickupPointId">Pickup point identifier</param>- /// <returns>Pickup point</returns>- public virtual Task<ShippingPoints> GetStoreShippingPointById(string pickupPointId)- {- return _shippingPointRepository.GetByIdAsync(pickupPointId);- }-- /// <summary>- /// Inserts a pickup point- /// </summary>- /// <param name="pickupPoint">Pickup point</param>- public virtual async Task InsertStoreShippingPoint(ShippingPoints pickupPoint)- {- ArgumentNullException.ThrowIfNull(pickupPoint);-- await _shippingPointRepository.InsertAsync(pickupPoint);- await _cacheBase.RemoveByPrefix(PICKUP_POINT_PATTERN_KEY);- }-- /// <summary>- /// Updates the pickup point- /// </summary>- /// <param name="pickupPoint">Pickup point</param>- public virtual async Task UpdateStoreShippingPoint(ShippingPoints pickupPoint)- {- ArgumentNullException.ThrowIfNull(pickupPoint);-- await _shippingPointRepository.UpdateAsync(pickupPoint);- await _cacheBase.RemoveByPrefix(PICKUP_POINT_PATTERN_KEY);- }-- /// <summary>- /// Deletes a pickup point- /// </summary>- /// <param name="pickupPoint">Pickup point</param>- public virtual async Task DeleteStoreShippingPoint(ShippingPoints pickupPoint)- {- ArgumentNullException.ThrowIfNull(pickupPoint);-- await _shippingPointRepository.DeleteAsync(pickupPoint);- await _cacheBase.RemoveByPrefix(PICKUP_POINT_PATTERN_KEY);- }- #endregion+ return Task.FromResult((from shippingPoint in _shippingPointRepository.Table+ where shippingPoint.ShippingPointName == pointName+ select shippingPoint).FirstOrDefault());}-}++ /// <summary>+ /// Gets a pickup point+ /// </summary>+ /// <param name="pickupPointId">Pickup point identifier</param>+ /// <returns>Pickup point</returns>+ public virtual Task<ShippingPoints> GetStoreShippingPointById(string pickupPointId)+ {+ return _shippingPointRepository.GetByIdAsync(pickupPointId);+ }++ /// <summary>+ /// Inserts a pickup point+ /// </summary>+ /// <param name="pickupPoint">Pickup point</param>+ public virtual async Task InsertStoreShippingPoint(ShippingPoints pickupPoint)+ {+ ArgumentNullException.ThrowIfNull(pickupPoint);++ await _shippingPointRepository.InsertAsync(pickupPoint);+ await _cacheBase.RemoveByPrefix(PICKUP_POINT_PATTERN_KEY);+ }++ /// <summary>+ /// Updates the pickup point+ /// </summary>+ /// <param name="pickupPoint">Pickup point</param>+ public virtual async Task UpdateStoreShippingPoint(ShippingPoints pickupPoint)+ {+ ArgumentNullException.ThrowIfNull(pickupPoint);++ await _shippingPointRepository.UpdateAsync(pickupPoint);+ await _cacheBase.RemoveByPrefix(PICKUP_POINT_PATTERN_KEY);+ }++ /// <summary>+ /// Deletes a pickup point+ /// </summary>+ /// <param name="pickupPoint">Pickup point</param>+ public virtual async Task DeleteStoreShippingPoint(ShippingPoints pickupPoint)+ {+ ArgumentNullException.ThrowIfNull(pickupPoint);++ await _shippingPointRepository.DeleteAsync(pickupPoint);+ await _cacheBase.RemoveByPrefix(PICKUP_POINT_PATTERN_KEY);+ }++ #endregion+}\ No newline at end of filediff --git a/src/Plugins/Shipping.ShippingPoint/ShippingPointRateDefaults.cs b/src/Plugins/Shipping.ShippingPoint/ShippingPointRateDefaults.csindex 2d68c0ab5..4d58548cb 100644--- a/src/Plugins/Shipping.ShippingPoint/ShippingPointRateDefaults.cs+++ b/src/Plugins/Shipping.ShippingPoint/ShippingPointRateDefaults.cs@@ -1,9 +1,8 @@-namespace Shipping.ShippingPoint+namespace Shipping.ShippingPoint;++public static class ShippingPointRateDefaults{- public static class ShippingPointRateDefaults- {- public const string ProviderSystemName = "Shipping.ShippingPoint";- public const string FriendlyName = "Shipping.ShippingPoint.FriendlyName";- public const string ConfigurationUrl = "../ShippingPoint/Configure";- }-}+ public const string ProviderSystemName = "Shipping.ShippingPoint";+ public const string FriendlyName = "Shipping.ShippingPoint.FriendlyName";+ public const string ConfigurationUrl = "../ShippingPoint/Configure";+}\ No newline at end of filediff --git a/src/Plugins/Shipping.ShippingPoint/ShippingPointRatePlugin.cs b/src/Plugins/Shipping.ShippingPoint/ShippingPointRatePlugin.csindex ad555fc28..1610a7336 100644--- a/src/Plugins/Shipping.ShippingPoint/ShippingPointRatePlugin.cs+++ b/src/Plugins/Shipping.ShippingPoint/ShippingPointRatePlugin.cs@@ -2,98 +2,141 @@using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Infrastructure.Plugins;-namespace Shipping.ShippingPoint+namespace Shipping.ShippingPoint;++public class ShippingPointRatePlugin : BasePlugin, IPlugin{- public class ShippingPointRatePlugin : BasePlugin, IPlugin+ #region Ctor++ public ShippingPointRatePlugin(+ ITranslationService translationService,+ ILanguageService languageService+ ){- #region Fields-- private readonly ITranslationService _translationService;- private readonly ILanguageService _languageService;-- #endregion-- #region Ctor- public ShippingPointRatePlugin(- ITranslationService translationService,- ILanguageService languageService- )- {- _translationService = translationService;- _languageService = languageService;- }- #endregion-- #region Methods-- /// <summary>- /// Install plugin- /// </summary>- public override async Task Install()- {- //locales- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.FriendlyName", "Shipping Point");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.PluginName", "Shipping Point");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.PluginDescription", "Choose a place where you can pick up your order");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.Fields.ShippingPointName", "Point Name");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.Fields.Description", "Description");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.Fields.PickupFee", "Pickup Fee");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.Fields.OpeningHours", "Open Between");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.Fields.Store", "Store Name");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.Fields.City", "City");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.Fields.Address1", "Address 1");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.Fields.ZipPostalCode", "Zip postal code");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.Fields.Country", "Country");-- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.ShippingPointName", "Point Name");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.Address", "Address");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.MethodAndFee", "{0} ({1})");-- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.AddNew", "Add New Point");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.RequiredShippingPointName", "Shipping Point Name Is Required");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.RequiredDescription", "Description Is Required");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.RequiredOpeningHours", "Opening Hours Are Required");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.SelectShippingOption", "Select Shipping Option");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.ChooseShippingPoint", "Choose Shipping Point");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Shipping.ShippingPoint.SelectBeforeProceed", "Select Shipping Option Before Proceed");-- await base.Install();- }-- /// <summary>- /// Uninstall plugin- /// </summary>- public override async Task Uninstall()- {- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.PluginName");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.PluginDescription");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.Fields.ShippingPointName");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.Fields.Description");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.Fields.PickupFee");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.Fields.OpeningHours");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.Fields.Store");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.AddNew");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.RequiredShippingPointName");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.RequiredDescription");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.RequiredOpeningHours");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.SelectShippingOption");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.ChooseShippingPoint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.SelectBeforeProceed");-- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.Fields.City");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.Fields.Address1");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.Fields.ZipPostalCode");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.Fields.Country");-- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.ShippingPointName");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.Address");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Shipping.ShippingPoint.MethodAndFee");--- await base.Uninstall();- }-- #endregion+ _translationService = translationService;+ _languageService = languageService;+ }++ #endregion++ #region Fields++ private readonly ITranslationService _translationService;+ private readonly ILanguageService _languageService;++ #endregion+ #region Methods++ /// <summary>+ /// Install plugin+ /// </summary>+ public override async Task Install()+ {+ //locales+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.FriendlyName", "Shipping Point");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.PluginName", "Shipping Point");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.PluginDescription", "Choose a place where you can pick up your order");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.Fields.ShippingPointName", "Point Name");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.Fields.Description", "Description");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.Fields.PickupFee", "Pickup Fee");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.Fields.OpeningHours", "Open Between");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.Fields.Store", "Store Name");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.Fields.City", "City");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.Fields.Address1", "Address 1");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.Fields.ZipPostalCode", "Zip postal code");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.Fields.Country", "Country");++ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.ShippingPointName", "Point Name");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.Address", "Address");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.MethodAndFee", "{0} ({1})");++ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.AddNew", "Add New Point");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.RequiredShippingPointName", "Shipping Point Name Is Required");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.RequiredDescription", "Description Is Required");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.RequiredOpeningHours", "Opening Hours Are Required");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.SelectShippingOption", "Select Shipping Option");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.ChooseShippingPoint", "Choose Shipping Point");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Shipping.ShippingPoint.SelectBeforeProceed", "Select Shipping Option Before Proceed");++ await base.Install();+ }++ /// <summary>+ /// Uninstall plugin+ /// </summary>+ public override async Task Uninstall()+ {+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.PluginName");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.PluginDescription");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.Fields.ShippingPointName");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.Fields.Description");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.Fields.PickupFee");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.Fields.OpeningHours");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.Fields.Store");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.AddNew");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.RequiredShippingPointName");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.RequiredDescription");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.RequiredOpeningHours");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.SelectShippingOption");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.ChooseShippingPoint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.SelectBeforeProceed");++ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.Fields.City");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.Fields.Address1");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.Fields.ZipPostalCode");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.Fields.Country");++ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.ShippingPointName");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.Address");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Shipping.ShippingPoint.MethodAndFee");+++ await base.Uninstall();}-}++ #endregion+}\ No newline at end of filediff --git a/src/Plugins/Shipping.ShippingPoint/ShippingPointRateProvider.cs b/src/Plugins/Shipping.ShippingPoint/ShippingPointRateProvider.csindex c1b35613b..9621d1388 100644--- a/src/Plugins/Shipping.ShippingPoint/ShippingPointRateProvider.cs+++ b/src/Plugins/Shipping.ShippingPoint/ShippingPointRateProvider.cs@@ -1,180 +1,184 @@using Grand.Business.Core.Enums.Checkout;-using Grand.Business.Core.Interfaces.Checkout.Shipping;-using Grand.Business.Core.Utilities.Checkout;using Grand.Business.Core.Extensions;+using Grand.Business.Core.Interfaces.Checkout.Shipping;using Grand.Business.Core.Interfaces.Common.Directory;using Grand.Business.Core.Interfaces.Common.Localization;+using Grand.Business.Core.Utilities.Checkout;using Grand.Domain.Customers;using Grand.Domain.Orders;using Grand.Domain.Shipping;using Grand.Infrastructure;+using Shipping.ShippingPoint.Domain;using Shipping.ShippingPoint.Services;using System.Xml.Serialization;-namespace Shipping.ShippingPoint+namespace Shipping.ShippingPoint;++public class ShippingPointRateProvider : IShippingRateCalculationProvider{- public class ShippingPointRateProvider : IShippingRateCalculationProvider+ #region Ctor++ public ShippingPointRateProvider(+ IShippingPointService shippingPointService,+ ITranslationService translationService,+ IWorkContext workContext,+ IUserFieldService userFieldService,+ ICountryService countryService,+ ICurrencyService currencyService,+ ShippingPointRateSettings shippingPointRateSettings+ ){- #region Fields-- private readonly IShippingPointService _shippingPointService;- private readonly ITranslationService _translationService;- private readonly IWorkContext _workContext;- private readonly IUserFieldService _userFieldService;- private readonly ICountryService _countryService;- private readonly ICurrencyService _currencyService;-- private readonly ShippingPointRateSettings _shippingPointRateSettings;-- #endregion-- #region Ctor- public ShippingPointRateProvider(- IShippingPointService shippingPointService,- ITranslationService translationService,- IWorkContext workContext,- IUserFieldService userFieldService,- ICountryService countryService,- ICurrencyService currencyService,- ShippingPointRateSettings shippingPointRateSettings- )- {- _shippingPointService = shippingPointService;- _translationService = translationService;- _workContext = workContext;- _userFieldService = userFieldService;- _countryService = countryService;- _currencyService = currencyService;- _shippingPointRateSettings = shippingPointRateSettings;- }- #endregion+ _shippingPointService = shippingPointService;+ _translationService = translationService;+ _workContext = workContext;+ _userFieldService = userFieldService;+ _countryService = countryService;+ _currencyService = currencyService;+ _shippingPointRateSettings = shippingPointRateSettings;+ }- #region Methods+ #endregion- /// <summary>- /// Gets available shipping options- /// </summary>- /// <param name="getShippingOptionRequest">A request for getting shipping options</param>- /// <returns>Represents a response of getting shipping rate options</returns>- public async Task<GetShippingOptionResponse> GetShippingOptions(GetShippingOptionRequest getShippingOptionRequest)- {- ArgumentNullException.ThrowIfNull(getShippingOptionRequest);+ #region Fields- var response = new GetShippingOptionResponse();+ private readonly IShippingPointService _shippingPointService;+ private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;+ private readonly IUserFieldService _userFieldService;+ private readonly ICountryService _countryService;+ private readonly ICurrencyService _currencyService;+ private readonly ShippingPointRateSettings _shippingPointRateSettings;- response.ShippingOptions.Add(new ShippingOption {- Name = _translationService.GetResource("Shipping.ShippingPoint.PluginName"),- Description = _translationService.GetResource("Shipping.ShippingPoint.PluginDescription"),- Rate = 0,- ShippingRateProviderSystemName = "Shipping.ShippingPoint"- });+ #endregion- return await Task.FromResult(response);- }+ #region Methods- /// <summary>- /// Gets fixed shipping rate (if Shipping rate method allows it and the rate can be calculated before checkout).- /// </summary>- /// <param name="getShippingOptionRequest">A request for getting shipping options</param>- /// <returns>Fixed shipping rate; or null in case there's no fixed shipping rate</returns>- public Task<double?> GetFixedRate(GetShippingOptionRequest getShippingOptionRequest)- {- return Task.FromResult(default(double?));- }+ /// <summary>+ /// Gets available shipping options+ /// </summary>+ /// <param name="getShippingOptionRequest">A request for getting shipping options</param>+ /// <returns>Represents a response of getting shipping rate options</returns>+ public async Task<GetShippingOptionResponse> GetShippingOptions(GetShippingOptionRequest getShippingOptionRequest)+ {+ ArgumentNullException.ThrowIfNull(getShippingOptionRequest);- public async Task<bool> HideShipmentMethods(IList<ShoppingCartItem> cart)- {- return await Task.FromResult(false);- }+ var response = new GetShippingOptionResponse();- public async Task<IList<string>> ValidateShippingForm(string shippingOption, IDictionary<string, string> data)- {- data.TryGetValue("selectedShippingOption", out var shippingOptionId);-- var shippingMethodName = shippingOption?.Split([':'])[0];-- if (string.IsNullOrEmpty(shippingOptionId))- return new List<string> { _translationService.GetResource("Shipping.ShippingPoint.SelectBeforeProceed") };-- if (shippingMethodName != _translationService.GetResource("Shipping.ShippingPoint.PluginName"))- throw new ArgumentException("shippingMethodName");-- var chosenShippingOption = await _shippingPointService.GetStoreShippingPointById(shippingOptionId);- if (chosenShippingOption == null)- return new List<string> { _translationService.GetResource("Shipping.ShippingPoint.SelectBeforeProceed") };-- //override price- var offeredShippingOptions = await _workContext.CurrentCustomer.GetUserField<List<ShippingOption>>(_userFieldService, SystemCustomerFieldNames.OfferedShippingOptions, _workContext.CurrentStore.Id);- offeredShippingOptions.Find(x => x.Name == shippingMethodName).Rate = await _currencyService.ConvertFromPrimaryStoreCurrency(chosenShippingOption.PickupFee, _workContext.WorkingCurrency);-- await _userFieldService.SaveField(- _workContext.CurrentCustomer,- SystemCustomerFieldNames.OfferedShippingOptions,- offeredShippingOptions,- _workContext.CurrentStore.Id);-- var forCustomer =- $"<strong>{_translationService.GetResource("Shipping.ShippingPoint.Fields.ShippingPointName")}:</strong> {chosenShippingOption.ShippingPointName}<br><strong>{_translationService.GetResource("Shipping.ShippingPoint.Fields.Description")}:</strong> {chosenShippingOption.Description}<br>";-- await _userFieldService.SaveField(- _workContext.CurrentCustomer,- SystemCustomerFieldNames.ShippingOptionAttributeDescription,- forCustomer,- _workContext.CurrentStore.Id);-- var serializedObject = new Domain.ShippingPointSerializable {- Id = chosenShippingOption.Id,- ShippingPointName = chosenShippingOption.ShippingPointName,- Description = chosenShippingOption.Description,- OpeningHours = chosenShippingOption.OpeningHours,- PickupFee = chosenShippingOption.PickupFee,- Country = (await _countryService.GetCountryById(chosenShippingOption.CountryId))?.Name,- City = chosenShippingOption.City,- Address1 = chosenShippingOption.Address1,- ZipPostalCode = chosenShippingOption.ZipPostalCode,- StoreId = chosenShippingOption.StoreId- };-- var stringBuilder = new StringBuilder();- string serializedAttribute;- await using (var tw = new StringWriter(stringBuilder))- {- var xmlS = new XmlSerializer(typeof(Domain.ShippingPointSerializable));- xmlS.Serialize(tw, serializedObject);- serializedAttribute = stringBuilder.ToString();- }-- await _userFieldService.SaveField(_workContext.CurrentCustomer,- SystemCustomerFieldNames.ShippingOptionAttribute,- serializedAttribute,- _workContext.CurrentStore.Id);-- return new List<string>();- }- public async Task<string> GetControllerRouteName()+ response.ShippingOptions.Add(new ShippingOption {+ Name = _translationService.GetResource("Shipping.ShippingPoint.PluginName"),+ Description = _translationService.GetResource("Shipping.ShippingPoint.PluginDescription"),+ Rate = 0,+ ShippingRateProviderSystemName = "Shipping.ShippingPoint"+ });++ return await Task.FromResult(response);+ }++ /// <summary>+ /// Gets fixed shipping rate (if Shipping rate method allows it and the rate can be calculated before checkout).+ /// </summary>+ /// <param name="getShippingOptionRequest">A request for getting shipping options</param>+ /// <returns>Fixed shipping rate; or null in case there's no fixed shipping rate</returns>+ public Task<double?> GetFixedRate(GetShippingOptionRequest getShippingOptionRequest)+ {+ return Task.FromResult(default(double?));+ }++ public async Task<bool> HideShipmentMethods(IList<ShoppingCartItem> cart)+ {+ return await Task.FromResult(false);+ }++ public async Task<IList<string>> ValidateShippingForm(string shippingOption, IDictionary<string, string> data)+ {+ data.TryGetValue("selectedShippingOption", out var shippingOptionId);++ var shippingMethodName = shippingOption?.Split([':'])[0];++ if (string.IsNullOrEmpty(shippingOptionId))+ return new List<string> { _translationService.GetResource("Shipping.ShippingPoint.SelectBeforeProceed") };++ if (shippingMethodName != _translationService.GetResource("Shipping.ShippingPoint.PluginName"))+ throw new ArgumentException("shippingMethodName");++ var chosenShippingOption = await _shippingPointService.GetStoreShippingPointById(shippingOptionId);+ if (chosenShippingOption == null)+ return new List<string> { _translationService.GetResource("Shipping.ShippingPoint.SelectBeforeProceed") };++ //override price+ var offeredShippingOptions = await _workContext.CurrentCustomer.GetUserField<List<ShippingOption>>(+ _userFieldService, SystemCustomerFieldNames.OfferedShippingOptions, _workContext.CurrentStore.Id);+ offeredShippingOptions.Find(x => x.Name == shippingMethodName).Rate =+ await _currencyService.ConvertFromPrimaryStoreCurrency(chosenShippingOption.PickupFee,+ _workContext.WorkingCurrency);++ await _userFieldService.SaveField(+ _workContext.CurrentCustomer,+ SystemCustomerFieldNames.OfferedShippingOptions,+ offeredShippingOptions,+ _workContext.CurrentStore.Id);++ var forCustomer =+ $"<strong>{_translationService.GetResource("Shipping.ShippingPoint.Fields.ShippingPointName")}:</strong> {chosenShippingOption.ShippingPointName}<br><strong>{_translationService.GetResource("Shipping.ShippingPoint.Fields.Description")}:</strong> {chosenShippingOption.Description}<br>";++ await _userFieldService.SaveField(+ _workContext.CurrentCustomer,+ SystemCustomerFieldNames.ShippingOptionAttributeDescription,+ forCustomer,+ _workContext.CurrentStore.Id);++ var serializedObject = new ShippingPointSerializable {+ Id = chosenShippingOption.Id,+ ShippingPointName = chosenShippingOption.ShippingPointName,+ Description = chosenShippingOption.Description,+ OpeningHours = chosenShippingOption.OpeningHours,+ PickupFee = chosenShippingOption.PickupFee,+ Country = (await _countryService.GetCountryById(chosenShippingOption.CountryId))?.Name,+ City = chosenShippingOption.City,+ Address1 = chosenShippingOption.Address1,+ ZipPostalCode = chosenShippingOption.ZipPostalCode,+ StoreId = chosenShippingOption.StoreId+ };++ var stringBuilder = new StringBuilder();+ string serializedAttribute;+ await using (var tw = new StringWriter(stringBuilder)){- return await Task.FromResult("Plugins.ShippingPoint.Points");+ var xmlS = new XmlSerializer(typeof(ShippingPointSerializable));+ xmlS.Serialize(tw, serializedObject);+ serializedAttribute = stringBuilder.ToString();}- public ShippingRateCalculationType ShippingRateCalculationType => ShippingRateCalculationType.Off;+ await _userFieldService.SaveField(_workContext.CurrentCustomer,+ SystemCustomerFieldNames.ShippingOptionAttribute,+ serializedAttribute,+ _workContext.CurrentStore.Id);++ return new List<string>();+ }++ public async Task<string> GetControllerRouteName()+ {+ return await Task.FromResult("Plugins.ShippingPoint.Points");+ }- public IShipmentTracker ShipmentTracker => null;+ public ShippingRateCalculationType ShippingRateCalculationType => ShippingRateCalculationType.Off;- public string ConfigurationUrl => ShippingPointRateDefaults.ConfigurationUrl;+ public IShipmentTracker ShipmentTracker => null;- public string SystemName => ShippingPointRateDefaults.ProviderSystemName;+ public string ConfigurationUrl => ShippingPointRateDefaults.ConfigurationUrl;- public string FriendlyName => _translationService.GetResource(ShippingPointRateDefaults.FriendlyName);+ public string SystemName => ShippingPointRateDefaults.ProviderSystemName;- public int Priority => _shippingPointRateSettings.DisplayOrder;+ public string FriendlyName => _translationService.GetResource(ShippingPointRateDefaults.FriendlyName);- public IList<string> LimitedToStores => new List<string>();+ public int Priority => _shippingPointRateSettings.DisplayOrder;- public IList<string> LimitedToGroups => new List<string>();+ public IList<string> LimitedToStores => new List<string>();- #endregion+ public IList<string> LimitedToGroups => new List<string>();- }-}+ #endregion+}\ No newline at end of filediff --git a/src/Plugins/Shipping.ShippingPoint/ShippingPointRateSettings.cs b/src/Plugins/Shipping.ShippingPoint/ShippingPointRateSettings.csindex 358a15c00..414bb45a9 100644--- a/src/Plugins/Shipping.ShippingPoint/ShippingPointRateSettings.cs+++ b/src/Plugins/Shipping.ShippingPoint/ShippingPointRateSettings.cs@@ -1,9 +1,8 @@using Grand.Domain.Configuration;-namespace Shipping.ShippingPoint+namespace Shipping.ShippingPoint;++public class ShippingPointRateSettings : ISettings{- public class ShippingPointRateSettings : ISettings- {- public int DisplayOrder { get; set; }- }-}+ public int DisplayOrder { get; set; }+}\ No newline at end of filediff --git a/src/Plugins/Shipping.ShippingPoint/StartupApplication.cs b/src/Plugins/Shipping.ShippingPoint/StartupApplication.csindex a91e4a5f0..5659d28b0 100644--- a/src/Plugins/Shipping.ShippingPoint/StartupApplication.cs+++ b/src/Plugins/Shipping.ShippingPoint/StartupApplication.cs@@ -6,22 +6,21 @@ using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;using Shipping.ShippingPoint.Services;-namespace Shipping.ShippingPoint+namespace Shipping.ShippingPoint;++public class StartupApplication : IStartupApplication{- public class StartupApplication : IStartupApplication+ public void ConfigureServices(IServiceCollection services, IConfiguration configuration){- public void ConfigureServices(IServiceCollection services, IConfiguration configuration)- {- services.AddScoped<IShippingRateCalculationProvider, ShippingPointRateProvider>();- services.AddScoped<IShippingPointService, ShippingPointService>();- }-- public int Priority => 10;- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)- {+ services.AddScoped<IShippingRateCalculationProvider, ShippingPointRateProvider>();+ services.AddScoped<IShippingPointService, ShippingPointService>();+ }- }- public bool BeforeConfigure => false;+ public int Priority => 10;+ public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)+ {}-}++ public bool BeforeConfigure => false;+}\ No newline at end of filediff --git a/src/Plugins/Shipping.ShippingPoint/Validators/ShippingPointValidator.cs b/src/Plugins/Shipping.ShippingPoint/Validators/ShippingPointValidator.csindex d5de54422..ffe6a936a 100644--- a/src/Plugins/Shipping.ShippingPoint/Validators/ShippingPointValidator.cs+++ b/src/Plugins/Shipping.ShippingPoint/Validators/ShippingPointValidator.cs@@ -3,23 +3,28 @@ using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Infrastructure.Validators;using Shipping.ShippingPoint.Models;-namespace Shipping.ShippingPoint.Validators+namespace Shipping.ShippingPoint.Validators;++public class ShippingPointValidator : BaseGrandValidator<ShippingPointModel>{- public class ShippingPointValidator : BaseGrandValidator<ShippingPointModel>+ public ShippingPointValidator(+ IEnumerable<IValidatorConsumer<ShippingPointModel>> validators,+ ITranslationService translationService)+ : base(validators){- public ShippingPointValidator(- IEnumerable<IValidatorConsumer<ShippingPointModel>> validators,- ITranslationService translationService)- : base(validators)- {- RuleFor(x => x.ShippingPointName).NotEmpty().WithMessage(translationService.GetResource("Shipping.ShippingPoint.RequiredShippingPointName"));- RuleFor(x => x.Description).NotEmpty().WithMessage(translationService.GetResource("Shipping.ShippingPoint.RequiredDescription"));- RuleFor(x => x.OpeningHours).NotEmpty().WithMessage(translationService.GetResource("Shipping.ShippingPoint.RequiredOpeningHours"));- RuleFor(x => x.CountryId).NotNull().WithMessage(translationService.GetResource("Admin.Address.Fields.Country.Required"));- RuleFor(x => x.City).NotEmpty().WithMessage(translationService.GetResource("Admin.Address.Fields.City.Required"));- RuleFor(x => x.Address1).NotEmpty().WithMessage(translationService.GetResource("Admin.Address.Fields.Address1.Required"));- RuleFor(x => x.ZipPostalCode).NotEmpty().WithMessage(translationService.GetResource("Admin.Address.Fields.ZipPostalCode.Required"));- }+ RuleFor(x => x.ShippingPointName).NotEmpty()+ .WithMessage(translationService.GetResource("Shipping.ShippingPoint.RequiredShippingPointName"));+ RuleFor(x => x.Description).NotEmpty()+ .WithMessage(translationService.GetResource("Shipping.ShippingPoint.RequiredDescription"));+ RuleFor(x => x.OpeningHours).NotEmpty()+ .WithMessage(translationService.GetResource("Shipping.ShippingPoint.RequiredOpeningHours"));+ RuleFor(x => x.CountryId).NotNull()+ .WithMessage(translationService.GetResource("Admin.Address.Fields.Country.Required"));+ RuleFor(x => x.City).NotEmpty()+ .WithMessage(translationService.GetResource("Admin.Address.Fields.City.Required"));+ RuleFor(x => x.Address1).NotEmpty()+ .WithMessage(translationService.GetResource("Admin.Address.Fields.Address1.Required"));+ RuleFor(x => x.ZipPostalCode).NotEmpty()+ .WithMessage(translationService.GetResource("Admin.Address.Fields.ZipPostalCode.Required"));}-}\ No newline at end of filediff --git a/src/Plugins/Shipping.ShippingPoint/Views/SelectedShippingPoint/Get.cshtml b/src/Plugins/Shipping.ShippingPoint/Views/SelectedShippingPoint/Get.cshtmlindex 29efd47ad..5bbfe45ac 100644--- a/src/Plugins/Shipping.ShippingPoint/Views/SelectedShippingPoint/Get.cshtml+++ b/src/Plugins/Shipping.ShippingPoint/Views/SelectedShippingPoint/Get.cshtml@@ -9,7 +9,9 @@<div class="col-md-10">@Loc["Shipping.ShippingPoint.MethodAndFee", Model.ShippingPointName, Model.PickupFee]</div></div><div class="row">- <div class="col-md-2 text-right"><label>@Loc["Shipping.ShippingPoint.Address"]</label></div>+ <div class="col-md-2 text-right">+ <label>@Loc["Shipping.ShippingPoint.Address"]</label>+ </div><div class="col-md-10">@Model.CountryName, @Model.ZipPostalCode @Model.City, @Model.Address1</div></div></div>diff --git a/src/Plugins/Shipping.ShippingPoint/Views/_ViewImports.cshtml b/src/Plugins/Shipping.ShippingPoint/Views/_ViewImports.cshtmlindex 20cb126bd..0d1dc3574 100644--- a/src/Plugins/Shipping.ShippingPoint/Views/_ViewImports.cshtml+++ b/src/Plugins/Shipping.ShippingPoint/Views/_ViewImports.cshtml@@ -4,5 +4,6 @@@using Microsoft.AspNetCore.Mvc.ViewFeatures@using Grand.Infrastructure.Extensions-@using Grand.Web.Common-@inject Grand.Web.Common.Localization.LocService Loc+@using Grand.Web.Common+@using Grand.Web.Common.Localization+@inject LocService Loc\ No newline at end of filediff --git a/src/Plugins/Tax.CountryStateZip/Areas/Admin/Controllers/TaxCountryStateZipController.cs b/src/Plugins/Tax.CountryStateZip/Areas/Admin/Controllers/TaxCountryStateZipController.csindex e3fa0f797..1a82d83d3 100644--- a/src/Plugins/Tax.CountryStateZip/Areas/Admin/Controllers/TaxCountryStateZipController.cs+++ b/src/Plugins/Tax.CountryStateZip/Areas/Admin/Controllers/TaxCountryStateZipController.cs@@ -11,142 +11,138 @@ using Tax.CountryStateZip.Domain;using Tax.CountryStateZip.Models;using Tax.CountryStateZip.Services;-namespace Tax.CountryStateZip.Areas.Admin.Controllers+namespace Tax.CountryStateZip.Areas.Admin.Controllers;++[PermissionAuthorize(PermissionSystemName.TaxSettings)]+public class TaxCountryStateZipController : BaseAdminPluginController{- [PermissionAuthorize(PermissionSystemName.TaxSettings)]- public class TaxCountryStateZipController : BaseAdminPluginController+ private readonly ICountryService _countryService;+ private readonly IStoreService _storeService;+ private readonly ITaxCategoryService _taxCategoryService;+ private readonly ITaxRateService _taxRateService;++ public TaxCountryStateZipController(ITaxCategoryService taxCategoryService,+ ICountryService countryService,+ ITaxRateService taxRateService,+ IStoreService storeService){- private readonly ITaxCategoryService _taxCategoryService;- private readonly ICountryService _countryService;- private readonly ITaxRateService _taxRateService;- private readonly IStoreService _storeService;+ _taxCategoryService = taxCategoryService;+ _countryService = countryService;+ _taxRateService = taxRateService;+ _storeService = storeService;+ }- public TaxCountryStateZipController(ITaxCategoryService taxCategoryService,- ICountryService countryService,- ITaxRateService taxRateService,- IStoreService storeService)- {- _taxCategoryService = taxCategoryService;- _countryService = countryService;- _taxRateService = taxRateService;- _storeService = storeService;- }+ public async Task<IActionResult> Configure()+ {+ var taxCategories = await _taxCategoryService.GetAllTaxCategories();+ if (taxCategories.Count == 0)+ return Content("No tax categories can be loaded");- public async Task<IActionResult> Configure()+ var model = new TaxRateListModel();+ //stores+ model.AvailableStores.Add(new SelectListItem { Text = "*", Value = "" });+ var stores = await _storeService.GetAllStores();+ foreach (var s in stores)+ model.AvailableStores.Add(new SelectListItem { Text = s.Shortcut, Value = s.Id });+ //tax categories+ foreach (var tc in taxCategories)+ model.AvailableTaxCategories.Add(new SelectListItem { Text = tc.Name, Value = tc.Id });+ //countries+ var countries = await _countryService.GetAllCountries(showHidden: true);+ foreach (var c in countries)+ model.AvailableCountries.Add(new SelectListItem { Text = c.Name, Value = c.Id });+ //states+ model.AvailableStates.Add(new SelectListItem { Text = "*", Value = "" });+ var defaultCountry = countries.FirstOrDefault();+ if (defaultCountry != null){- var taxCategories = await _taxCategoryService.GetAllTaxCategories();- if (taxCategories.Count == 0)- return Content("No tax categories can be loaded");-- var model = new TaxRateListModel();- //stores- model.AvailableStores.Add(new SelectListItem { Text = "*", Value = "" });- var stores = await _storeService.GetAllStores();- foreach (var s in stores)- model.AvailableStores.Add(new SelectListItem { Text = s.Shortcut, Value = s.Id });- //tax categories- foreach (var tc in taxCategories)- model.AvailableTaxCategories.Add(new SelectListItem { Text = tc.Name, Value = tc.Id });- //countries- var countries = await _countryService.GetAllCountries(showHidden: true);- foreach (var c in countries)- model.AvailableCountries.Add(new SelectListItem { Text = c.Name, Value = c.Id });- //states- model.AvailableStates.Add(new SelectListItem { Text = "*", Value = "" });- var defaultCountry = countries.FirstOrDefault();- if (defaultCountry != null)- {- var states = await _countryService.GetStateProvincesByCountryId(defaultCountry.Id);- foreach (var s in states)- model.AvailableStates.Add(new SelectListItem { Text = s.Name, Value = s.Id });- }-- return View(model);+ var states = await _countryService.GetStateProvincesByCountryId(defaultCountry.Id);+ foreach (var s in states)+ model.AvailableStates.Add(new SelectListItem { Text = s.Name, Value = s.Id });}- [HttpPost]- [AutoValidateAntiforgeryToken]- public async Task<IActionResult> RatesList(DataSourceRequest command)- {- var records = await _taxRateService.GetAllTaxRates(command.Page - 1, command.PageSize);- var taxRatesModel = new List<TaxRateModel>();- foreach (var x in records)- {- var m = new TaxRateModel- {- Id = x.Id,- StoreId = x.StoreId,- TaxCategoryId = x.TaxCategoryId,- CountryId = x.CountryId,- StateProvinceId = x.StateProvinceId,- Zip = x.Zip,- Percentage = x.Percentage- };- //store- var store = await _storeService.GetStoreById(x.StoreId);- m.StoreName = store != null ? store.Shortcut : "*";- //tax category- var tc = await _taxCategoryService.GetTaxCategoryById(x.TaxCategoryId);- m.TaxCategoryName = tc != null ? tc.Name : "";- //country- var c = await _countryService.GetCountryById(x.CountryId);- m.CountryName = c != null ? c.Name : "Unavailable";- //state- var s = c?.StateProvinces.FirstOrDefault(z=>z.Id == x.StateProvinceId);- m.StateProvinceName = s != null ? s.Name : "*";- //zip- m.Zip = !string.IsNullOrEmpty(x.Zip) ? x.Zip : "*";- taxRatesModel.Add(m);- }+ return View(model);+ }- var gridModel = new DataSourceResult- {- Data = taxRatesModel,- Total = records.TotalCount+ [HttpPost]+ [AutoValidateAntiforgeryToken]+ public async Task<IActionResult> RatesList(DataSourceRequest command)+ {+ var records = await _taxRateService.GetAllTaxRates(command.Page - 1, command.PageSize);+ var taxRatesModel = new List<TaxRateModel>();+ foreach (var x in records)+ {+ var m = new TaxRateModel {+ Id = x.Id,+ StoreId = x.StoreId,+ TaxCategoryId = x.TaxCategoryId,+ CountryId = x.CountryId,+ StateProvinceId = x.StateProvinceId,+ Zip = x.Zip,+ Percentage = x.Percentage};-- return Json(gridModel);+ //store+ var store = await _storeService.GetStoreById(x.StoreId);+ m.StoreName = store != null ? store.Shortcut : "*";+ //tax category+ var tc = await _taxCategoryService.GetTaxCategoryById(x.TaxCategoryId);+ m.TaxCategoryName = tc != null ? tc.Name : "";+ //country+ var c = await _countryService.GetCountryById(x.CountryId);+ m.CountryName = c != null ? c.Name : "Unavailable";+ //state+ var s = c?.StateProvinces.FirstOrDefault(z => z.Id == x.StateProvinceId);+ m.StateProvinceName = s != null ? s.Name : "*";+ //zip+ m.Zip = !string.IsNullOrEmpty(x.Zip) ? x.Zip : "*";+ taxRatesModel.Add(m);}- [HttpPost]- [AutoValidateAntiforgeryToken]- public async Task<IActionResult> RateUpdate(TaxRateModel model)- {- var taxRate = await _taxRateService.GetTaxRateById(model.Id);- taxRate.Zip = model.Zip == "*" ? null : model.Zip;- taxRate.Percentage = model.Percentage;- await _taxRateService.UpdateTaxRate(taxRate);+ var gridModel = new DataSourceResult {+ Data = taxRatesModel,+ Total = records.TotalCount+ };- return new JsonResult("");- }+ return Json(gridModel);+ }- [HttpPost]- [AutoValidateAntiforgeryToken]- public async Task<IActionResult> RateDelete(string id)- {- var taxRate = await _taxRateService.GetTaxRateById(id);- if (taxRate != null)- await _taxRateService.DeleteTaxRate(taxRate);+ [HttpPost]+ [AutoValidateAntiforgeryToken]+ public async Task<IActionResult> RateUpdate(TaxRateModel model)+ {+ var taxRate = await _taxRateService.GetTaxRateById(model.Id);+ taxRate.Zip = model.Zip == "*" ? null : model.Zip;+ taxRate.Percentage = model.Percentage;+ await _taxRateService.UpdateTaxRate(taxRate);- return new JsonResult("");- }+ return new JsonResult("");+ }- [HttpPost]- [AutoValidateAntiforgeryToken]- public async Task<IActionResult> AddTaxRate(TaxRateListModel model)- {- var taxRate = new TaxRate- {- StoreId = model.AddStoreId,- TaxCategoryId = model.AddTaxCategoryId,- CountryId = model.AddCountryId,- StateProvinceId = model.AddStateProvinceId,- Zip = model.AddZip,- Percentage = model.AddPercentage- };- await _taxRateService.InsertTaxRate(taxRate);+ [HttpPost]+ [AutoValidateAntiforgeryToken]+ public async Task<IActionResult> RateDelete(string id)+ {+ var taxRate = await _taxRateService.GetTaxRateById(id);+ if (taxRate != null)+ await _taxRateService.DeleteTaxRate(taxRate);- return Json(new { Result = true });- }+ return new JsonResult("");+ }++ [HttpPost]+ [AutoValidateAntiforgeryToken]+ public async Task<IActionResult> AddTaxRate(TaxRateListModel model)+ {+ var taxRate = new TaxRate {+ StoreId = model.AddStoreId,+ TaxCategoryId = model.AddTaxCategoryId,+ CountryId = model.AddCountryId,+ StateProvinceId = model.AddStateProvinceId,+ Zip = model.AddZip,+ Percentage = model.AddPercentage+ };+ await _taxRateService.InsertTaxRate(taxRate);++ return Json(new { Result = true });}}\ No newline at end of filediff --git a/src/Plugins/Tax.CountryStateZip/Areas/Admin/Views/TaxCountryStateZip/Configure.cshtml b/src/Plugins/Tax.CountryStateZip/Areas/Admin/Views/TaxCountryStateZip/Configure.cshtmlindex ed53c9171..e18faefd2 100644--- a/src/Plugins/Tax.CountryStateZip/Areas/Admin/Views/TaxCountryStateZip/Configure.cshtml+++ b/src/Plugins/Tax.CountryStateZip/Areas/Admin/Views/TaxCountryStateZip/Configure.cshtml@@ -1,12 +1,11 @@-@model TaxRateListModel-@using Tax.CountryStateZip.Models-@using Grand.Domain.Common;+@using Grand.Domain.Common@using Microsoft.AspNetCore.Routing+@model Tax.CountryStateZip.Models.TaxRateListModel@inject AdminAreaSettings adminAreaSettings@{Layout = "_ConfigurePlugin";}-<input id="active-menu-item" type="hidden" value="/Admin/Tax/Providers" />+<input id="active-menu-item" type="hidden" value="/Admin/Tax/Providers"/><div id="tax-countrystatezip-grid"></div><script>$(document).ready(function () {@@ -142,7 +141,7 @@});</script><form asp-controller="TaxCountryStateZip" asp-action="Configure" method="post">-+<div class="form-horizontal"><div class="form-body"><div class="form-group">@@ -152,55 +151,55 @@</div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="AddStoreId" class="control-label" />+ <admin-label asp-for="AddStoreId" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-select asp-for="AddStoreId" asp-items="Model.AvailableStores" />+ <admin-select asp-for="AddStoreId" asp-items="Model.AvailableStores"/><span asp-validation-for="AddStoreId"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="AddCountryId" class="control-label" />+ <admin-label asp-for="AddCountryId" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-select asp-for="AddCountryId" asp-items="Model.AvailableCountries" />+ <admin-select asp-for="AddCountryId" asp-items="Model.AvailableCountries"/><span asp-validation-for="AddCountryId"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="AddStateProvinceId" class="control-label" />+ <admin-label asp-for="AddStateProvinceId" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-select asp-for="AddStateProvinceId" asp-items="Model.AvailableStates" />+ <admin-select asp-for="AddStateProvinceId" asp-items="Model.AvailableStates"/><span asp-validation-for="AddStateProvinceId"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="AddZip" class="control-label" />+ <admin-label asp-for="AddZip" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="AddZip" />+ <admin-input asp-for="AddZip"/><span asp-validation-for="AddZip"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="AddTaxCategoryId" class="control-label" />+ <admin-label asp-for="AddTaxCategoryId" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-select asp-for="AddTaxCategoryId" asp-items="Model.AvailableTaxCategories" />+ <admin-select asp-for="AddTaxCategoryId" asp-items="Model.AvailableTaxCategories"/><span asp-validation-for="AddTaxCategoryId"></span></div></div><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="AddPercentage" class="control-label" />+ <admin-label asp-for="AddPercentage" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="AddPercentage" />+ <admin-input asp-for="AddPercentage"/><span asp-validation-for="AddPercentage"></span></div></div>@@ -208,7 +207,7 @@<div class="form-actions"><div class="row"><div class="offset-md-3 offset-sm-3 col-md-9 col-sm-9">- <input type="button" id="addtaxrate" class="btn green" value="@Loc["Plugins.Tax.CountryStateZip.AddRecord"]" />+ <input type="button" id="addtaxrate" class="btn green" value="@Loc["Plugins.Tax.CountryStateZip.AddRecord"]"/></div></div></div>diff --git a/src/Plugins/Tax.CountryStateZip/Areas/Admin/Views/_ViewImports.cshtml b/src/Plugins/Tax.CountryStateZip/Areas/Admin/Views/_ViewImports.cshtmlindex 2fb08c043..fb3b84aa9 100644--- a/src/Plugins/Tax.CountryStateZip/Areas/Admin/Views/_ViewImports.cshtml+++ b/src/Plugins/Tax.CountryStateZip/Areas/Admin/Views/_ViewImports.cshtml@@ -4,5 +4,6 @@@using Microsoft.AspNetCore.Mvc.ViewFeatures@using Grand.Infrastructure.Extensions+@using Grand.Web.Common.Localization-@inject Grand.Web.Common.Localization.LocService Loc+@inject LocService Loc\ No newline at end of filediff --git a/src/Plugins/Tax.CountryStateZip/CountryStateZipTaxDefaults.cs b/src/Plugins/Tax.CountryStateZip/CountryStateZipTaxDefaults.csindex 97e4ef25e..2e4b5a036 100644--- a/src/Plugins/Tax.CountryStateZip/CountryStateZipTaxDefaults.cs+++ b/src/Plugins/Tax.CountryStateZip/CountryStateZipTaxDefaults.cs@@ -1,9 +1,8 @@-namespace Tax.CountryStateZip+namespace Tax.CountryStateZip;++public static class CountryStateZipTaxDefaults{- public static class CountryStateZipTaxDefaults- {- public const string ProviderSystemName = "Tax.CountryStateZip";- public const string FriendlyName = "Tax.CountryStateZip.FriendlyName";- public const string ConfigurationUrl = "../TaxCountryStateZip/Configure";- }-}+ public const string ProviderSystemName = "Tax.CountryStateZip";+ public const string FriendlyName = "Tax.CountryStateZip.FriendlyName";+ public const string ConfigurationUrl = "../TaxCountryStateZip/Configure";+}\ No newline at end of filediff --git a/src/Plugins/Tax.CountryStateZip/CountryStateZipTaxPlugin.cs b/src/Plugins/Tax.CountryStateZip/CountryStateZipTaxPlugin.csindex 13ebc87ab..6a71e49b0 100644--- a/src/Plugins/Tax.CountryStateZip/CountryStateZipTaxPlugin.cs+++ b/src/Plugins/Tax.CountryStateZip/CountryStateZipTaxPlugin.cs@@ -2,80 +2,111 @@using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Infrastructure.Plugins;-namespace Tax.CountryStateZip+namespace Tax.CountryStateZip;++/// <summary>+/// Fixed rate tax provider+/// </summary>+public class CountryStateZipTaxPlugin : BasePlugin, IPlugin{+ private readonly ILanguageService _languageService;+ private readonly ITranslationService _translationService;++ public CountryStateZipTaxPlugin(+ ITranslationService translationService,+ ILanguageService languageService)+ {+ _translationService = translationService;+ _languageService = languageService;+ }+/// <summary>- /// Fixed rate tax provider+ /// Gets a configuration page URL/// </summary>- public class CountryStateZipTaxPlugin : BasePlugin, IPlugin+ public override string ConfigurationUrl(){- private readonly ITranslationService _translationService;- private readonly ILanguageService _languageService;-- public CountryStateZipTaxPlugin(- ITranslationService translationService,- ILanguageService languageService)- {- _translationService = translationService;- _languageService = languageService;- }-- /// <summary>- /// Gets a configuration page URL- /// </summary>- public override string ConfigurationUrl()- {- return CountryStateZipTaxDefaults.ConfigurationUrl;- }+ return CountryStateZipTaxDefaults.ConfigurationUrl;+ }- /// <summary>- /// Install plugin- /// </summary>- public override async Task Install()- {- //locales- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Tax.CountryStateZip.FriendlyName", "Tax by country and state zip");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.Store", "Store");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.Store.Hint", "If an asterisk is selected, then this shipping rate will apply to all stores.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.Country", "Country");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.Country.Hint", "The country.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.StateProvince", "State / province");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.StateProvince.Hint", "If an asterisk is selected, then this tax rate will apply to all customers from the given country, regardless of the state.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.Zip", "Zip");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.Zip.Hint", "Zip / postal code. If zip is empty, then this tax rate will apply to all customers from the given country or state, regardless of the zip code.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.TaxCategory", "Tax category");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.TaxCategory.Hint", "The tax category.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.Percentage", "Percentage");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.Percentage.Hint", "The tax rate.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.AddRecord", "Add tax rate");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.AddRecord.Hint", "Adding a new tax rate");+ /// <summary>+ /// Install plugin+ /// </summary>+ public override async Task Install()+ {+ //locales+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Tax.CountryStateZip.FriendlyName", "Tax by country and state zip");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.Store", "Store");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.Store.Hint",+ "If an asterisk is selected, then this shipping rate will apply to all stores.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.Country", "Country");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.Country.Hint", "The country.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.StateProvince", "State / province");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.StateProvince.Hint",+ "If an asterisk is selected, then this tax rate will apply to all customers from the given country, regardless of the state.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.Zip", "Zip");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.Zip.Hint",+ "Zip / postal code. If zip is empty, then this tax rate will apply to all customers from the given country or state, regardless of the zip code.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.TaxCategory", "Tax category");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.TaxCategory.Hint", "The tax category.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.Percentage", "Percentage");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.Percentage.Hint", "The tax rate.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.AddRecord", "Add tax rate");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.AddRecord.Hint", "Adding a new tax rate");- await base.Install();- }+ await base.Install();+ }- /// <summary>- /// Uninstall plugin- /// </summary>- public override async Task Uninstall()- {- //locales- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.Store");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.Store.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.Country");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.Country.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.StateProvince");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.StateProvince.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.Zip");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.Zip.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.TaxCategory");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.TaxCategory.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.Percentage");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.Fields.Percentage.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.AddRecord");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Tax.CountryStateZip.AddRecord.Hint");+ /// <summary>+ /// Uninstall plugin+ /// </summary>+ public override async Task Uninstall()+ {+ //locales+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.Store");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.Store.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.Country");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.Country.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.StateProvince");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.StateProvince.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.Zip");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.Zip.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.TaxCategory");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.TaxCategory.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.Percentage");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.Fields.Percentage.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.AddRecord");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Tax.CountryStateZip.AddRecord.Hint");- await base.Uninstall();- }+ await base.Uninstall();}}\ No newline at end of filediff --git a/src/Plugins/Tax.CountryStateZip/CountryStateZipTaxProvider.cs b/src/Plugins/Tax.CountryStateZip/CountryStateZipTaxProvider.csindex 6d5d4063c..a54b4b5e5 100644--- a/src/Plugins/Tax.CountryStateZip/CountryStateZipTaxProvider.cs+++ b/src/Plugins/Tax.CountryStateZip/CountryStateZipTaxProvider.cs@@ -1,114 +1,116 @@using Grand.Business.Core.Interfaces.Catalog.Tax;-using Grand.Business.Core.Utilities.Catalog;using Grand.Business.Core.Interfaces.Common.Localization;+using Grand.Business.Core.Utilities.Catalog;using Grand.Infrastructure;using Grand.Infrastructure.Caching;using Tax.CountryStateZip.Infrastructure.Cache;using Tax.CountryStateZip.Services;-namespace Tax.CountryStateZip+namespace Tax.CountryStateZip;++public class CountryStateZipTaxProvider : ITaxProvider{- public class CountryStateZipTaxProvider : ITaxProvider- {- private readonly ITranslationService _translationService;- private readonly ICacheBase _cacheBase;- private readonly IWorkContext _workContext;- private readonly ITaxRateService _taxRateService;+ private readonly ICacheBase _cacheBase;- private readonly CountryStateZipTaxSettings _countryStateZipTaxSettings;+ private readonly CountryStateZipTaxSettings _countryStateZipTaxSettings;+ private readonly ITaxRateService _taxRateService;+ private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;- public CountryStateZipTaxProvider(ITranslationService translationService,- ICacheBase cacheBase,- IWorkContext workContext,- ITaxRateService taxRateService,- CountryStateZipTaxSettings countryStateZipTaxSettings)- {- _translationService = translationService;- _cacheBase = cacheBase;- _workContext = workContext;- _taxRateService = taxRateService;- _countryStateZipTaxSettings = countryStateZipTaxSettings;- }+ public CountryStateZipTaxProvider(ITranslationService translationService,+ ICacheBase cacheBase,+ IWorkContext workContext,+ ITaxRateService taxRateService,+ CountryStateZipTaxSettings countryStateZipTaxSettings)+ {+ _translationService = translationService;+ _cacheBase = cacheBase;+ _workContext = workContext;+ _taxRateService = taxRateService;+ _countryStateZipTaxSettings = countryStateZipTaxSettings;+ }- public string ConfigurationUrl => CountryStateZipTaxDefaults.ConfigurationUrl;+ public string ConfigurationUrl => CountryStateZipTaxDefaults.ConfigurationUrl;- public string SystemName => CountryStateZipTaxDefaults.ProviderSystemName;+ public string SystemName => CountryStateZipTaxDefaults.ProviderSystemName;- public string FriendlyName => _translationService.GetResource(CountryStateZipTaxDefaults.FriendlyName);+ public string FriendlyName => _translationService.GetResource(CountryStateZipTaxDefaults.FriendlyName);- public int Priority => _countryStateZipTaxSettings.DisplayOrder;+ public int Priority => _countryStateZipTaxSettings.DisplayOrder;- public IList<string> LimitedToStores => new List<string>();+ public IList<string> LimitedToStores => new List<string>();- public IList<string> LimitedToGroups => new List<string>();+ public IList<string> LimitedToGroups => new List<string>();- /// <summary>- /// Gets tax rate- /// </summary>- /// <param name="calculateTaxRequest">Tax calculation request</param>- /// <returns>Tax</returns>- public async Task<TaxResult> GetTaxRate(TaxRequest calculateTaxRequest)+ /// <summary>+ /// Gets tax rate+ /// </summary>+ /// <param name="calculateTaxRequest">Tax calculation request</param>+ /// <returns>Tax</returns>+ public async Task<TaxResult> GetTaxRate(TaxRequest calculateTaxRequest)+ {+ var result = new TaxResult();++ if (calculateTaxRequest.Address == null){- var result = new TaxResult();-- if (calculateTaxRequest.Address == null)- {- result.Errors.Add("Address is not set");- return result;- }-- const string cacheKey = ModelCacheEventConsumer.ALL_TAX_RATES_MODEL_KEY;- var allTaxRates = await _cacheBase.GetAsync(cacheKey, async () =>- {- var taxes = await _taxRateService.GetAllTaxRates();- return taxes.Select(x => new TaxRateForCaching- {- Id = x.Id,- StoreId = x.StoreId,- TaxCategoryId = x.TaxCategoryId,- CountryId = x.CountryId,- StateProvinceId = x.StateProvinceId,- Zip = x.Zip,- Percentage = x.Percentage- });- });+ result.Errors.Add("Address is not set");+ return result;+ }- var storeId = _workContext.CurrentStore.Id;- var taxCategoryId = calculateTaxRequest.TaxCategoryId;- var countryId = calculateTaxRequest.Address.CountryId;- var stateProvinceId = calculateTaxRequest.Address.StateProvinceId;- var zip = calculateTaxRequest.Address.ZipPostalCode ?? string.Empty;+ const string cacheKey = ModelCacheEventConsumer.ALL_TAX_RATES_MODEL_KEY;+ var allTaxRates = await _cacheBase.GetAsync(cacheKey, async () =>+ {+ var taxes = await _taxRateService.GetAllTaxRates();+ return taxes.Select(x => new TaxRateForCaching {+ Id = x.Id,+ StoreId = x.StoreId,+ TaxCategoryId = x.TaxCategoryId,+ CountryId = x.CountryId,+ StateProvinceId = x.StateProvinceId,+ Zip = x.Zip,+ Percentage = x.Percentage+ });+ });- zip = zip.Trim();+ var storeId = _workContext.CurrentStore.Id;+ var taxCategoryId = calculateTaxRequest.TaxCategoryId;+ var countryId = calculateTaxRequest.Address.CountryId;+ var stateProvinceId = calculateTaxRequest.Address.StateProvinceId;+ var zip = calculateTaxRequest.Address.ZipPostalCode ?? string.Empty;- var existingRates = allTaxRates.Where(taxRate => taxRate.CountryId == countryId && taxRate.TaxCategoryId == taxCategoryId).ToList();+ zip = zip.Trim();- //filter by store- var matchedByStore = existingRates.Where(taxRate => storeId == taxRate.StoreId).ToList();+ var existingRates = allTaxRates+ .Where(taxRate => taxRate.CountryId == countryId && taxRate.TaxCategoryId == taxCategoryId).ToList();- //not found? use the default ones (ID == 0)- if (!matchedByStore.Any())- matchedByStore.AddRange(existingRates.Where(taxRate => string.IsNullOrEmpty(taxRate.StoreId)));+ //filter by store+ var matchedByStore = existingRates.Where(taxRate => storeId == taxRate.StoreId).ToList();- //filter by state/province- var matchedByStateProvince = matchedByStore.Where(taxRate => stateProvinceId == taxRate.StateProvinceId).ToList();+ //not found? use the default ones (ID == 0)+ if (!matchedByStore.Any())+ matchedByStore.AddRange(existingRates.Where(taxRate => string.IsNullOrEmpty(taxRate.StoreId)));- //not found? use the default ones (ID == 0)- if (!matchedByStateProvince.Any())- matchedByStateProvince.AddRange(matchedByStore.Where(taxRate => string.IsNullOrEmpty(taxRate.StateProvinceId)));+ //filter by state/province+ var matchedByStateProvince =+ matchedByStore.Where(taxRate => stateProvinceId == taxRate.StateProvinceId).ToList();- //filter by zip- var matchedByZip = matchedByStateProvince.Where(taxRate => (string.IsNullOrEmpty(zip) && string.IsNullOrEmpty(taxRate.Zip)) || zip.Equals(taxRate.Zip, StringComparison.OrdinalIgnoreCase)).ToList();- if (!matchedByZip.Any())- matchedByZip.AddRange(matchedByStateProvince.Where(taxRate => string.IsNullOrWhiteSpace(taxRate.Zip)));+ //not found? use the default ones (ID == 0)+ if (!matchedByStateProvince.Any())+ matchedByStateProvince.AddRange(matchedByStore.Where(taxRate =>+ string.IsNullOrEmpty(taxRate.StateProvinceId)));- if (matchedByZip.Any())- result.TaxRate = matchedByZip[0].Percentage;+ //filter by zip+ var matchedByZip = matchedByStateProvince.Where(taxRate =>+ (string.IsNullOrEmpty(zip) && string.IsNullOrEmpty(taxRate.Zip)) ||+ zip.Equals(taxRate.Zip, StringComparison.OrdinalIgnoreCase)).ToList();+ if (!matchedByZip.Any())+ matchedByZip.AddRange(matchedByStateProvince.Where(taxRate => string.IsNullOrWhiteSpace(taxRate.Zip)));- return result;- }+ if (matchedByZip.Any())+ result.TaxRate = matchedByZip[0].Percentage;+ return result;}-}+}\ No newline at end of filediff --git a/src/Plugins/Tax.CountryStateZip/CountryStateZipTaxSettings.cs b/src/Plugins/Tax.CountryStateZip/CountryStateZipTaxSettings.csindex 816236d1c..2ad3656bd 100644--- a/src/Plugins/Tax.CountryStateZip/CountryStateZipTaxSettings.cs+++ b/src/Plugins/Tax.CountryStateZip/CountryStateZipTaxSettings.cs@@ -1,9 +1,8 @@using Grand.Domain.Configuration;-namespace Tax.CountryStateZip+namespace Tax.CountryStateZip;++public class CountryStateZipTaxSettings : ISettings{- public class CountryStateZipTaxSettings : ISettings- {- public int DisplayOrder { get; set; }- }-}+ public int DisplayOrder { get; set; }+}\ No newline at end of filediff --git a/src/Plugins/Tax.CountryStateZip/Domain/TaxRate.cs b/src/Plugins/Tax.CountryStateZip/Domain/TaxRate.csindex 993b4b130..65bd7becf 100644--- a/src/Plugins/Tax.CountryStateZip/Domain/TaxRate.cs+++ b/src/Plugins/Tax.CountryStateZip/Domain/TaxRate.cs@@ -1,40 +1,39 @@using Grand.Domain;-namespace Tax.CountryStateZip.Domain+namespace Tax.CountryStateZip.Domain;++/// <summary>+/// Represents a tax rate+/// </summary>+public class TaxRate : BaseEntity{/// <summary>- /// Represents a tax rate+ /// Gets or sets the store identifier/// </summary>- public class TaxRate : BaseEntity- {- /// <summary>- /// Gets or sets the store identifier- /// </summary>- public string StoreId { get; set; }+ public string StoreId { get; set; }- /// <summary>- /// Gets or sets the tax category identifier- /// </summary>- public string TaxCategoryId { get; set; }+ /// <summary>+ /// Gets or sets the tax category identifier+ /// </summary>+ public string TaxCategoryId { get; set; }- /// <summary>- /// Gets or sets the country identifier- /// </summary>- public string CountryId { get; set; }+ /// <summary>+ /// Gets or sets the country identifier+ /// </summary>+ public string CountryId { get; set; }- /// <summary>- /// Gets or sets the state/province identifier- /// </summary>- public string StateProvinceId { get; set; }+ /// <summary>+ /// Gets or sets the state/province identifier+ /// </summary>+ public string StateProvinceId { get; set; }- /// <summary>- /// Gets or sets the zip- /// </summary>- public string Zip { get; set; }+ /// <summary>+ /// Gets or sets the zip+ /// </summary>+ public string Zip { get; set; }- /// <summary>- /// Gets or sets the percentage- /// </summary>- public double Percentage { get; set; }- }+ /// <summary>+ /// Gets or sets the percentage+ /// </summary>+ public double Percentage { get; set; }}\ No newline at end of filediff --git a/src/Plugins/Tax.CountryStateZip/Infrastructure/Cache/ModelCacheEventConsumer.cs b/src/Plugins/Tax.CountryStateZip/Infrastructure/Cache/ModelCacheEventConsumer.csindex a9be130ef..c46bec235 100644--- a/src/Plugins/Tax.CountryStateZip/Infrastructure/Cache/ModelCacheEventConsumer.cs+++ b/src/Plugins/Tax.CountryStateZip/Infrastructure/Cache/ModelCacheEventConsumer.cs@@ -3,42 +3,44 @@ using Grand.Infrastructure.Events;using MediatR;using Tax.CountryStateZip.Domain;-namespace Tax.CountryStateZip.Infrastructure.Cache+namespace Tax.CountryStateZip.Infrastructure.Cache;++/// <summary>+/// Model cache event consumer (used for caching of presentation layer models)+/// </summary>+public class ModelCacheEventConsumer :+ //tax rates+ INotificationHandler<EntityInserted<TaxRate>>,+ INotificationHandler<EntityUpdated<TaxRate>>,+ INotificationHandler<EntityDeleted<TaxRate>>{/// <summary>- /// Model cache event consumer (used for caching of presentation layer models)+ /// Key for caching/// </summary>- public class ModelCacheEventConsumer :- //tax rates- INotificationHandler<EntityInserted<TaxRate>>,- INotificationHandler<EntityUpdated<TaxRate>>,- INotificationHandler<EntityDeleted<TaxRate>>+ public const string ALL_TAX_RATES_MODEL_KEY = "Grand.plugins.tax.countrystatezip.all";++ public const string ALL_TAX_RATES_PATTERN_KEY = "Grand.plugins.tax.countrystatezip";++ private readonly ICacheBase _cacheBase;++ public ModelCacheEventConsumer(ICacheBase cacheBase)+ {+ _cacheBase = cacheBase;+ }++ public async Task Handle(EntityDeleted<TaxRate> eventMessage, CancellationToken cancellationToken)+ {+ await _cacheBase.RemoveByPrefix(ALL_TAX_RATES_PATTERN_KEY);+ }++ //tax rates+ public async Task Handle(EntityInserted<TaxRate> eventMessage, CancellationToken cancellationToken)+ {+ await _cacheBase.RemoveByPrefix(ALL_TAX_RATES_PATTERN_KEY);+ }++ public async Task Handle(EntityUpdated<TaxRate> eventMessage, CancellationToken cancellationToken){- /// <summary>- /// Key for caching- /// </summary>- public const string ALL_TAX_RATES_MODEL_KEY = "Grand.plugins.tax.countrystatezip.all";- public const string ALL_TAX_RATES_PATTERN_KEY = "Grand.plugins.tax.countrystatezip";-- private readonly ICacheBase _cacheBase;-- public ModelCacheEventConsumer(ICacheBase cacheBase)- {- this._cacheBase = cacheBase;- }-- //tax rates- public async Task Handle(EntityInserted<TaxRate> eventMessage, CancellationToken cancellationToken)- {- await _cacheBase.RemoveByPrefix(ALL_TAX_RATES_PATTERN_KEY);- }- public async Task Handle(EntityUpdated<TaxRate> eventMessage, CancellationToken cancellationToken)- {- await _cacheBase.RemoveByPrefix(ALL_TAX_RATES_PATTERN_KEY);- }- public async Task Handle(EntityDeleted<TaxRate> eventMessage, CancellationToken cancellationToken)- {- await _cacheBase.RemoveByPrefix(ALL_TAX_RATES_PATTERN_KEY);- }+ await _cacheBase.RemoveByPrefix(ALL_TAX_RATES_PATTERN_KEY);}}\ No newline at end of filediff --git a/src/Plugins/Tax.CountryStateZip/Infrastructure/Cache/TaxRateForCaching.cs b/src/Plugins/Tax.CountryStateZip/Infrastructure/Cache/TaxRateForCaching.csindex 7abce78f9..c051c7ccd 100644--- a/src/Plugins/Tax.CountryStateZip/Infrastructure/Cache/TaxRateForCaching.cs+++ b/src/Plugins/Tax.CountryStateZip/Infrastructure/Cache/TaxRateForCaching.cs@@ -1,16 +1,15 @@-namespace Tax.CountryStateZip.Infrastructure.Cache+namespace Tax.CountryStateZip.Infrastructure.Cache;++/// <summary>+/// Represents a tax rate+/// </summary>+public class TaxRateForCaching{- /// <summary>- /// Represents a tax rate- /// </summary>- public class TaxRateForCaching- {- public string Id { get; set; }- public string StoreId { get; set; }- public string TaxCategoryId { get; set; }- public string CountryId { get; set; }- public string StateProvinceId { get; set; }- public string Zip { get; set; }- public double Percentage { get; set; }- }+ public string Id { get; set; }+ public string StoreId { get; set; }+ public string TaxCategoryId { get; set; }+ public string CountryId { get; set; }+ public string StateProvinceId { get; set; }+ public string Zip { get; set; }+ public double Percentage { get; set; }}\ No newline at end of filediff --git a/src/Plugins/Tax.CountryStateZip/Models/TaxRateListModel.cs b/src/Plugins/Tax.CountryStateZip/Models/TaxRateListModel.csindex a99f5e33c..6bf3275d7 100644--- a/src/Plugins/Tax.CountryStateZip/Models/TaxRateListModel.cs+++ b/src/Plugins/Tax.CountryStateZip/Models/TaxRateListModel.cs@@ -2,28 +2,32 @@using Grand.Infrastructure.Models;using Microsoft.AspNetCore.Mvc.Rendering;-namespace Tax.CountryStateZip.Models+namespace Tax.CountryStateZip.Models;++public class TaxRateListModel : BaseModel{- public class TaxRateListModel : BaseModel- {- [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Store")]- public string AddStoreId { get; set; }- [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Country")]- public string AddCountryId { get; set; }- [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.StateProvince")]- public string AddStateProvinceId { get; set; }- [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Zip")]- public string AddZip { get; set; }- [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.TaxCategory")]- public string AddTaxCategoryId { get; set; }- [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Percentage")]- public double AddPercentage { get; set; }-- public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();- public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();- public IList<SelectListItem> AvailableStates { get; set; } = new List<SelectListItem>();- public IList<SelectListItem> AvailableTaxCategories { get; set; } = new List<SelectListItem>();-- public IList<TaxRateModel> TaxRates { get; set; } = new List<TaxRateModel>();- }+ [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Store")]+ public string AddStoreId { get; set; }++ [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Country")]+ public string AddCountryId { get; set; }++ [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.StateProvince")]+ public string AddStateProvinceId { get; set; }++ [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Zip")]+ public string AddZip { get; set; }++ [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.TaxCategory")]+ public string AddTaxCategoryId { get; set; }++ [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Percentage")]+ public double AddPercentage { get; set; }++ public IList<SelectListItem> AvailableStores { get; set; } = new List<SelectListItem>();+ public IList<SelectListItem> AvailableCountries { get; set; } = new List<SelectListItem>();+ public IList<SelectListItem> AvailableStates { get; set; } = new List<SelectListItem>();+ public IList<SelectListItem> AvailableTaxCategories { get; set; } = new List<SelectListItem>();++ public IList<TaxRateModel> TaxRates { get; set; } = new List<TaxRateModel>();}\ No newline at end of filediff --git a/src/Plugins/Tax.CountryStateZip/Models/TaxRateModel.cs b/src/Plugins/Tax.CountryStateZip/Models/TaxRateModel.csindex e426a7db7..dc5759926 100644--- a/src/Plugins/Tax.CountryStateZip/Models/TaxRateModel.cs+++ b/src/Plugins/Tax.CountryStateZip/Models/TaxRateModel.cs@@ -1,34 +1,37 @@using Grand.Infrastructure.ModelBinding;using Grand.Infrastructure.Models;-namespace Tax.CountryStateZip.Models+namespace Tax.CountryStateZip.Models;++public class TaxRateModel : BaseEntityModel{- public class TaxRateModel : BaseEntityModel- {- [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Store")]- public string StoreId { get; set; }- [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Store")]- public string StoreName { get; set; }-- [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.TaxCategory")]- public string TaxCategoryId { get; set; }- [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.TaxCategory")]- public string TaxCategoryName { get; set; }-- [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Country")]- public string CountryId { get; set; }- [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Country")]- public string CountryName { get; set; }-- [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.StateProvince")]- public string StateProvinceId { get; set; }- [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.StateProvince")]- public string StateProvinceName { get; set; }-- [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Zip")]- public string Zip { get; set; }-- [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Percentage")]- public double Percentage { get; set; }- }+ [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Store")]+ public string StoreId { get; set; }++ [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Store")]+ public string StoreName { get; set; }++ [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.TaxCategory")]+ public string TaxCategoryId { get; set; }++ [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.TaxCategory")]+ public string TaxCategoryName { get; set; }++ [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Country")]+ public string CountryId { get; set; }++ [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Country")]+ public string CountryName { get; set; }++ [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.StateProvince")]+ public string StateProvinceId { get; set; }++ [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.StateProvince")]+ public string StateProvinceName { get; set; }++ [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Zip")]+ public string Zip { get; set; }++ [GrandResourceDisplayName("Plugins.Tax.CountryStateZip.Fields.Percentage")]+ public double Percentage { get; set; }}\ No newline at end of filediff --git a/src/Plugins/Tax.CountryStateZip/Services/ITaxRateService.cs b/src/Plugins/Tax.CountryStateZip/Services/ITaxRateService.csindex 8a30f0e78..bd462a29e 100644--- a/src/Plugins/Tax.CountryStateZip/Services/ITaxRateService.cs+++ b/src/Plugins/Tax.CountryStateZip/Services/ITaxRateService.cs@@ -1,42 +1,41 @@using Grand.Domain;using Tax.CountryStateZip.Domain;-namespace Tax.CountryStateZip.Services+namespace Tax.CountryStateZip.Services;++/// <summary>+/// Tax rate service interface+/// </summary>+public interface ITaxRateService{/// <summary>- /// Tax rate service interface+ /// Deletes a tax rate/// </summary>- public interface ITaxRateService- {- /// <summary>- /// Deletes a tax rate- /// </summary>- /// <param name="taxRate">Tax rate</param>- Task DeleteTaxRate(TaxRate taxRate);+ /// <param name="taxRate">Tax rate</param>+ Task DeleteTaxRate(TaxRate taxRate);- /// <summary>- /// Gets all tax rates- /// </summary>- /// <returns>Tax rates</returns>- Task<IPagedList<TaxRate>> GetAllTaxRates(int pageIndex = 0, int pageSize = int.MaxValue);+ /// <summary>+ /// Gets all tax rates+ /// </summary>+ /// <returns>Tax rates</returns>+ Task<IPagedList<TaxRate>> GetAllTaxRates(int pageIndex = 0, int pageSize = int.MaxValue);- /// <summary>- /// Gets a tax rate- /// </summary>- /// <param name="taxRateId">Tax rate identifier</param>- /// <returns>Tax rate</returns>- Task<TaxRate> GetTaxRateById(string taxRateId);+ /// <summary>+ /// Gets a tax rate+ /// </summary>+ /// <param name="taxRateId">Tax rate identifier</param>+ /// <returns>Tax rate</returns>+ Task<TaxRate> GetTaxRateById(string taxRateId);- /// <summary>- /// Inserts a tax rate- /// </summary>- /// <param name="taxRate">Tax rate</param>- Task InsertTaxRate(TaxRate taxRate);+ /// <summary>+ /// Inserts a tax rate+ /// </summary>+ /// <param name="taxRate">Tax rate</param>+ Task InsertTaxRate(TaxRate taxRate);- /// <summary>- /// Updates the tax rate- /// </summary>- /// <param name="taxRate">Tax rate</param>- Task UpdateTaxRate(TaxRate taxRate);- }+ /// <summary>+ /// Updates the tax rate+ /// </summary>+ /// <param name="taxRate">Tax rate</param>+ Task UpdateTaxRate(TaxRate taxRate);}\ No newline at end of filediff --git a/src/Plugins/Tax.CountryStateZip/Services/TaxRateService.cs b/src/Plugins/Tax.CountryStateZip/Services/TaxRateService.csindex 7bcab898c..ddff99786 100644--- a/src/Plugins/Tax.CountryStateZip/Services/TaxRateService.cs+++ b/src/Plugins/Tax.CountryStateZip/Services/TaxRateService.cs@@ -1,124 +1,126 @@-using Grand.Domain;using Grand.Data;+using Grand.Domain;using Grand.Infrastructure.Caching;using Grand.Infrastructure.Extensions;using MediatR;using Tax.CountryStateZip.Domain;-namespace Tax.CountryStateZip.Services+namespace Tax.CountryStateZip.Services;++/// <summary>+/// Tax rate service+/// </summary>+public class TaxRateService : ITaxRateService{+ #region Ctor+/// <summary>- /// Tax rate service+ /// Ctor/// </summary>- public class TaxRateService : ITaxRateService+ /// <param name="mediator">Mediator</param>+ /// <param name="cacheManager">Cache manager</param>+ /// <param name="taxRateRepository">Tax rate repository</param>+ public TaxRateService(IMediator mediator,+ ICacheBase cacheManager,+ IRepository<TaxRate> taxRateRepository){- #region Constants- private const string TAXRATE_ALL_KEY = "Grand.taxrate.all-{0}-{1}";- private const string TAXRATE_PATTERN_KEY = "Grand.taxrate.";- #endregion-- #region Fields-- private readonly IMediator _mediator;- private readonly IRepository<TaxRate> _taxRateRepository;- private readonly ICacheBase _cacheBase;-- #endregion-- #region Ctor-- /// <summary>- /// Ctor- /// </summary>- /// <param name="mediator">Mediator</param>- /// <param name="cacheManager">Cache manager</param>- /// <param name="taxRateRepository">Tax rate repository</param>- public TaxRateService(IMediator mediator,- ICacheBase cacheManager,- IRepository<TaxRate> taxRateRepository)- {- _mediator = mediator;- _cacheBase = cacheManager;- _taxRateRepository = taxRateRepository;- }+ _mediator = mediator;+ _cacheBase = cacheManager;+ _taxRateRepository = taxRateRepository;+ }- #endregion+ #endregion- #region Methods+ #region Constants- /// <summary>- /// Deletes a tax rate- /// </summary>- /// <param name="taxRate">Tax rate</param>- public virtual async Task DeleteTaxRate(TaxRate taxRate)- {- ArgumentNullException.ThrowIfNull(taxRate);+ private const string TAXRATE_ALL_KEY = "Grand.taxrate.all-{0}-{1}";+ private const string TAXRATE_PATTERN_KEY = "Grand.taxrate.";- await _taxRateRepository.DeleteAsync(taxRate);+ #endregion- await _cacheBase.RemoveByPrefix(TAXRATE_PATTERN_KEY);+ #region Fields- //event notification- await _mediator.EntityDeleted(taxRate);- }+ private readonly IMediator _mediator;+ private readonly IRepository<TaxRate> _taxRateRepository;+ private readonly ICacheBase _cacheBase;- /// <summary>- /// Gets all tax rates- /// </summary>- /// <returns>Tax rates</returns>- public virtual async Task<IPagedList<TaxRate>> GetAllTaxRates(int pageIndex = 0, int pageSize = int.MaxValue)- {- var key = string.Format(TAXRATE_ALL_KEY, pageIndex, pageSize);- return await _cacheBase.GetAsync(key, async () =>- {- var query = from tr in _taxRateRepository.Table- orderby tr.StoreId, tr.CountryId, tr.StateProvinceId, tr.Zip, tr.TaxCategoryId- select tr;- return await Task.FromResult(new PagedList<TaxRate>(query, pageIndex, pageSize));- });- }-- /// <summary>- /// Gets a tax rate- /// </summary>- /// <param name="taxRateId">Tax rate identifier</param>- /// <returns>Tax rate</returns>- public virtual Task<TaxRate> GetTaxRateById(string taxRateId)- {- return _taxRateRepository.GetByIdAsync(taxRateId);- }-- /// <summary>- /// Inserts a tax rate- /// </summary>- /// <param name="taxRate">Tax rate</param>- public virtual async Task InsertTaxRate(TaxRate taxRate)- {- ArgumentNullException.ThrowIfNull(taxRate);+ #endregion- await _taxRateRepository.InsertAsync(taxRate);+ #region Methods- await _cacheBase.RemoveByPrefix(TAXRATE_PATTERN_KEY);+ /// <summary>+ /// Deletes a tax rate+ /// </summary>+ /// <param name="taxRate">Tax rate</param>+ public virtual async Task DeleteTaxRate(TaxRate taxRate)+ {+ ArgumentNullException.ThrowIfNull(taxRate);- //event notification- await _mediator.EntityInserted(taxRate);- }+ await _taxRateRepository.DeleteAsync(taxRate);- /// <summary>- /// Updates the tax rate- /// </summary>- /// <param name="taxRate">Tax rate</param>- public virtual async Task UpdateTaxRate(TaxRate taxRate)+ await _cacheBase.RemoveByPrefix(TAXRATE_PATTERN_KEY);++ //event notification+ await _mediator.EntityDeleted(taxRate);+ }++ /// <summary>+ /// Gets all tax rates+ /// </summary>+ /// <returns>Tax rates</returns>+ public virtual async Task<IPagedList<TaxRate>> GetAllTaxRates(int pageIndex = 0, int pageSize = int.MaxValue)+ {+ var key = string.Format(TAXRATE_ALL_KEY, pageIndex, pageSize);+ return await _cacheBase.GetAsync(key, async () =>{- ArgumentNullException.ThrowIfNull(taxRate);+ var query = from tr in _taxRateRepository.Table+ orderby tr.StoreId, tr.CountryId, tr.StateProvinceId, tr.Zip, tr.TaxCategoryId+ select tr;+ return await Task.FromResult(new PagedList<TaxRate>(query, pageIndex, pageSize));+ });+ }++ /// <summary>+ /// Gets a tax rate+ /// </summary>+ /// <param name="taxRateId">Tax rate identifier</param>+ /// <returns>Tax rate</returns>+ public virtual Task<TaxRate> GetTaxRateById(string taxRateId)+ {+ return _taxRateRepository.GetByIdAsync(taxRateId);+ }++ /// <summary>+ /// Inserts a tax rate+ /// </summary>+ /// <param name="taxRate">Tax rate</param>+ public virtual async Task InsertTaxRate(TaxRate taxRate)+ {+ ArgumentNullException.ThrowIfNull(taxRate);- await _taxRateRepository.UpdateAsync(taxRate);+ await _taxRateRepository.InsertAsync(taxRate);- await _cacheBase.RemoveByPrefix(TAXRATE_PATTERN_KEY);+ await _cacheBase.RemoveByPrefix(TAXRATE_PATTERN_KEY);- //event notification- await _mediator.EntityUpdated(taxRate);- }- #endregion+ //event notification+ await _mediator.EntityInserted(taxRate);}-}++ /// <summary>+ /// Updates the tax rate+ /// </summary>+ /// <param name="taxRate">Tax rate</param>+ public virtual async Task UpdateTaxRate(TaxRate taxRate)+ {+ ArgumentNullException.ThrowIfNull(taxRate);++ await _taxRateRepository.UpdateAsync(taxRate);++ await _cacheBase.RemoveByPrefix(TAXRATE_PATTERN_KEY);++ //event notification+ await _mediator.EntityUpdated(taxRate);+ }++ #endregion+}\ No newline at end of filediff --git a/src/Plugins/Tax.CountryStateZip/StartupApplication.cs b/src/Plugins/Tax.CountryStateZip/StartupApplication.csindex f67fcb22b..321f8ac6f 100644--- a/src/Plugins/Tax.CountryStateZip/StartupApplication.cs+++ b/src/Plugins/Tax.CountryStateZip/StartupApplication.cs@@ -6,21 +6,21 @@ using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;using Tax.CountryStateZip.Services;-namespace Tax.CountryStateZip+namespace Tax.CountryStateZip;++public class StartupApplication : IStartupApplication{- public class StartupApplication : IStartupApplication+ public void ConfigureServices(IServiceCollection services, IConfiguration configuration){- public void ConfigureServices(IServiceCollection services, IConfiguration configuration)- {- services.AddScoped<ITaxRateService, TaxRateService>();- services.AddScoped<ITaxProvider, CountryStateZipTaxProvider>();- }+ services.AddScoped<ITaxRateService, TaxRateService>();+ services.AddScoped<ITaxProvider, CountryStateZipTaxProvider>();+ }- public int Priority => 20;- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)- {+ public int Priority => 20;- }- public bool BeforeConfigure => false;+ public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)+ {}-}++ public bool BeforeConfigure => false;+}\ No newline at end of filediff --git a/src/Plugins/Tax.FixedRate/Areas/Admin/Controllers/TaxFixedRateController.cs b/src/Plugins/Tax.FixedRate/Areas/Admin/Controllers/TaxFixedRateController.csindex 48f748ed7..a439e8daa 100644--- a/src/Plugins/Tax.FixedRate/Areas/Admin/Controllers/TaxFixedRateController.cs+++ b/src/Plugins/Tax.FixedRate/Areas/Admin/Controllers/TaxFixedRateController.cs@@ -7,61 +7,61 @@ using Grand.Web.Common.Security.Authorization;using Microsoft.AspNetCore.Mvc;using Tax.FixedRate.Models;-namespace Tax.FixedRate.Areas.Admin.Controllers+namespace Tax.FixedRate.Areas.Admin.Controllers;++[PermissionAuthorize(PermissionSystemName.TaxSettings)]+public class TaxFixedRateController : BaseAdminPluginController{- [PermissionAuthorize(PermissionSystemName.TaxSettings)]- public class TaxFixedRateController : BaseAdminPluginController- {- private readonly ITaxCategoryService _taxCategoryService;- private readonly ISettingService _settingService;+ private readonly ISettingService _settingService;+ private readonly ITaxCategoryService _taxCategoryService;- public TaxFixedRateController(ITaxCategoryService taxCategoryService, ISettingService settingService)- {- _taxCategoryService = taxCategoryService;- _settingService = settingService;- }+ public TaxFixedRateController(ITaxCategoryService taxCategoryService, ISettingService settingService)+ {+ _taxCategoryService = taxCategoryService;+ _settingService = settingService;+ }- public IActionResult Configure()- {- return View();- }+ public IActionResult Configure()+ {+ return View();+ }- [HttpPost]- public async Task<IActionResult> Configure(DataSourceRequest command)- {- var taxRateModels = new List<FixedTaxRateModel>();- foreach (var taxCategory in await _taxCategoryService.GetAllTaxCategories())- taxRateModels.Add(new FixedTaxRateModel {- TaxCategoryId = taxCategory.Id,- TaxCategoryName = taxCategory.Name,- Rate = GetTaxRate(taxCategory.Id)- });+ [HttpPost]+ public async Task<IActionResult> Configure(DataSourceRequest command)+ {+ var taxRateModels = new List<FixedTaxRateModel>();+ foreach (var taxCategory in await _taxCategoryService.GetAllTaxCategories())+ taxRateModels.Add(new FixedTaxRateModel {+ TaxCategoryId = taxCategory.Id,+ TaxCategoryName = taxCategory.Name,+ Rate = GetTaxRate(taxCategory.Id)+ });- var gridModel = new DataSourceResult {- Data = taxRateModels,- Total = taxRateModels.Count- };- return Json(gridModel);- }+ var gridModel = new DataSourceResult {+ Data = taxRateModels,+ Total = taxRateModels.Count+ };+ return Json(gridModel);+ }- [HttpPost]- public async Task<IActionResult> TaxRateUpdate(FixedTaxRateModel model)- {- var taxCategoryId = model.TaxCategoryId;- var rate = model.Rate;+ [HttpPost]+ public async Task<IActionResult> TaxRateUpdate(FixedTaxRateModel model)+ {+ var taxCategoryId = model.TaxCategoryId;+ var rate = model.Rate;- await _settingService.SetSetting($"Tax.TaxProvider.FixedRate.TaxCategoryId{taxCategoryId}", new FixedTaxRate { Rate = rate });+ await _settingService.SetSetting($"Tax.TaxProvider.FixedRate.TaxCategoryId{taxCategoryId}",+ new FixedTaxRate { Rate = rate });- return new JsonResult("");- }+ return new JsonResult("");+ }- [NonAction]- private double GetTaxRate(string taxCategoryId)- {- var rate = _settingService.GetSettingByKey<FixedTaxRate>(- $"Tax.TaxProvider.FixedRate.TaxCategoryId{taxCategoryId}")?.Rate;- return rate ?? 0;- }+ [NonAction]+ private double GetTaxRate(string taxCategoryId)+ {+ var rate = _settingService.GetSettingByKey<FixedTaxRate>(+ $"Tax.TaxProvider.FixedRate.TaxCategoryId{taxCategoryId}")?.Rate;+ return rate ?? 0;}-}+}\ No newline at end of filediff --git a/src/Plugins/Tax.FixedRate/Areas/Admin/Views/TaxFixedRate/Configure.cshtml b/src/Plugins/Tax.FixedRate/Areas/Admin/Views/TaxFixedRate/Configure.cshtmlindex 5645dff78..99d422b75 100644--- a/src/Plugins/Tax.FixedRate/Areas/Admin/Views/TaxFixedRate/Configure.cshtml+++ b/src/Plugins/Tax.FixedRate/Areas/Admin/Views/TaxFixedRate/Configure.cshtml@@ -1,7 +1,7 @@@{Layout = "_ConfigurePlugin";}-<input id="active-menu-item" type="hidden" value="/Admin/Tax/Providers" />+<input id="active-menu-item" type="hidden" value="/Admin/Tax/Providers"/><div id="tax-categories-grid"></div><script>$(document).ready(function () {diff --git a/src/Plugins/Tax.FixedRate/Areas/Admin/Views/_ViewImports.cshtml b/src/Plugins/Tax.FixedRate/Areas/Admin/Views/_ViewImports.cshtmlindex 2fb08c043..fb3b84aa9 100644--- a/src/Plugins/Tax.FixedRate/Areas/Admin/Views/_ViewImports.cshtml+++ b/src/Plugins/Tax.FixedRate/Areas/Admin/Views/_ViewImports.cshtml@@ -4,5 +4,6 @@@using Microsoft.AspNetCore.Mvc.ViewFeatures@using Grand.Infrastructure.Extensions+@using Grand.Web.Common.Localization-@inject Grand.Web.Common.Localization.LocService Loc+@inject LocService Loc\ No newline at end of filediff --git a/src/Plugins/Tax.FixedRate/FixedRateTaxDefaults.cs b/src/Plugins/Tax.FixedRate/FixedRateTaxDefaults.csindex f6615eb9c..9ca54171a 100644--- a/src/Plugins/Tax.FixedRate/FixedRateTaxDefaults.cs+++ b/src/Plugins/Tax.FixedRate/FixedRateTaxDefaults.cs@@ -1,9 +1,8 @@-namespace Tax.FixedRate+namespace Tax.FixedRate;++public static class FixedRateTaxDefaults{- public static class FixedRateTaxDefaults- {- public const string ProviderSystemName = "Tax.FixedRate";- public const string FriendlyName = "Tax.FixedRate.FriendlyName";- public const string ConfigurationUrl = "../TaxFixedRate/Configure";- }-}+ public const string ProviderSystemName = "Tax.FixedRate";+ public const string FriendlyName = "Tax.FixedRate.FriendlyName";+ public const string ConfigurationUrl = "../TaxFixedRate/Configure";+}\ No newline at end of filediff --git a/src/Plugins/Tax.FixedRate/FixedRateTaxPlugin.cs b/src/Plugins/Tax.FixedRate/FixedRateTaxPlugin.csindex 676b6578b..751ab9f7a 100644--- a/src/Plugins/Tax.FixedRate/FixedRateTaxPlugin.cs+++ b/src/Plugins/Tax.FixedRate/FixedRateTaxPlugin.cs@@ -2,51 +2,55 @@using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Infrastructure.Plugins;-namespace Tax.FixedRate+namespace Tax.FixedRate;++/// <summary>+/// Fixed rate tax provider+/// </summary>+public class FixedRateTaxPlugin : BasePlugin, IPlugin{+ private readonly ILanguageService _languageService;+ private readonly ITranslationService _translationService;++ public FixedRateTaxPlugin(ITranslationService translationService, ILanguageService languageService)+ {+ _translationService = translationService;+ _languageService = languageService;+ }++/// <summary>- /// Fixed rate tax provider+ /// Gets a configuration page URL/// </summary>- public class FixedRateTaxPlugin : BasePlugin, IPlugin+ public override string ConfigurationUrl(){- private readonly ITranslationService _translationService;- private readonly ILanguageService _languageService;-- public FixedRateTaxPlugin(ITranslationService translationService, ILanguageService languageService)- {- _translationService = translationService;- _languageService = languageService;- }--- /// <summary>- /// Gets a configuration page URL- /// </summary>- public override string ConfigurationUrl()- {- return FixedRateTaxDefaults.ConfigurationUrl;- }-- public override async Task Install()- {- //locales- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Tax.FixedRate.FriendlyName", "Tax by fixed rate");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Tax.FixedRate.Fields.TaxCategoryName", "Tax category");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Plugins.Tax.FixedRate.Fields.Rate", "Rate");-- await base.Install();- }-- /// <summary>- /// Uninstall plugin- /// </summary>- public override async Task Uninstall()- {- //locales- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Tax.FixedRate.Fields.TaxCategoryName");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Plugins.Tax.FixedRate.Fields.Rate");-- await base.Uninstall();- }+ return FixedRateTaxDefaults.ConfigurationUrl;+ }++ public override async Task Install()+ {+ //locales+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Tax.FixedRate.FriendlyName", "Tax by fixed rate");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Tax.FixedRate.Fields.TaxCategoryName", "Tax category");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Plugins.Tax.FixedRate.Fields.Rate", "Rate");++ await base.Install();+ }++ /// <summary>+ /// Uninstall plugin+ /// </summary>+ public override async Task Uninstall()+ {+ //locales+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Tax.FixedRate.Fields.TaxCategoryName");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Plugins.Tax.FixedRate.Fields.Rate");++ await base.Uninstall();}-}+}\ No newline at end of filediff --git a/src/Plugins/Tax.FixedRate/FixedRateTaxProvider.cs b/src/Plugins/Tax.FixedRate/FixedRateTaxProvider.csindex 556695dda..8bf65a4e4 100644--- a/src/Plugins/Tax.FixedRate/FixedRateTaxProvider.cs+++ b/src/Plugins/Tax.FixedRate/FixedRateTaxProvider.cs@@ -1,59 +1,56 @@using Grand.Business.Core.Interfaces.Catalog.Tax;-using Grand.Business.Core.Utilities.Catalog;using Grand.Business.Core.Interfaces.Common.Configuration;using Grand.Business.Core.Interfaces.Common.Localization;+using Grand.Business.Core.Utilities.Catalog;using Tax.FixedRate.Models;-namespace Tax.FixedRate+namespace Tax.FixedRate;++public class FixedRateTaxProvider : ITaxProvider{- public class FixedRateTaxProvider : ITaxProvider+ private readonly ISettingService _settingService;+ private readonly ITranslationService _translationService;++ public FixedRateTaxProvider(ISettingService settingService, ITranslationService translationService){- private readonly ISettingService _settingService;- private readonly ITranslationService _translationService;-- public FixedRateTaxProvider(ISettingService settingService, ITranslationService translationService)- {- _settingService = settingService;- _translationService = translationService;- }-- public string ConfigurationUrl => FixedRateTaxDefaults.ConfigurationUrl;-- public string SystemName => FixedRateTaxDefaults.ProviderSystemName;-- public string FriendlyName => _translationService.GetResource(FixedRateTaxDefaults.FriendlyName);-- public int Priority => 0;-- public IList<string> LimitedToStores => new List<string>();-- public IList<string> LimitedToGroups => new List<string>();-- /// <summary>- /// Gets tax rate- /// </summary>- /// <param name="calculateTaxRequest">Tax calculation request</param>- /// <returns>Tax</returns>- public Task<TaxResult> GetTaxRate(TaxRequest calculateTaxRequest)- {- var result = new TaxResult- {- TaxRate = GetTaxRate(calculateTaxRequest.TaxCategoryId)- };- return Task.FromResult(result);- }-- /// <summary>- /// Gets a tax rate- /// </summary>- /// <param name="taxCategoryId">The tax category identifier</param>- /// <returns>Tax rate</returns>- private double GetTaxRate(string taxCategoryId)- {- var rate = _settingService.GetSettingByKey<FixedTaxRate>(- $"Tax.TaxProvider.FixedRate.TaxCategoryId{taxCategoryId}")?.Rate;- return rate ?? 0;- }+ _settingService = settingService;+ _translationService = translationService;+ }++ public string ConfigurationUrl => FixedRateTaxDefaults.ConfigurationUrl;++ public string SystemName => FixedRateTaxDefaults.ProviderSystemName;++ public string FriendlyName => _translationService.GetResource(FixedRateTaxDefaults.FriendlyName);+ public int Priority => 0;++ public IList<string> LimitedToStores => new List<string>();++ public IList<string> LimitedToGroups => new List<string>();++ /// <summary>+ /// Gets tax rate+ /// </summary>+ /// <param name="calculateTaxRequest">Tax calculation request</param>+ /// <returns>Tax</returns>+ public Task<TaxResult> GetTaxRate(TaxRequest calculateTaxRequest)+ {+ var result = new TaxResult {+ TaxRate = GetTaxRate(calculateTaxRequest.TaxCategoryId)+ };+ return Task.FromResult(result);+ }++ /// <summary>+ /// Gets a tax rate+ /// </summary>+ /// <param name="taxCategoryId">The tax category identifier</param>+ /// <returns>Tax rate</returns>+ private double GetTaxRate(string taxCategoryId)+ {+ var rate = _settingService.GetSettingByKey<FixedTaxRate>(+ $"Tax.TaxProvider.FixedRate.TaxCategoryId{taxCategoryId}")?.Rate;+ return rate ?? 0;}-}+}\ No newline at end of filediff --git a/src/Plugins/Tax.FixedRate/Models/FixedTaxRate.cs b/src/Plugins/Tax.FixedRate/Models/FixedTaxRate.csindex 599333a20..d14449bab 100644--- a/src/Plugins/Tax.FixedRate/Models/FixedTaxRate.cs+++ b/src/Plugins/Tax.FixedRate/Models/FixedTaxRate.cs@@ -1,7 +1,6 @@-namespace Tax.FixedRate.Models+namespace Tax.FixedRate.Models;++public class FixedTaxRate{- public class FixedTaxRate- {- public double Rate { get; set; }- }-}+ public double Rate { get; set; }+}\ No newline at end of filediff --git a/src/Plugins/Tax.FixedRate/Models/FixedTaxRateModel.cs b/src/Plugins/Tax.FixedRate/Models/FixedTaxRateModel.csindex 53a52beeb..0df58e2f8 100644--- a/src/Plugins/Tax.FixedRate/Models/FixedTaxRateModel.cs+++ b/src/Plugins/Tax.FixedRate/Models/FixedTaxRateModel.cs@@ -1,15 +1,14 @@using Grand.Infrastructure.ModelBinding;-namespace Tax.FixedRate.Models+namespace Tax.FixedRate.Models;++public class FixedTaxRateModel{- public class FixedTaxRateModel- {- public string TaxCategoryId { get; set; }+ public string TaxCategoryId { get; set; }- [GrandResourceDisplayName("Plugins.Tax.FixedRate.Fields.TaxCategoryName")]- public string TaxCategoryName { get; set; }+ [GrandResourceDisplayName("Plugins.Tax.FixedRate.Fields.TaxCategoryName")]+ public string TaxCategoryName { get; set; }- [GrandResourceDisplayName("Plugins.Tax.FixedRate.Fields.Rate")]- public double Rate { get; set; }- }+ [GrandResourceDisplayName("Plugins.Tax.FixedRate.Fields.Rate")]+ public double Rate { get; set; }}\ No newline at end of filediff --git a/src/Plugins/Tax.FixedRate/StartupApplication.cs b/src/Plugins/Tax.FixedRate/StartupApplication.csindex 962800ba9..d803b83e0 100644--- a/src/Plugins/Tax.FixedRate/StartupApplication.cs+++ b/src/Plugins/Tax.FixedRate/StartupApplication.cs@@ -5,21 +5,20 @@ using Microsoft.AspNetCore.Hosting;using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;-namespace Tax.FixedRate+namespace Tax.FixedRate;++public class StartupApplication : IStartupApplication{- public class StartupApplication : IStartupApplication+ public void ConfigureServices(IServiceCollection services, IConfiguration configuration){- public void ConfigureServices(IServiceCollection services, IConfiguration configuration)- {- services.AddScoped<ITaxProvider, FixedRateTaxProvider>();- }+ services.AddScoped<ITaxProvider, FixedRateTaxProvider>();+ }- public int Priority => 10;- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)- {+ public int Priority => 10;- }- public bool BeforeConfigure => false;+ public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)+ {}-}+ public bool BeforeConfigure => false;+}\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/ModernThemePlugin.cs b/src/Plugins/Theme.Modern/ModernThemePlugin.csindex a4ad7e1b5..f64af32ac 100644--- a/src/Plugins/Theme.Modern/ModernThemePlugin.cs+++ b/src/Plugins/Theme.Modern/ModernThemePlugin.cs@@ -1,14 +1,10 @@using Grand.Infrastructure.Plugins;-namespace Theme.Modern+namespace Theme.Modern;++/// <summary>+/// Plugin+/// </summary>+public class MinimalThemePlugin : BasePlugin, IPlugin{- /// <summary>- /// Plugin- /// </summary>- public class MinimalThemePlugin : BasePlugin, IPlugin- {- public MinimalThemePlugin()- {- }- }}\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/ModernThemeView.cs b/src/Plugins/Theme.Modern/ModernThemeView.csindex e188bce22..aa3f4bcb1 100644--- a/src/Plugins/Theme.Modern/ModernThemeView.cs+++ b/src/Plugins/Theme.Modern/ModernThemeView.cs@@ -2,12 +2,13 @@namespace Theme.Modern;-public class ModernThemeView: IThemeView+public class ModernThemeView : IThemeView{public string AreaName => "";public string ThemeName => "Modern";-- public ThemeInfo ThemeInfo => new ("Modern theme (beta)", "~/Plugins/Theme.Modern/Content/theme.jpg", "Minimal theme (beta)", false);++ public ThemeInfo ThemeInfo => new("Modern theme (beta)", "~/Plugins/Theme.Modern/Content/theme.jpg",+ "Minimal theme (beta)", false);public IEnumerable<string> GetViewLocations(){diff --git a/src/Plugins/Theme.Modern/StartupApplication.cs b/src/Plugins/Theme.Modern/StartupApplication.csindex bcbf590d7..a362b7cd4 100644--- a/src/Plugins/Theme.Modern/StartupApplication.cs+++ b/src/Plugins/Theme.Modern/StartupApplication.cs@@ -19,6 +19,6 @@ public class StartupApplication : IStartupApplicationpublic void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment){}-+public bool BeforeConfigure => false;}\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/AddressAdd.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/AddressAdd.cshtmlindex b5e1cf3a1..e879c3049 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/AddressAdd.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/AddressAdd.cshtml@@ -6,15 +6,19 @@//titlepagebuilder.AddTitleParts(Loc["Title.Account"]);}+@section left{@await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = AccountNavigationEnum.Addresses })}+<vc:widget widget-zone="customer-address-add-before" additional-data="@Model"></vc:widget><validation-observer v-slot="{ handleSubmit }"><form asp-route="CustomerAddressAdd" method="post" ref="form" v-on:submit.prevent="handleSubmit(formSubmit)"><div class="page account-page address-edit-page pl-lg-3 mb-3 pt-lg-0 pt-3">- <h1 class="generalTitle h2"><div>@Loc["Account.CustomerAddresses.AddNew"]</div></h1>+ <h1 class="generalTitle h2">+ <div>@Loc["Account.CustomerAddresses.AddNew"]</div>+ </h1><a class="left-side-toggler mb-3" onclick="sideToggle()"><div class="inner"><span></span>@@ -34,11 +38,11 @@HtmlFieldPrefix = "Address"}};- <partial name="Partials/CreateOrUpdateAddress" model="Model.Address" view-data="dataDictAddress" />+ <partial name="Partials/CreateOrUpdateAddress" model="Model.Address" view-data="dataDictAddress"/>}<vc:widget widget-zone="customer-address-add-form" additional-data="@Model"></vc:widget><div class="buttons generalMarginSupporter mt-1 mb-1">- <input type="submit" class="btn btn-info save-address-button" value="@Loc["Common.Save"]" />+ <input type="submit" class="btn btn-info save-address-button" value="@Loc["Common.Save"]"/></div></div></form>diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/AddressEdit.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/AddressEdit.cshtmlindex d926e202f..d360ef9d0 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/AddressEdit.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/AddressEdit.cshtml@@ -6,15 +6,19 @@//titlepagebuilder.AddTitleParts(Loc["Title.Account"]);}+@section left{@await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = AccountNavigationEnum.Addresses })}+<vc:widget widget-zone="customer-address-edit-before" additional-data="@Model"></vc:widget><validation-observer v-slot="{ handleSubmit }"><form asp-route="CustomerAddressEdit" method="post" ref="form" v-on:submit.prevent="handleSubmit(formSubmit)"><div class="page account-page address-edit-page pl-lg-3 mb-3 pt-lg-0 pt-3">- <h1 class="h2 generalTitle"><div>@Loc["Account.CustomerAddresses.Edit"]</div></h1>+ <h1 class="h2 generalTitle">+ <div>@Loc["Account.CustomerAddresses.Edit"]</div>+ </h1><a class="left-side-toggler mb-3" onclick="sideToggle()"><div class="inner"><span></span>@@ -34,11 +38,11 @@HtmlFieldPrefix = "Address"}};- <partial name="Partials/CreateOrUpdateAddress" model="Model.Address" view-data="dataDictAddress" />+ <partial name="Partials/CreateOrUpdateAddress" model="Model.Address" view-data="dataDictAddress"/>}<vc:widget widget-zone="customer-address-edit-form" additional-data="@Model"></vc:widget><div class="buttons generalMarginSupporter">- <input type="submit" class="btn btn-info save-address-button" value="@Loc["Common.Save"]" />+ <input type="submit" class="btn btn-info save-address-button" value="@Loc["Common.Save"]"/></div></div></form>diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/Addresses.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/Addresses.cshtmlindex 6ad92a4bb..8d55e8cc7 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/Addresses.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/Addresses.cshtml@@ -6,13 +6,17 @@//titlepagebuilder.AddTitleParts(Loc["Title.Account"]);}+@section left{@await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = AccountNavigationEnum.Addresses })}+<div class="page account-page address-list-page pl-lg-3 pt-lg-0 pt-3">@Html.AntiForgeryToken()- <h1 class="h2 generalTitle"><div>@Loc["Account.CustomerAddresses"]</div></h1>+ <h1 class="h2 generalTitle">+ <div>@Loc["Account.CustomerAddresses"]</div>+ </h1><a class="left-side-toggler mb-3" onclick="sideToggle()"><div class="inner"><span></span>@@ -33,116 +37,125 @@<div class="address-list table-responsive"><table class="table table-bordered hover-table"><thead>- <tr>- <th scope="col">@Loc["Address.Fields.Name"]</th>- <th scope="col">@Loc["Address.Fields.Address"]</th>- <th scope="col"></th>- </tr>+ <tr>+ <th scope="col">@Loc["Address.Fields.Name"]</th>+ <th scope="col">@Loc["Address.Fields.Address"]</th>+ <th scope="col"></th>+ </tr></thead><tbody>- @for (int i = 0; i < Model.Addresses.Count; i++)- {- var address = Model.Addresses[i];- <tr>- <td>- <h3 class="h5 mb-0">- @address.FirstName @address.LastName- </h3>- @address.Email- </td>- <td>- <ul class="m-0 p-0">- @if (address.PhoneEnabled)- {- <li class="phone">- <label class="mb-0"><strong>@Loc["Address.Fields.PhoneNumber"]:</strong></label>- @address.PhoneNumber- </li>- }- @if (address.FaxEnabled)- {- <li class="fax">- <label class="mb-0"><strong>@Loc["Address.Fields.FaxNumber"]:</strong></label>- @address.FaxNumber- </li>- }- @if (address.CompanyEnabled && !String.IsNullOrEmpty(address.Company))- {- <li class="company">@address.Company</li>- }- @if (address.VatNumberEnabled && !String.IsNullOrEmpty(address.VatNumber))- {- <li class="vatnumber">@address.VatNumber</li>- }- @if (address.StreetAddressEnabled)- {- <li class="address1">- @address.Address1- </li>- }- @if (address.StreetAddress2Enabled && !String.IsNullOrEmpty(address.Address2))- {- <li class="address2">- @address.Address2- </li>- }- @if (address.CityEnabled || address.StateProvinceEnabled || address.ZipPostalCodeEnabled)+ @for (var i = 0; i < Model.Addresses.Count; i++)+ {+ var address = Model.Addresses[i];+ <tr>+ <td>+ <h3 class="h5 mb-0">+ @address.FirstName @address.LastName+ </h3>+ @address.Email+ </td>+ <td>+ <ul class="m-0 p-0">+ @if (address.PhoneEnabled)+ {+ <li class="phone">+ <label class="mb-0">+ <strong>@Loc["Address.Fields.PhoneNumber"]:</strong>+ </label>+ @address.PhoneNumber+ </li>+ }+ @if (address.FaxEnabled)+ {+ <li class="fax">+ <label class="mb-0">+ <strong>@Loc["Address.Fields.FaxNumber"]:</strong>+ </label>+ @address.FaxNumber+ </li>+ }+ @if (address.CompanyEnabled && !string.IsNullOrEmpty(address.Company))+ {+ <li class="company">@address.Company</li>+ }+ @if (address.VatNumberEnabled && !string.IsNullOrEmpty(address.VatNumber))+ {+ <li class="vatnumber">@address.VatNumber</li>+ }+ @if (address.StreetAddressEnabled)+ {+ <li class="address1">+ @address.Address1+ </li>+ }+ @if (address.StreetAddress2Enabled && !string.IsNullOrEmpty(address.Address2))+ {+ <li class="address2">+ @address.Address2+ </li>+ }+ @if (address.CityEnabled || address.StateProvinceEnabled || address.ZipPostalCodeEnabled)+ {+ var cityStateZip = "";+ if (address.CityEnabled){- var cityStateZip = "";- if (address.CityEnabled)+ cityStateZip = address.City;+ if (address.StateProvinceEnabled || address.ZipPostalCodeEnabled){- cityStateZip = address.City;- if (address.StateProvinceEnabled || address.ZipPostalCodeEnabled)- {- cityStateZip += ",";- }+ cityStateZip += ",";}- if (address.StateProvinceEnabled)- {- if (!String.IsNullOrEmpty(cityStateZip))- {- cityStateZip += " ";- }- cityStateZip += address.StateProvinceName;- }- if (address.ZipPostalCodeEnabled)- {- if (!String.IsNullOrEmpty(cityStateZip))- {- cityStateZip += " ";- }- cityStateZip += address.ZipPostalCode;- }- <li class="city-state-zip">- @cityStateZip- </li>}- @if (address.CountryEnabled && !String.IsNullOrEmpty(address.CountryName))++ if (address.StateProvinceEnabled){- <li class="country">- @address.CountryName- </li>+ if (!string.IsNullOrEmpty(cityStateZip))+ {+ cityStateZip += " ";+ }++ cityStateZip += address.StateProvinceName;}- @if (!String.IsNullOrEmpty(address.FormattedCustomAddressAttributes))++ if (address.ZipPostalCodeEnabled){- <li class="custom-attributes-view">- @Html.Raw(address.FormattedCustomAddressAttributes)- </li>+ if (!string.IsNullOrEmpty(cityStateZip))+ {+ cityStateZip += " ";+ }++ cityStateZip += address.ZipPostalCode;}- </ul>- </td>- <td>- <div class="buttons d-flex flex-column">- <button class="btn btn-secondary edit-address-button" onclick="location.href='@(Url.RouteUrl("CustomerAddressEdit", new { addressId = address.Id }))'">- @Loc["Common.Edit"]- </button>- <button class="btn btn-danger delete-address-button mt-1" onclick="deletecustomeraddress('@(address.Id)')">- @Loc["Common.Delete"]- </button>- </div>- </td>- </tr>- }++ <li class="city-state-zip">+ @cityStateZip+ </li>+ }+ @if (address.CountryEnabled && !string.IsNullOrEmpty(address.CountryName))+ {+ <li class="country">+ @address.CountryName+ </li>+ }+ @if (!string.IsNullOrEmpty(address.FormattedCustomAddressAttributes))+ {+ <li class="custom-attributes-view">+ @Html.Raw(address.FormattedCustomAddressAttributes)+ </li>+ }+ </ul>+ </td>+ <td>+ <div class="buttons d-flex flex-column">+ <button class="btn btn-secondary edit-address-button" onclick="location.href='@(Url.RouteUrl("CustomerAddressEdit", new { addressId = address.Id }))'">+ @Loc["Common.Edit"]+ </button>+ <button class="btn btn-danger delete-address-button mt-1" onclick="deletecustomeraddress('@(address.Id)')">+ @Loc["Common.Delete"]+ </button>+ </div>+ </td>+ </tr>+ }</tbody></table></div>diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/Auctions.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/Auctions.cshtmlindex fd5d3c7e3..b1a5aca39 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/Auctions.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/Auctions.cshtml@@ -5,13 +5,16 @@//titlepagebuilder.AddTitleParts(Loc["Title.Auctions"]);}+@section left{@await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = AccountNavigationEnum.Auctions })}<div class="page account-page auction-list-page pl-lg-3 pt-3 pt-lg-0">- <h1 class="h2 generalTitle"><div>@Loc["Account.CustomerAuctions"]</div></h1>+ <h1 class="h2 generalTitle">+ <div>@Loc["Account.CustomerAuctions"]</div>+ </h1><a class="left-side-toggler mb-3" onclick="sideToggle()"><div class="inner"><span></span>@@ -32,50 +35,63 @@<div id="auction-table-ongoing" class="table-responsive"><table class="table"><thead role="rowgroup">- <tr role="row">- <th role="columnheader"><div>@Loc["Account.CustomerAuctions.ProductName"]</div></th>- <th role="columnheader"><div>@Loc["Account.CustomerAuctions.Status"]</div></th>- <th role="columnheader"><div>@Loc["Account.CustomerAuctions.Highestbid"]</div></th>- <th role="columnheader"><div>@Loc["Account.CustomerAuctions.AuctionEndTime"]</div></th>- </tr>+ <tr role="row">+ <th role="columnheader">+ <div>@Loc["Account.CustomerAuctions.ProductName"]</div>+ </th>+ <th role="columnheader">+ <div>@Loc["Account.CustomerAuctions.Status"]</div>+ </th>+ <th role="columnheader">+ <div>@Loc["Account.CustomerAuctions.Highestbid"]</div>+ </th>+ <th role="columnheader">+ <div>@Loc["Account.CustomerAuctions.AuctionEndTime"]</div>+ </th>+ </tr></thead><tbody role="rowgroup">- @{- var ongoing = Model.ProductBidList.Where(x => !x.Ended);- }- @foreach (var item in ongoing)- {- <tr role="row">- <td>- <div><a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })">@item.ProductName</a></div>- </td>- @if (item.HighestBidder)- {- <td>- <div>- <span class="text-success">@Loc["Account.CustomerAuctions.Status.HighestBidder"]</span>- </div>- </td>- }- else- {- <td>- <div>- <span class="text-danger">@Loc["Account.CustomerAuctions.Status.Outbid"]</span>- </div>- </td>- }+ @{+ var ongoing = Model.ProductBidList.Where(x => !x.Ended);+ }+ @foreach (var item in ongoing)+ {+ <tr role="row">+ <td>+ <div>+ <a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })">@item.ProductName</a>+ </div>+ </td>+ @if (item.HighestBidder)+ {<td><div>- @item.CurrentBidAmount @if (item.CurrentBidAmountValue > item.BidAmountValue)- {<small>(@item.BidAmount)</small>}+ <span class="text-success">@Loc["Account.CustomerAuctions.Status.HighestBidder"]</span></div></td>+ }+ else+ {<td>- <div>@item.EndBidDate</div>+ <div>+ <span class="text-danger">@Loc["Account.CustomerAuctions.Status.Outbid"]</span>+ </div></td>- </tr>- }+ }+ <td>+ <div>+ @item.CurrentBidAmount+ @if (item.CurrentBidAmountValue > item.BidAmountValue)+ {+ <small>(@item.BidAmount)</small>+ }+ </div>+ </td>+ <td>+ <div>@item.EndBidDate</div>+ </td>+ </tr>+ }</tbody></table></div>@@ -90,55 +106,67 @@<b-tab title="@Loc["Account.Auctions.Tab.Ended"]">@if (Model.ProductBidList.Any(x => x.Ended)){-<div id="auction-table-ended" class="table-responsive"><table class="table"><thead role="rowgroup">- <tr role="row">- <th role="columnheader"><div>@Loc["Account.CustomerAuctions.ProductName"]</div></th>- <th role="columnheader"><div>@Loc["Account.CustomerAuctions.Status"]</div></th>- <th role="columnheader"><div>@Loc["Account.CustomerAuctions.Highestbid"]</div></th>- <th role="columnheader"><div>@Loc["Account.CustomerAuctions.AuctionEndTime"]</div></th>- </tr>+ <tr role="row">+ <th role="columnheader">+ <div>@Loc["Account.CustomerAuctions.ProductName"]</div>+ </th>+ <th role="columnheader">+ <div>@Loc["Account.CustomerAuctions.Status"]</div>+ </th>+ <th role="columnheader">+ <div>@Loc["Account.CustomerAuctions.Highestbid"]</div>+ </th>+ <th role="columnheader">+ <div>@Loc["Account.CustomerAuctions.AuctionEndTime"]</div>+ </th>+ </tr></thead><tbody role="rowgroup">- @{- var ended = Model.ProductBidList.Where(x => x.Ended);- }+ @{+ var ended = Model.ProductBidList.Where(x => x.Ended);+ }- @foreach (var item in ended)- {- <tr role="row">- <td>- <div><a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })">@item.ProductName</a></div>- </td>- @if (item.HighestBidder)- {- <td>- <div>- <span class="text-success">@Loc["Account.CustomerAuctions.Status.HighestBidder"]</span>- </div>- </td>- }- else- {- <td>- <div>- <span class="text-danger">@Loc["Account.CustomerAuctions.Status.Outbid"]</span>- </div>- </td>- }+ @foreach (var item in ended)+ {+ <tr role="row">+ <td>+ <div>+ <a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })">@item.ProductName</a>+ </div>+ </td>+ @if (item.HighestBidder)+ {<td><div>- @item.CurrentBidAmount @if (item.CurrentBidAmountValue > item.BidAmountValue)- {<small>(@item.BidAmount)</small>}+ <span class="text-success">@Loc["Account.CustomerAuctions.Status.HighestBidder"]</span></div></td>+ }+ else+ {<td>- <div>@item.EndBidDate</div>+ <div>+ <span class="text-danger">@Loc["Account.CustomerAuctions.Status.Outbid"]</span>+ </div></td>- </tr>- }+ }+ <td>+ <div>+ @item.CurrentBidAmount+ @if (item.CurrentBidAmountValue > item.BidAmountValue)+ {+ <small>(@item.BidAmount)</small>+ }+ </div>+ </td>+ <td>+ <div>@item.EndBidDate</div>+ </td>+ </tr>+ }</tbody></table></div>diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/ChangePassword.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/ChangePassword.cshtmlindex 87248a7d2..6e7b7da64 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/ChangePassword.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/ChangePassword.cshtml@@ -6,14 +6,18 @@//titlepagebuilder.AddTitleParts(Loc["Title.Account"]);}+@section left{@await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = AccountNavigationEnum.ChangePassword })}+<validation-observer v-slot="{ handleSubmit }"><form asp-route="CustomerChangePassword" method="post" ref="form" v-on:submit.prevent="handleSubmit(formSubmit)"><section class="page account-page change-password-page pl-lg-3 pt-3 pt-lg-0">- <h1 class="h2 generalTitle"><div>@Loc["Account.ChangePassword"]</div></h1>+ <h1 class="h2 generalTitle">+ <div>@Loc["Account.ChangePassword"]</div>+ </h1><a class="left-side-toggler mb-3" onclick="sideToggle()"><div class="inner"><span></span>@@ -24,7 +28,7 @@@Loc["Account.Navigation"]</div></a>- @if (!String.IsNullOrEmpty(Model.Result))+ @if (!string.IsNullOrEmpty(Model.Result)){<section class="result alert alert-info">@Model.Result@@ -37,7 +41,7 @@<fieldset class="form-group"><validation-provider tag="div" rules="required" name="OldPassword" v-slot="{ errors, classes }"><label asp-for="OldPassword" class="col-form-label">@Loc["Account.ChangePassword.Fields.OldPassword"]:</label>- <input asp-for="OldPassword" v-model="changepassword.OldPassword" v-bind:class="[classes , 'form-control']" />+ <input asp-for="OldPassword" v-model="changepassword.OldPassword" v-bind:class="[classes , 'form-control']"/><span class="field-validation-error">{{ errors[0] }}</span><span asp-validation-for="OldPassword"></span></validation-provider>@@ -45,7 +49,7 @@<fieldset class="form-group"><validation-provider tag="div" vid="changepassword.NewPassword" rules="required" v-slot="{ errors, classes }"><label asp-for="NewPassword" class="col-form-label">@Loc["Account.ChangePassword.Fields.NewPassword"]:</label>- <input asp-for="NewPassword" v-model="changepassword.NewPassword" v-bind:class="[classes , 'form-control']" />+ <input asp-for="NewPassword" v-model="changepassword.NewPassword" v-bind:class="[classes , 'form-control']"/><span class="field-validation-error">{{ errors[0] }}</span><span asp-validation-for="NewPassword"></span></validation-provider>@@ -53,7 +57,7 @@<fieldset class="form-group"><validation-provider tag="div" vid="changepassword.ConfirmNewPassword" rules="required|confirmed:@@changepassword.NewPassword" v-slot="{ errors, classes }"><label asp-for="ConfirmNewPassword" class="col-form-label">@Loc["Account.ChangePassword.Fields.ConfirmNewPassword"]:</label>- <input asp-for="ConfirmNewPassword" v-model="changepassword.ConfirmNewPassword" v-bind:class="[classes , 'form-control']" />+ <input asp-for="ConfirmNewPassword" v-model="changepassword.ConfirmNewPassword" v-bind:class="[classes , 'form-control']"/><span class="field-validation-error">{{ errors[0] }}</span><span asp-validation-for="ConfirmNewPassword"></span></validation-provider>@@ -61,7 +65,7 @@</div></fieldset><div class="text-xs-center">- <input type="submit" class="btn btn-info change-password-button" value="@Loc["Account.ChangePassword.Button"]" />+ <input type="submit" class="btn btn-info change-password-button" value="@Loc["Account.ChangePassword.Button"]"/></div></section></form>diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/Courses.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/Courses.cshtmlindex 9ea461fd6..4b84dc3ec 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/Courses.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/Courses.cshtml@@ -5,13 +5,16 @@//titlepagebuilder.AddTitleParts(Loc["Title.Courses"]);}+@section left{@await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = AccountNavigationEnum.Courses })}<div class="page account-page auction-list-page pl-lg-3 pt-3 pt-lg-0">- <h1 class="h2 generalTitle"><div>@Loc["Account.Courses"]</div></h1>+ <h1 class="h2 generalTitle">+ <div>@Loc["Account.Courses"]</div>+ </h1><a class="left-side-toggler mb-3" onclick="sideToggle()"><div class="inner"><span></span>diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/DeleteAccount.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/DeleteAccount.cshtmlindex c80546d43..cc6cda182 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/DeleteAccount.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/DeleteAccount.cshtml@@ -6,14 +6,18 @@//titlepagebuilder.AddTitleParts(Loc["Title.Account"]);}+@section left{@await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = AccountNavigationEnum.DeleteAccount })}+<validation-observer v-slot="{ handleSubmit }"><form asp-route="CustomerDeleteAccount" method="post" autocomplete="off" ref="form" v-on:submit.prevent="handleSubmit(formSubmit)"><section class="page account-page change-password-page pl-lg-3 pt-3 pt-lg-0">- <h1 class="h2 generalTitle"><div>@Loc["Account.DeleteAccount"]</div></h1>+ <h1 class="h2 generalTitle">+ <div>@Loc["Account.DeleteAccount"]</div>+ </h1><a class="left-side-toggler mb-3" onclick="sideToggle()"><div class="inner"><span></span>@@ -33,7 +37,7 @@<fieldset class="form-group"><validation-provider tag="div" rules="required" name="Password" v-slot="{ errors, classes }"><label asp-for="Password" class="col-form-label">@Loc["Account.DeleteAccount.Fields.Password"]:</label>- <input asp-for="Password" v-model="deleteaccount.Password" v-bind:class="[classes , 'form-control']" />+ <input asp-for="Password" v-model="deleteaccount.Password" v-bind:class="[classes , 'form-control']"/><span class="field-validation-error">{{ errors[0] }}</span><span asp-validation-for="Password"></span></validation-provider>@@ -41,7 +45,7 @@</div></fieldset><div class="text-xs-center">- <input type="submit" class="btn btn-danger change-password-button" value="@Loc["Account.DeleteAccount.Button"]" onclick="return confirm('@Loc["Admin.Common.AreYouSure"]'); " />+ <input type="submit" class="btn btn-danger change-password-button" value="@Loc["Account.DeleteAccount.Button"]" onclick="return confirm('@Loc["Admin.Common.AreYouSure"]'); "/></div></section></form>diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/Documents.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/Documents.cshtmlindex 70afa183f..e1951f665 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/Documents.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/Documents.cshtml@@ -5,13 +5,16 @@//titlepagebuilder.AddTitleParts(Loc["Title.Documents"]);}+@section left{@await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = AccountNavigationEnum.Documents })}<div class="page account-page auction-list-page pl-lg-3 pt-3 pt-lg-0">- <h1 class="h2 generalTitle"><div>@Loc["Account.Documents"]</div></h1>+ <h1 class="h2 generalTitle">+ <div>@Loc["Account.Documents"]</div>+ </h1><a class="left-side-toggler mb-3" onclick="sideToggle()"><div class="inner"><span></span>@@ -59,13 +62,14 @@<div class="d-inline-flex p-sm-3 p-2 border-top"><span class="mb-2">@Loc["Account.Documents.Attachment"]:- <a href="@Url.RouteUrl("GetDocumentFile", new { documentId = item.Id})">@Loc["Account.Documents.Download"]</a>+ <a href="@Url.RouteUrl("GetDocumentFile", new { documentId = item.Id })">@Loc["Account.Documents.Download"]</a></span></div>}</div>}- <page-navigation asp-query-param="pagenumber" asp-pagination="Model.PagingContext" />++ <page-navigation asp-query-param="pagenumber" asp-pagination="Model.PagingContext"/>}else{diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/DownloadableProducts.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/DownloadableProducts.cshtmlindex 9dc54690a..8e5d4f58c 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/DownloadableProducts.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/DownloadableProducts.cshtml@@ -6,12 +6,16 @@//titlepagebuilder.AddTitleParts(Loc["Title.Account"]);}+@section left{@await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = AccountNavigationEnum.DownloadableProducts })}+<section class="page account-page downloadable-products-page pl-lg-3 pt-lg-0 pt-3">- <h1 class="h2 generalTitle"><div>@Loc["Account.DownloadableProducts"]</div></h1>+ <h1 class="h2 generalTitle">+ <div>@Loc["Account.DownloadableProducts"]</div>+ </h1><a class="left-side-toggler mb-3" onclick="sideToggle()"><div class="inner"><span></span>@@ -24,7 +28,6 @@</a>@if (Model.Items.Any()){-<div id="downloadable-products"></div><script>var DownloadableProducts = Vue.extend({@@ -38,7 +41,7 @@{ key: 'download', label: '@Loc["DownloadableProducts.Fields.Download"]'},],items: [- @for (int i = 0; i < Model.Items.Count; i++)+ @for (var i = 0; i < Model.Items.Count; i++){var item = Model.Items[i];<text>@@ -50,10 +53,24 @@date: '@item.CreatedOn.ToString("d")'},product: {- product: '<a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })">@item.ProductName</a>@if (!String.IsNullOrEmpty(item.ProductAttributes)) {<div class="attributes">@Html.Raw(item.ProductAttributes)</div>}'+ product: '<a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })">@item.ProductName</a>@if (!string.IsNullOrEmpty(item.ProductAttributes))+ {+ <div class="attributes">@Html.Raw(item.ProductAttributes)</div>+ }'},download: {- download: '@if (!String.IsNullOrEmpty(item.DownloadId)) { <a href="@Url.RouteUrl("GetDownload", new { orderItemId = item.OrderItemGuid })">@Loc["DownloadableProducts.Fields.Download"]</a>}else {@Loc["DownloadableProducts.Fields.Download.NA"]}@if (!String.IsNullOrEmpty(item.LicenseId))@if (!String.IsNullOrEmpty(item.LicenseId)) {<a href="@Url.RouteUrl("GetLicense", new { orderItemId = item.OrderItemGuid })">@Loc["DownloadableProducts.Fields.DownloadLicense"]</a> }'+ download: '@if (!string.IsNullOrEmpty(item.DownloadId))+ {+ <a href="@Url.RouteUrl("GetDownload", new { orderItemId = item.OrderItemGuid })">@Loc["DownloadableProducts.Fields.Download"]</a>+ }+ else+ {+ @Loc["DownloadableProducts.Fields.Download.NA"]+ }+ @if (!string.IsNullOrEmpty(item.LicenseId)) @if (!string.IsNullOrEmpty(item.LicenseId))+ {+ <a href="@Url.RouteUrl("GetLicense", new { orderItemId = item.OrderItemGuid })">@Loc["DownloadableProducts.Fields.DownloadLicense"]</a>+ }'},},@@ -72,4 +89,4 @@@Loc["DownloadableProducts.NoItems"]</div>}-</section>+</section>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/Info.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/Info.cshtmlindex 9faba4102..6e25aad46 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/Info.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/Info.cshtml@@ -7,6 +7,7 @@//titlepagebuilder.AddTitleParts(Loc["Title.Account"]);}+@section left{@await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = AccountNavigationEnum.Info })@@ -71,523 +72,529 @@});</script><div class="page account-page customer-info-page pl-lg-3 pt-3 pt-lg-0">- @if (customerSettings.AllowUsersToExportData)- {- <button class="btn btn-info float-sm-right mt-2" onclick="location.href='/account/export'">- <b-icon icon="server"></b-icon> @Loc["Account.CustomerExportToXls"]- </button>- }- <h2 class="generalTitle"><div>@Loc["Account.CustomerInfo"]</div></h2>- <a class="left-side-toggler mb-3" onclick="sideToggle()">- <div class="inner">- <span></span>- <span></span>- <span></span>- </div>- <div class="text">- @Loc["Account.Navigation"]+@if (customerSettings.AllowUsersToExportData)+{+ <button class="btn btn-info float-sm-right mt-2" onclick="location.href='/account/export'">+ <b-icon icon="server"></b-icon> @Loc["Account.CustomerExportToXls"]+ </button>+}+<h2 class="generalTitle">+ <div>@Loc["Account.CustomerInfo"]</div>+</h2>+<a class="left-side-toggler mb-3" onclick="sideToggle()">+ <div class="inner">+ <span></span>+ <span></span>+ <span></span>+ </div>+ <div class="text">+ @Loc["Account.Navigation"]+ </div>+</a>+<validation-observer v-slot="{ handleSubmit }">+<form asp-route="CustomerInfo" method="post" ref="form" v-on:submit.prevent="handleSubmit(formSubmit)">+<div asp-validation-summary="All" class="message-error"></div>+<div class="card mb-3">+ <h3 class="card-header">@Loc["Account.YourPersonalDetails"]</h3>+ <div class="card-body">+ <fieldset class="form-fields">+ <legend class="sr-only">@Loc["Account.Fields.Gender"]</legend>+ @if (Model.GenderEnabled)+ {+ <label class="col-form-label">+ @Loc["Account.Fields.Gender"]:+ </label>+ <div class="form-group gender">+ <div class="flex-row">+ <div class="custom-control custom-radio male custom-control-inline">+ <input type="radio" asp-for="Gender" value="M" checked="@(Model.Gender == "M")" id="gender-male" class="custom-control-input"/>+ <label class="custom-control-label" for="gender-male">@Loc["Account.Fields.Gender.Male"]</label>+ </div>+ <div class="custom-control custom-radio female custom-control-inline">+ <input type="radio" asp-for="Gender" value="F" checked="@(Model.Gender == "F")" id="gender-female" class="custom-control-input"/>+ <label class="custom-control-label" for="gender-female">@Loc["Account.Fields.Gender.Female"]</label>+ </div>+ </div>+ </div>+ }+ </fieldset>+ <div class="form-row">+ <fieldset class="form-group col-sm-6 col-12">+ <legend class="sr-only">@Loc["account.fields.firstname"]</legend>+ @if (Model.FirstLastNameRequired)+ {+ <validation-provider tag="div" rules="required" name="FirstName" v-slot="{ errors, classes }">+ <label asp-for="FirstName" class="col-form-label">@Loc["Account.Fields.FirstName"]:</label>+ <span class="required">*</span>+ <input asp-for="FirstName" v-model="customer.FirstName" v-bind:class="[classes , 'form-control']"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="FirstName"></span>+ </validation-provider>+ }+ else+ {+ <label asp-for="FirstName" class="col-form-label">@Loc["Account.Fields.FirstName"]:</label>+ <input asp-for="FirstName" class="form-control"/>+ }+ </fieldset>+ <fieldset class="form-group col-sm-6 col-12">+ <legend class="sr-only">@Loc["account.fields.lastname"]</legend>+ @if (Model.FirstLastNameRequired)+ {+ <validation-provider tag="div" rules="required" name="LastName" v-slot="{ errors, classes }">+ <label asp-for="LastName" class="col-form-label">@Loc["Account.Fields.LastName"]:</label>+ <span class="required">*</span>+ <input asp-for="LastName" v-model="customer.LastName" v-bind:class="[classes , 'form-control']"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="LastName"></span>+ </validation-provider>+ }+ else+ {+ <label asp-for="LastName" class="col-form-label">@Loc["Account.Fields.LastName"]:</label>+ <input asp-for="LastName" class="form-control"/>+ }+ </fieldset></div>- </a>- <validation-observer v-slot="{ handleSubmit }">- <form asp-route="CustomerInfo" method="post" ref="form" v-on:submit.prevent="handleSubmit(formSubmit)">- <div asp-validation-summary="All" class="message-error"></div>- <div class="card mb-3">- <h3 class="card-header">@Loc["Account.YourPersonalDetails"]</h3>- <div class="card-body">- <fieldset class="form-fields">- <legend class="sr-only">@Loc["Account.Fields.Gender"]</legend>- @if (Model.GenderEnabled)+ @if (Model.DateOfBirthEnabled)+ {+ <fieldset class="form-group date-of-birth">+ <legend class="sr-only">@Loc["account.fields.dateofbirth"]</legend>+ <span class="col-form-label">+ @Loc["Account.Fields.DateOfBirth"]:+ </span>+ @if (Model.DateOfBirthRequired)+ {+ <span class="required">*</span>+ }+ <div class="input-group">+ <date-picker-dropdown control-day="@Html.IdFor(x => x.DateOfBirthDay)"+ control-month="@Html.IdFor(x => x.DateOfBirthMonth)"+ control-year="@Html.IdFor(x => x.DateOfBirthYear)"+ begin-year="@(DateTime.Now.Year - 100)"+ end-year="DateTime.Now.Year"+ selected-day="Model.DateOfBirthDay ?? 0"+ selected-month="Model.DateOfBirthMonth ?? 0"+ selected-year="Model.DateOfBirthYear ?? 0"+ class="col-12 input-group px-0"/>++ <span asp-validation-for="DateOfBirthDay"></span>+ <span asp-validation-for="DateOfBirthMonth"></span>+ <span asp-validation-for="DateOfBirthYear"></span>+ </div>+ </fieldset>+ }+ <fieldset class="form-group row mail">+ <legend class="sr-only">@Loc["account.associatedexternalauth.email"]</legend>+ <div class="col-12">+ <validation-provider tag="div" rules="required|email" name="Email" v-slot="{ errors, classes }">+ <label asp-for="Email" class="col-form-label">@Loc["Account.Fields.Email"]:</label>+ <span class="required">*</span>+ <input asp-for="Email" v-model="customer.Email" v-bind:class="[classes , 'form-control']" asp-readonly="@(!Model.AllowUsersToChangeEmail)"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="Email"></span>+ </validation-provider>+ </div>+ </fieldset>+ @if (Model.UsernamesEnabled)+ {+ if (Model.AllowUsersToChangeUsernames)+ {+ <fieldset class="form-group row mb-0">+ <legend class="sr-only">@Loc["account.associatedexternalauth.email"]</legend>+ <div class="col-12">+ <validation-provider tag="div" rules="required" name="Username" v-slot="{ errors, classes }">+ <label asp-for="Username" class="col-form-label">@Loc["Account.Fields.Username"]:</label>+ <span class="required">*</span>+ <input asp-for="Username" v-model="customer.Username" v-bind:class="[classes , 'form-control']"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="Username"></span>+ </validation-provider>+ @if (Model.CheckUsernameAvailabilityEnabled){- <label class="col-form-label">- @Loc["Account.Fields.Gender"]:- </label>- <div class="form-group gender">- <div class="flex-row">- <div class="custom-control custom-radio male custom-control-inline">- <input type="radio" asp-for="Gender" value="M" checked="@(Model.Gender == "M")" id="gender-male" class="custom-control-input" />- <label class="custom-control-label" for="gender-male">@Loc["Account.Fields.Gender.Male"]</label>- </div>- <div class="custom-control custom-radio female custom-control-inline">- <input type="radio" asp-for="Gender" value="F" checked="@(Model.Gender == "F")" id="gender-female" class="custom-control-input" />- <label class="custom-control-label" for="gender-female">@Loc["Account.Fields.Gender.Female"]</label>- </div>- </div>- </div>+ <partial name="Partials/CheckUsernameAvailability"/>}- </fieldset>- <div class="form-row">- <fieldset class="form-group col-sm-6 col-12">- <legend class="sr-only">@Loc["account.fields.firstname"]</legend>- @if (Model.FirstLastNameRequired)+ </div>+ </fieldset>+ }+ else+ {+ <fieldset class="form-group row mb-0">+ <legend class="sr-only">@Loc["account.fields.username"]</legend>+ <div class="form-group">+ <label asp-for="Username" class="col-form-label px-3">@Loc["Account.Fields.Username"]:</label>+ <span class="readonly-username px-3">@Model.Username</span>+ </div>+ </fieldset>+ }+ }+ </div>+</div>+@if (Model.CompanyEnabled || Model.DisplayVatNumber)+{+ <div class="card mb-3">+ <h3 class="card-header">@Loc["Account.CompanyDetails"]</h3>+ <div class="card-body">+ <div class="form-fields">+ @if (Model.CompanyEnabled)+ {+ <div class="form-group">+ @if (Model.CompanyRequired)+ {+ <validation-provider tag="div" rules="required" name="Company" v-slot="{ errors, classes }">+ <label asp-for="Company" class="col-form-label">@Loc["Account.Fields.Company"]:</label>+ <span class="required">*</span>+ <input asp-for="Company" v-model="customer.Company" v-bind:class="[classes , 'form-control']"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="Company"></span>+ </validation-provider>+ }+ else+ {+ <label asp-for="Company" class="col-form-label">@Loc["Account.Fields.Company"]:</label>+ <input asp-for="Company" class="form-control"/>+ <span asp-validation-for="Company"></span>+ }+ </div>+ }+ @if (Model.DisplayVatNumber)+ {+ <div class="form-group">+ <label asp-for="VatNumber" class="col-form-label">@Loc["Account.Fields.VatNumber"]:</label>+ <input asp-for="VatNumber" class="form-control"/>+ <span class="vat-status">@Model.VatNumberStatusNote</span>+ <span class="vat-note">+ <em>@Loc["Account.Fields.VatNumber.Note"]</em>+ </span>+ </div>+ }+ </div>+ </div>+ </div>+}+@if (Model.StreetAddressEnabled ||+ Model.StreetAddress2Enabled ||+ Model.ZipPostalCodeEnabled ||+ Model.CityEnabled ||+ Model.CountryEnabled)+{+ <div class="card mb-3">+ <h3 class="card-header">+ @Loc["Account.YourAddress"]+ </h3>+ <div class="card-body">+ <div class="form-fields">+ <div class="row d-flex">+ @if (Model.StreetAddressEnabled)+ {+ <fieldset class="form-group col-12 col-sm-6">+ <legend class="sr-only">@Loc["account.fields.streetaddress"]</legend>+ @if (Model.StreetAddressRequired){- <validation-provider tag="div" rules="required" name="FirstName" v-slot="{ errors, classes }">- <label asp-for="FirstName" class="col-form-label">@Loc["Account.Fields.FirstName"]:</label>+ <validation-provider tag="div" rules="required" name="StreetAddress" v-slot="{ errors, classes }">+ <label asp-for="StreetAddress" class="col-form-label">@Loc["Account.Fields.StreetAddress"]:</label><span class="required">*</span>- <input asp-for="FirstName" v-model="customer.FirstName" v-bind:class="[classes , 'form-control']" />+ <input asp-for="StreetAddress" v-model="customer.StreetAddress" v-bind:class="[classes , 'form-control']"/><span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="FirstName"></span>+ <span asp-validation-for="StreetAddress"></span></validation-provider>}else{- <label asp-for="FirstName" class="col-form-label">@Loc["Account.Fields.FirstName"]:</label>- <input asp-for="FirstName" class="form-control" />+ <label asp-for="StreetAddress" class="col-form-label">@Loc["Account.Fields.StreetAddress"]:</label>+ <input asp-for="StreetAddress" class="form-control"/>+ <span asp-validation-for="StreetAddress"></span>}</fieldset>- <fieldset class="form-group col-sm-6 col-12">- <legend class="sr-only">@Loc["account.fields.lastname"]</legend>- @if (Model.FirstLastNameRequired)+ }+ @if (Model.StreetAddress2Enabled)+ {+ <fieldset class="form-group col-12 col-sm-6">+ <legend class="sr-only">@Loc["account.fields.streetaddress2"]</legend>+ @if (Model.StreetAddress2Required){- <validation-provider tag="div" rules="required" name="LastName" v-slot="{ errors, classes }">- <label asp-for="LastName" class="col-form-label">@Loc["Account.Fields.LastName"]:</label>+ <validation-provider tag="div" rules="required" name="StreetAddress2" v-slot="{ errors, classes }">+ <label asp-for="StreetAddress2" class="col-form-label">@Loc["Account.Fields.StreetAddress2"]:</label><span class="required">*</span>- <input asp-for="LastName" v-model="customer.LastName" v-bind:class="[classes , 'form-control']" />+ <input asp-for="StreetAddress2" v-model="customer.StreetAddress2" v-bind:class="[classes , 'form-control']"/><span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="LastName"></span>+ <span asp-validation-for="StreetAddress2"></span></validation-provider>}else{- <label asp-for="LastName" class="col-form-label">@Loc["Account.Fields.LastName"]:</label>- <input asp-for="LastName" class="form-control" />+ <label asp-for="StreetAddress2" class="col-form-label">@Loc["Account.Fields.StreetAddress2"]:</label>+ <input asp-for="StreetAddress2" class="form-control"/>+ <span asp-validation-for="StreetAddress2"></span>}</fieldset>- </div>- @if (Model.DateOfBirthEnabled)+ }+ @if (Model.ZipPostalCodeEnabled){- <fieldset class="form-group date-of-birth">- <legend class="sr-only">@Loc["account.fields.dateofbirth"]</legend>- <span class="col-form-label">- @Loc["Account.Fields.DateOfBirth"]:- </span>- @if (Model.DateOfBirthRequired)+ <fieldset class="form-group col-12 col-sm-6">+ <legend class="sr-only">@Loc["account.fields.zippostalcode"]</legend>+ @if (Model.ZipPostalCodeRequired){- <span class="required">*</span>+ <validation-provider tag="div" rules="required" name="ZipPostalCode" v-slot="{ errors, classes }">+ <label asp-for="ZipPostalCode" class="col-form-label">@Loc["Account.Fields.ZipPostalCode"]:</label>+ <span class="required">*</span>+ <input asp-for="ZipPostalCode" v-model="customer.ZipPostalCode" v-bind:class="[classes , 'form-control']"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="ZipPostalCode"></span>+ </validation-provider>+ }+ else+ {+ <label asp-for="ZipPostalCode" class="col-form-label">@Loc["Account.Fields.ZipPostalCode"]:</label>+ <input asp-for="ZipPostalCode" class="form-control"/>+ <span asp-validation-for="ZipPostalCode"></span>}- <div class="input-group">- <date-picker-dropdown control-day="@Html.IdFor(x => x.DateOfBirthDay)"- control-month="@Html.IdFor(x => x.DateOfBirthMonth)"- control-year="@Html.IdFor(x => x.DateOfBirthYear)"- begin-year="@(DateTime.Now.Year - 100)"- end-year="DateTime.Now.Year"- selected-day="Model.DateOfBirthDay ?? 0"- selected-month="Model.DateOfBirthMonth ?? 0"- selected-year="Model.DateOfBirthYear ?? 0"- class="col-12 input-group px-0" />-- <span asp-validation-for="DateOfBirthDay"></span>- <span asp-validation-for="DateOfBirthMonth"></span>- <span asp-validation-for="DateOfBirthYear"></span>- </div></fieldset>}- <fieldset class="form-group row mail">- <legend class="sr-only">@Loc["account.associatedexternalauth.email"]</legend>- <div class="col-12">- <validation-provider tag="div" rules="required|email" name="Email" v-slot="{ errors, classes }">- <label asp-for="Email" class="col-form-label">@Loc["Account.Fields.Email"]:</label>- <span class="required">*</span>- <input asp-for="Email" v-model="customer.Email" v-bind:class="[classes , 'form-control']" asp-readonly=@(!Model.AllowUsersToChangeEmail) />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="Email"></span>- </validation-provider>- </div>- </fieldset>- @if (Model.UsernamesEnabled)+ @if (Model.CityEnabled){- if (Model.AllowUsersToChangeUsernames)- {- <fieldset class="form-group row mb-0">- <legend class="sr-only">@Loc["account.associatedexternalauth.email"]</legend>- <div class="col-12">- <validation-provider tag="div" rules="required" name="Username" v-slot="{ errors, classes }">- <label asp-for="Username" class="col-form-label">@Loc["Account.Fields.Username"]:</label>- <span class="required">*</span>- <input asp-for="Username" v-model="customer.Username" v-bind:class="[classes , 'form-control']" />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="Username"></span>- </validation-provider>- @if (Model.CheckUsernameAvailabilityEnabled)- {- <partial name="Partials/CheckUsernameAvailability" />- }- </div>- </fieldset>- }- else- {- <fieldset class="form-group row mb-0">- <legend class="sr-only">@Loc["account.fields.username"]</legend>- <div class="form-group">- <label asp-for="Username" class="col-form-label px-3">@Loc["Account.Fields.Username"]:</label>- <span class="readonly-username px-3">@Model.Username</span>- </div>- </fieldset>- }+ <fieldset class="form-group col-12 col-sm-6">+ <legend class="sr-only">@Loc["account.fields.city"]</legend>+ @if (Model.CityRequired)+ {+ <validation-provider tag="div" rules="required" name="City" v-slot="{ errors, classes }">+ <label asp-for="City" class="col-form-label">@Loc["Account.Fields.City"]:</label>+ <span class="required">*</span>+ <input asp-for="City" v-model="customer.City" v-bind:class="[classes , 'form-control']"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="City"></span>+ </validation-provider>+ }+ else+ {+ <label asp-for="City" class="col-form-label">@Loc["Account.Fields.City"]:</label>+ <input asp-for="City" class="form-control"/>+ <span asp-validation-for="City"></span>+ }+ </fieldset>}- </div>- </div>- @if (Model.CompanyEnabled || Model.DisplayVatNumber)- {- <div class="card mb-3">- <h3 class="card-header">@Loc["Account.CompanyDetails"]</h3>- <div class="card-body">- <div class="form-fields">- @if (Model.CompanyEnabled)+ @if (Model.CountryEnabled)+ {+ <fieldset class="form-group col-12 col-sm-6">+ <legend class="sr-only">@Loc["account.fields.country"]</legend>+ @if (Model.CountryRequired){- <div class="form-group">- @if (Model.CompanyRequired)- {- <validation-provider tag="div" rules="required" name="Company" v-slot="{ errors, classes }">- <label asp-for="Company" class="col-form-label">@Loc["Account.Fields.Company"]:</label>- <span class="required">*</span>- <input asp-for="Company" v-model="customer.Company" v-bind:class="[classes , 'form-control']" />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="Company"></span>- </validation-provider>- }- else- {- <label asp-for="Company" class="col-form-label">@Loc["Account.Fields.Company"]:</label>- <input asp-for="Company" class="form-control" />- <span asp-validation-for="Company"></span>- }- </div>+ <validation-provider tag="div" rules="required" name="CountryId" v-slot="{ errors, classes }">+ <label asp-for="CountryId" class="col-form-label">@Loc["Account.Fields.Country"]:</label>+ <span class="required">*</span>+ <select asp-for="CountryId" asp-items="Model.AvailableCountries"+ onchange="@Html.IdFor(model => model.CountryId)_select_element(this)" v-bind:class="[classes , 'form-control custom-select']" v-model="customer.CountryId">+ </select>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="CountryId"></span>+ </validation-provider>}- @if (Model.DisplayVatNumber)+ else{- <div class="form-group">- <label asp-for="VatNumber" class="col-form-label">@Loc["Account.Fields.VatNumber"]:</label>- <input asp-for="VatNumber" class="form-control" />- <span class="vat-status">@Model.VatNumberStatusNote</span>- <span class="vat-note"><em>@Loc["Account.Fields.VatNumber.Note"]</em></span>- </div>+ <label asp-for="CountryId" class="col-form-label">@Loc["Account.Fields.Country"]:</label>+ <select asp-for="CountryId" class="custom-select form-control" asp-items="Model.AvailableCountries"></select>+ <span asp-validation-for="CountryId"></span>}- </div>- </div>- </div>- }- @if (Model.StreetAddressEnabled ||- Model.StreetAddress2Enabled ||- Model.ZipPostalCodeEnabled ||- Model.CityEnabled ||- Model.CountryEnabled)- {- <div class="card mb-3">- <h3 class="card-header">- @Loc["Account.YourAddress"]- </h3>- <div class="card-body">- <div class="form-fields">- <div class="row d-flex">- @if (Model.StreetAddressEnabled)- {- <fieldset class="form-group col-12 col-sm-6">- <legend class="sr-only">@Loc["account.fields.streetaddress"]</legend>- @if (Model.StreetAddressRequired)- {- <validation-provider tag="div" rules="required" name="StreetAddress" v-slot="{ errors, classes }">- <label asp-for="StreetAddress" class="col-form-label">@Loc["Account.Fields.StreetAddress"]:</label>- <span class="required">*</span>- <input asp-for="StreetAddress" v-model="customer.StreetAddress" v-bind:class="[classes , 'form-control']" />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="StreetAddress"></span>- </validation-provider>- }- else- {- <label asp-for="StreetAddress" class="col-form-label">@Loc["Account.Fields.StreetAddress"]:</label>- <input asp-for="StreetAddress" class="form-control" />- <span asp-validation-for="StreetAddress"></span>- }- </fieldset>- }- @if (Model.StreetAddress2Enabled)- {- <fieldset class="form-group col-12 col-sm-6">- <legend class="sr-only">@Loc["account.fields.streetaddress2"]</legend>- @if (Model.StreetAddress2Required)- {- <validation-provider tag="div" rules="required" name="StreetAddress2" v-slot="{ errors, classes }">- <label asp-for="StreetAddress2" class="col-form-label">@Loc["Account.Fields.StreetAddress2"]:</label>- <span class="required">*</span>- <input asp-for="StreetAddress2" v-model="customer.StreetAddress2" v-bind:class="[classes , 'form-control']" />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="StreetAddress2"></span>- </validation-provider>- }- else- {- <label asp-for="StreetAddress2" class="col-form-label">@Loc["Account.Fields.StreetAddress2"]:</label>- <input asp-for="StreetAddress2" class="form-control" />- <span asp-validation-for="StreetAddress2"></span>- }- </fieldset>- }- @if (Model.ZipPostalCodeEnabled)- {- <fieldset class="form-group col-12 col-sm-6">- <legend class="sr-only">@Loc["account.fields.zippostalcode"]</legend>- @if (Model.ZipPostalCodeRequired)- {- <validation-provider tag="div" rules="required" name="ZipPostalCode" v-slot="{ errors, classes }">- <label asp-for="ZipPostalCode" class="col-form-label">@Loc["Account.Fields.ZipPostalCode"]:</label>- <span class="required">*</span>- <input asp-for="ZipPostalCode" v-model="customer.ZipPostalCode" v-bind:class="[classes , 'form-control']" />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="ZipPostalCode"></span>- </validation-provider>- }- else- {- <label asp-for="ZipPostalCode" class="col-form-label">@Loc["Account.Fields.ZipPostalCode"]:</label>- <input asp-for="ZipPostalCode" class="form-control" />- <span asp-validation-for="ZipPostalCode"></span>- }- </fieldset>- }- @if (Model.CityEnabled)- {- <fieldset class="form-group col-12 col-sm-6">- <legend class="sr-only">@Loc["account.fields.city"]</legend>- @if (Model.CityRequired)- {- <validation-provider tag="div" rules="required" name="City" v-slot="{ errors, classes }">- <label asp-for="City" class="col-form-label">@Loc["Account.Fields.City"]:</label>- <span class="required">*</span>- <input asp-for="City" v-model="customer.City" v-bind:class="[classes , 'form-control']" />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="City"></span>- </validation-provider>- }- else- {- <label asp-for="City" class="col-form-label">@Loc["Account.Fields.City"]:</label>- <input asp-for="City" class="form-control" />- <span asp-validation-for="City"></span>- }- </fieldset>- }- @if (Model.CountryEnabled)- {- <fieldset class="form-group col-12 col-sm-6">- <legend class="sr-only">@Loc["account.fields.country"]</legend>- @if (Model.CountryRequired)- {- <validation-provider tag="div" rules="required" name="CountryId" v-slot="{ errors, classes }">- <label asp-for="CountryId" class="col-form-label">@Loc["Account.Fields.Country"]:</label>- <span class="required">*</span>- <select asp-for="CountryId" asp-items="Model.AvailableCountries"- onchange="@Html.IdFor(model => model.CountryId)_select_element(this)" v-bind:class="[classes , 'form-control custom-select']" v-model="customer.CountryId"></select>- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="CountryId"></span>- </validation-provider>- }- else- {- <label asp-for="CountryId" class="col-form-label">@Loc["Account.Fields.Country"]:</label>- <select asp-for="CountryId" class="custom-select form-control" asp-items="Model.AvailableCountries"></select>- <span asp-validation-for="CountryId"></span>- }- </fieldset>- }- @if (Model.CountryEnabled && Model.StateProvinceEnabled)+ </fieldset>+ }+ @if (Model.CountryEnabled && Model.StateProvinceEnabled)+ {+ <fieldset class="form-group col-12 col-sm-6">+ <legend class="sr-only">@Loc["account.fields.stateprovince"]</legend>+ <validation-provider tag="div" rules="required" name="StateProvinceId" v-slot="{ errors, classes }">+ <label asp-for="StateProvinceId" class="col-form-label">@Loc["Account.Fields.StateProvince"]:</label>+ @if (Model.StateProvinceRequired){- <fieldset class="form-group col-12 col-sm-6">- <legend class="sr-only">@Loc["account.fields.stateprovince"]</legend>- <validation-provider tag="div" rules="required" name="StateProvinceId" v-slot="{ errors, classes }">- <label asp-for="StateProvinceId" class="col-form-label">@Loc["Account.Fields.StateProvince"]:</label>- @if (Model.StateProvinceRequired)- {- <span class="required">*</span>- }- <select asp-for="StateProvinceId" data-val-required="@Loc["Address.Fields.StateProvince.Required"]" class="custom-select form-control"- onchange="@Html.IdFor(model => model.StateProvinceId)_select_element(this)" asp-items="Model.AvailableStates" v-model="customer.StateProvinceId"></select>- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="StateProvinceId"></span>- <span id="states-loading-progress" style="display: none;" class="please-wait">@Loc["Common.Wait..."]</span>- </validation-provider>- </fieldset>+ <span class="required">*</span>}- </div>-- </div>- </div>+ <select asp-for="StateProvinceId" data-val-required="@Loc["Address.Fields.StateProvince.Required"]" class="custom-select form-control"+ onchange="@Html.IdFor(model => model.StateProvinceId)_select_element(this)" asp-items="Model.AvailableStates" v-model="customer.StateProvinceId">+ </select>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="StateProvinceId"></span>+ <span id="states-loading-progress" style="display: none;" class="please-wait">@Loc["Common.Wait..."]</span>+ </validation-provider>+ </fieldset>+ }</div>- }- @if (Model.PhoneEnabled || Model.FaxEnabled)++ </div>+ </div>+ </div>+}+@if (Model.PhoneEnabled || Model.FaxEnabled)+{+ <div class="card mb-3">+ <h3 class="card-header">@Loc["Account.YourContactInformation"]</h3>+ <div class="card-body d-flex flex-row row">+ @if (Model.PhoneEnabled){- <div class="card mb-3">- <h3 class="card-header">@Loc["Account.YourContactInformation"]</h3>- <div class="card-body d-flex flex-row row">- @if (Model.PhoneEnabled)- {- <fieldset class="form-group col-12 col-sm-6">- <legend class="sr-only">@Loc["account.fields.phone"]</legend>- @if (Model.PhoneRequired)- {- <validation-provider tag="div" rules="required" name="Phone" v-slot="{ errors, classes }">- <label asp-for="Phone" class="col-form-label">@Loc["Account.Fields.Phone"]:</label>- <span class="required">*</span>- <input asp-for="Phone" v-bind:class="[classes , 'form-control']" v-model="customer.Phone" />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="Phone"></span>- </validation-provider>- }- else- {- <label asp-for="Phone" class="col-form-label">@Loc["Account.Fields.Phone"]:</label>- <input asp-for="Phone" class="form-control" />- <span asp-validation-for="Phone"></span>- }+ <fieldset class="form-group col-12 col-sm-6">+ <legend class="sr-only">@Loc["account.fields.phone"]</legend>+ @if (Model.PhoneRequired)+ {+ <validation-provider tag="div" rules="required" name="Phone" v-slot="{ errors, classes }">+ <label asp-for="Phone" class="col-form-label">@Loc["Account.Fields.Phone"]:</label>+ <span class="required">*</span>+ <input asp-for="Phone" v-bind:class="[classes , 'form-control']" v-model="customer.Phone"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="Phone"></span>+ </validation-provider>+ }+ else+ {+ <label asp-for="Phone" class="col-form-label">@Loc["Account.Fields.Phone"]:</label>+ <input asp-for="Phone" class="form-control"/>+ <span asp-validation-for="Phone"></span>+ }- </fieldset>- }- @if (Model.FaxEnabled)- {- <fieldset class="form-group col-12 col-sm-6">- <legend class="sr-only">@Loc["account.fields.fax"]</legend>- @if (Model.FaxRequired)- {- <validation-provider tag="div" rules="required" name="Fax" v-slot="{ errors, classes }">- <label asp-for="Fax" class="col-form-label">@Loc["Account.Fields.Fax"]:</label>- <span class="required">*</span>- <input asp-for="Fax" v-bind:class="[classes , 'form-control']" v-model="customer.Fax" />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="Fax"></span>- </validation-provider>- }- else- {- <label asp-for="Fax" class="col-form-label">@Loc["Account.Fields.Fax"]:</label>- <input asp-for="Fax" class="form-control" />- <span asp-validation-for="Fax"></span>- }- </fieldset>- }- </div>- </div>+ </fieldset>}-- @if (Model.NewsletterEnabled || Model.CustomerAttributes.Any())+ @if (Model.FaxEnabled){- <div class="card mb-3">- <h3 class="card-header">- @Loc["Account.Options"]- </h3>- <div class="card-body">- <fieldset class="form-fields">- <legend class="sr-only">@Loc["account.fields.newsletter"]</legend>- @if (Model.NewsletterEnabled)- {- <div class="form-group">- <label for="Newsletter" class="ml-1 custom-control custom-checkbox">- <input class="custom-control-input" asp-for="Newsletter" onchange="toggleNewsletterCat()" />- <span class="custom-control-label">@Loc["account.fields.newsletter"]</span>- <span class="sr-only">@Loc["account.fields.newsletter"]</span>- </label>- <span asp-validation-for="Newsletter"></span>- </div>- <partial name="Partials/NewsLetterCategories" model="Model.NewsletterCategories" />- }+ <fieldset class="form-group col-12 col-sm-6">+ <legend class="sr-only">@Loc["account.fields.fax"]</legend>+ @if (Model.FaxRequired)+ {+ <validation-provider tag="div" rules="required" name="Fax" v-slot="{ errors, classes }">+ <label asp-for="Fax" class="col-form-label">@Loc["Account.Fields.Fax"]:</label>+ <span class="required">*</span>+ <input asp-for="Fax" v-bind:class="[classes , 'form-control']" v-model="customer.Fax"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="Fax"></span>+ </validation-provider>+ }+ else+ {+ <label asp-for="Fax" class="col-form-label">@Loc["Account.Fields.Fax"]:</label>+ <input asp-for="Fax" class="form-control"/>+ <span asp-validation-for="Fax"></span>+ }+ </fieldset>+ }+ </div>+ </div>+}- @if (Model.CustomerAttributes.Any())- {- <partial name="Partials/CustomerAttributes" model="Model.CustomerAttributes" />- }- </fieldset>+@if (Model.NewsletterEnabled || Model.CustomerAttributes.Any())+{+ <div class="card mb-3">+ <h3 class="card-header">+ @Loc["Account.Options"]+ </h3>+ <div class="card-body">+ <fieldset class="form-fields">+ <legend class="sr-only">@Loc["account.fields.newsletter"]</legend>+ @if (Model.NewsletterEnabled)+ {+ <div class="form-group">+ <label for="Newsletter" class="ml-1 custom-control custom-checkbox">+ <input class="custom-control-input" asp-for="Newsletter" onchange="toggleNewsletterCat()"/>+ <span class="custom-control-label">@Loc["account.fields.newsletter"]</span>+ <span class="sr-only">@Loc["account.fields.newsletter"]</span>+ </label>+ <span asp-validation-for="Newsletter"></span></div>- </div>- }- @if (Model.NumberOfExternalAuthenticationProviders > 0)+ <partial name="Partials/NewsLetterCategories" model="Model.NewsletterCategories"/>+ }++ @if (Model.CustomerAttributes.Any())+ {+ <partial name="Partials/CustomerAttributes" model="Model.CustomerAttributes"/>+ }+ </fieldset>+ </div>+ </div>+}+@if (Model.NumberOfExternalAuthenticationProviders > 0)+{+ <div class="card mb-3">+ <h3 class="card-header">@Loc["Account.AssociatedExternalAuth"]</h3>+ <div class="card-body">+ @if (Model.AssociatedExternalAuthRecords.Count > 0){- <div class="card mb-3">- <h3 class="card-header">@Loc["Account.AssociatedExternalAuth"]</h3>- <div class="card-body">- @if (Model.AssociatedExternalAuthRecords.Count > 0)- {- //existing associated external records- <div class="table-responsive">- <table class="table table-hover">- <colgroup>- <col />- <col />- <col />- </colgroup>- <thead class="tab">- <tr>- <th class="auth-method-name">- @Loc["Account.AssociatedExternalAuth.AuthMethodName"]- </th>- <th class="email">- @Loc["Account.AssociatedExternalAuth.Email"]- </th>- <th class="external-id">- @Loc["Account.AssociatedExternalAuth.ExternalIdentifier"]- </th>- <th class="remove">- @Loc["Account.AssociatedExternalAuth.Remove"]- </th>- </tr>- </thead>- <tbody>- @foreach (var item in Model.AssociatedExternalAuthRecords)- {- <tr>- <td class="auth-method-name">- @item.AuthMethodName- </td>- <td class="email">- @item.Email- </td>- <td class="external-id">- @CommonHelper.EnsureMaximumLength(item.ExternalIdentifier, 40, "...")- </td>- <td class="remove">- <a href="#" onclick="removeexternalassociation('@item.Id')">@Loc["Account.AssociatedExternalAuth.Remove"]</a>- </td>- </tr>- }- </tbody>- </table>- </div>- }- @if (Model.NumberOfExternalAuthenticationProviders > Model.AssociatedExternalAuthRecords.Count)+ //existing associated external records+ <div class="table-responsive">+ <table class="table table-hover">+ <colgroup>+ <col/>+ <col/>+ <col/>+ </colgroup>+ <thead class="tab">+ <tr>+ <th class="auth-method-name">+ @Loc["Account.AssociatedExternalAuth.AuthMethodName"]+ </th>+ <th class="email">+ @Loc["Account.AssociatedExternalAuth.Email"]+ </th>+ <th class="external-id">+ @Loc["Account.AssociatedExternalAuth.ExternalIdentifier"]+ </th>+ <th class="remove">+ @Loc["Account.AssociatedExternalAuth.Remove"]+ </th>+ </tr>+ </thead>+ <tbody>+ @foreach (var item in Model.AssociatedExternalAuthRecords){- //we can add more external records- <div class="form-fields add-more-external-records">- @Loc["Account.AssociatedExternalAuth.AddMoreRecords"] <a href="@Url.RouteUrl("Login", null, Context.Request.Scheme)">@Url.RouteUrl("Login", null, Context.Request.Scheme)</a>- </div>+ <tr>+ <td class="auth-method-name">+ @item.AuthMethodName+ </td>+ <td class="email">+ @item.Email+ </td>+ <td class="external-id">+ @CommonHelper.EnsureMaximumLength(item.ExternalIdentifier, 40, "...")+ </td>+ <td class="remove">+ <a href="#" onclick="removeexternalassociation('@item.Id')">@Loc["Account.AssociatedExternalAuth.Remove"]</a>+ </td>+ </tr>}- </div>+ </tbody>+ </table></div>}-- @if (customerSettings.TwoFactorAuthenticationEnabled)+ @if (Model.NumberOfExternalAuthenticationProviders > Model.AssociatedExternalAuthRecords.Count){- <div class="card mb-3">- <h3 class="card-header">@Loc["Account.TwoFactorAuth"]</h3>- @if (Model.Is2faEnabled)- {- @Html.ActionLink(Loc["Account.TwoFactorAuth.Disable"], "DisableTwoFactorAuthenticator", "Account", new object { }, new { @class = "btn btn-info login-button" })- }- else- {- @Html.ActionLink(Loc["Account.TwoFactorAuth.Enable"], "EnableTwoFactorAuthenticator", "Account", new object { }, new { @class = "btn btn-info login-button" })- }+ //we can add more external records+ <div class="form-fields add-more-external-records">+ @Loc["Account.AssociatedExternalAuth.AddMoreRecords"] <a href="@Url.RouteUrl("Login", null, Context.Request.Scheme)">@Url.RouteUrl("Login", null, Context.Request.Scheme)</a></div>}- <div class="generalMarginSupporter">- <input type="submit" value="@Loc["Common.Save"]" name="save-info-button" class="btn btn-info save-customer-info-button" />- </div>- </form>- </validation-observer>+ </div>+ </div>+}++@if (customerSettings.TwoFactorAuthenticationEnabled)+{+ <div class="card mb-3">+ <h3 class="card-header">@Loc["Account.TwoFactorAuth"]</h3>+ @if (Model.Is2faEnabled)+ {+ @Html.ActionLink(Loc["Account.TwoFactorAuth.Disable"], "DisableTwoFactorAuthenticator", "Account", new object(), new { @class = "btn btn-info login-button" })+ }+ else+ {+ @Html.ActionLink(Loc["Account.TwoFactorAuth.Enable"], "EnableTwoFactorAuthenticator", "Account", new object(), new { @class = "btn btn-info login-button" })+ }+ </div>+}+<div class="generalMarginSupporter">+ <input type="submit" value="@Loc["Common.Save"]" name="save-info-button" class="btn btn-info save-customer-info-button"/>+</div>+</form>+</validation-observer></div><script asp-location="Footer" asp-order="300">var customer = new Vue({data: () => ({@{- <text>+ <text>FirstName: '@Html.Raw(Model.FirstName)',LastName: '@Html.Raw(Model.LastName)',Company: '@Html.Raw(Model.Company)',@@ -603,27 +610,31 @@Email: '@Html.Raw(Model.Email)',@foreach (var item in Model.CustomerAttributes){- @switch (item.AttributeControlType)+ @switch (item.AttributeControlType)+ {+ case AttributeControlType.DropdownList:{- case AttributeControlType.DropdownList:+ @foreach (var itemValue in item.Values){- @foreach (var itemValue in item.Values)+ if (itemValue.IsPreSelected){- if (itemValue.IsPreSelected)- {- <text>customer_attribute_</text> @item.Id <text>: '@itemValue.Id',</text>- break;- } else {- <text>customer_attribute_</text> @item.Id <text>: '',</text>- }+ <text>customer_attribute_</text>+ @item.Id+ <text>: '@itemValue.Id',</text>+ break;}++ @:customer_attribute_ @item.Id : '',}+ }break;- case AttributeControlType.Checkboxes:- case AttributeControlType.RadioList:- case AttributeControlType.ReadonlyCheckboxes:- {- <text>customer_attribute_</text> @item.Id <text>: [+ case AttributeControlType.Checkboxes:+ case AttributeControlType.RadioList:+ case AttributeControlType.ReadonlyCheckboxes:+ {+ <text>customer_attribute_</text>+ @item.Id+ <text>: [@foreach (var itemValue in item.Values){if (itemValue.IsPreSelected)@@ -632,19 +643,26 @@}}],</text>- }- break;- case AttributeControlType.TextBox:- case AttributeControlType.MultilineTextbox:- {- <text>customer_attribute_</text> @item.Id <text>: @if (item.DefaultValue != null) { <text>'@item.DefaultValue'</text> } else { <text>''</text> },</text>- }+ }break;+ case AttributeControlType.TextBox:+ case AttributeControlType.MultilineTextbox:+ {+ <text>customer_attribute_</text>+ @item.Id+ <text>: @if (item.DefaultValue != null)+ {+ <text>'@item.DefaultValue'</text>+ }+ else+ {+ <text>''</text>+ },</text>}-- }- </text>- }+ break;+ }+ }+ </text>}}),created() {document.addEventListener("DOMContentLoaded", function () {diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/Login.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/Login.cshtmlindex d502e795a..c8cb205d9 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/Login.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/Login.cshtml@@ -7,10 +7,12 @@pagebuilder.AddTitleParts(Loc["Title.Login"]);//register URL with return URL (if specified)- var registerUrl = Url.RouteUrl("Register", new { returnUrl = this.Context.Request.Query["returnUrl"] });+ var registerUrl = Url.RouteUrl("Register", new { returnUrl = Context.Request.Query["returnUrl"] });}<div class="page login-page">- <h2 class="generalTitle text-center mt-3"><div>@Loc["Account.Login.Welcome"]</div></h2>+ <h2 class="generalTitle text-center mt-3">+ <div>@Loc["Account.Login.Welcome"]</div>+ </h2><div cols="12"><div class="my-3">@* login main block *@@@ -34,7 +36,7 @@</div><div class="col-lg-9 col-12"><validation-provider tag="div" rules="required" name="UserName" v-slot="{ errors, classes }">- <input asp-for="Username" v-model="login.Username" v-bind:class="[classes , 'form-control']" />+ <input asp-for="Username" v-model="login.Username" v-bind:class="[classes , 'form-control']"/><span class="field-validation-error">{{ errors[0] }}</span><span asp-validation-for="Username"></span></validation-provider>@@ -49,7 +51,7 @@</div><div class="col-lg-9 col-12"><validation-provider tag="div" rules="required|email" name="Email" v-slot="{ errors, classes }">- <input asp-for="Email" v-model="login.Email" v-bind:class="[classes , 'form-control']" />+ <input asp-for="Email" v-model="login.Email" v-bind:class="[classes , 'form-control']"/><span class="field-validation-error">{{ errors[0] }}</span><span asp-validation-for="Email"></span></validation-provider>@@ -63,7 +65,7 @@</div><div class="col-lg-9 col-12"><validation-provider tag="div" rules="required" name="Password" v-slot="{ errors, classes }">- <input asp-for="Password" v-model="login.Password" v-bind:class="[classes , 'form-control']" />+ <input asp-for="Password" v-model="login.Password" v-bind:class="[classes , 'form-control']"/><span class="field-validation-error">{{ errors[0] }}</span><span asp-validation-for="Password"></span></validation-provider>@@ -71,7 +73,7 @@</div><div class="inputs d-flex flex-sm-row flex-column justify-content-center"><label class="custom-control custom-checkbox">- <input class="custom-control-input" asp-for="RememberMe" />+ <input class="custom-control-input" asp-for="RememberMe"/><input class="custom-control-label" name="RememberMe" type="hidden" value="false"><span class="custom-control-label"></span><span class="custom-control-description">@Loc["Account.Login.Fields.RememberMe"]</span>@@ -83,7 +85,7 @@@if (Model.DisplayCaptcha){<div class="captcha-box">- <captcha />+ <captcha/></div>}</div>diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/Notes.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/Notes.cshtmlindex f416b1cbf..ca93ef346 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/Notes.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/Notes.cshtml@@ -5,13 +5,16 @@//titlepagebuilder.AddTitleParts(Loc["Title.Notes"]);}+@section left{@await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = AccountNavigationEnum.Notes })}<div class="page account-page auction-list-page pl-lg-3 pt-3 pt-lg-0">- <h1 class="h2 generalTitle"><div>@Loc["Account.CustomerNotes"]</div></h1>+ <h1 class="h2 generalTitle">+ <div>@Loc["Account.CustomerNotes"]</div>+ </h1><a class="left-side-toggler mb-3" onclick="sideToggle()"><div class="inner"><span></span>@@ -46,7 +49,7 @@<div class="d-inline-flex"><span class="mb-2"><b-label class="col-form-label">@Loc["Account.CustomerNotes.Attachment"]:</b-label>- <b-link class="mx-2" href="@Url.RouteUrl("GetCustomerNoteFile", new { customerNoteId = item.NoteId})">@Loc["Customer.Notes.Download"]</b-link>+ <b-link class="mx-2" href="@Url.RouteUrl("GetCustomerNoteFile", new { customerNoteId = item.NoteId })">@Loc["Customer.Notes.Download"]</b-link></span></div>}diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/PasswordRecovery.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/PasswordRecovery.cshtmlindex 0719ea65a..f662bfe15 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/PasswordRecovery.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/PasswordRecovery.cshtml@@ -7,8 +7,10 @@pagebuilder.AddTitleParts(Loc["Title.PasswordRecovery"]);}<div class="page password-recovery-page">- <h1 class="generalTitle h2"><div>@Loc["Account.PasswordRecovery"]</div></h1>- @if (!String.IsNullOrEmpty(Model.Result))+ <h1 class="generalTitle h2">+ <div>@Loc["Account.PasswordRecovery"]</div>+ </h1>+ @if (!string.IsNullOrEmpty(Model.Result)){<div class="result alert alert-info mt-3">@Model.Result@@ -18,12 +20,12 @@{<validation-observer v-slot="{ handleSubmit }"><form asp-route="PasswordRecovery" method="post" ref="form" v-on:submit.prevent="handleSubmit(formSubmit)">- <input type="hidden" asp-for="DisplayCaptcha" />+ <input type="hidden" asp-for="DisplayCaptcha"/><div asp-validation-summary="All" class="message-error"></div><div class="form-group"><validation-provider tag="div" rules="required|email" name="Email" v-slot="{ errors, classes }"><label asp-for="Email" class="col-form-label">@Loc["Account.PasswordRecovery.Email"]:</label>- <input asp-for="Email" v-model="passwordrecovery.Email" v-bind:class="[classes , 'form-control']" />+ <input asp-for="Email" v-model="passwordrecovery.Email" v-bind:class="[classes , 'form-control']"/><span class="field-validation-error">{{ errors[0] }}</span><span asp-validation-for="Email"></span></validation-provider>@@ -32,7 +34,7 @@{<div class="form-group"><div class="captcha-box">- <captcha />+ <captcha/></div></div>}diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/Register.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/Register.cshtmlindex 128609b11..233cdc1c0 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/Register.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/Register.cshtml@@ -65,456 +65,459 @@</script><validation-observer v-slot="{ handleSubmit }">- <form asp-route="Register" asp-route-returnurl="@Context.Request.Query["ReturnUrl"]" method="post" ref="form" v-on:submit.prevent="handleSubmit(formSubmit)">- <div class="page registration-page">- <div asp-validation-summary="All" class="message-error"></div>- <div class="card my-3">- <div class="card-header">- <h3 class="h5 mb-0">@Loc["Account.YourPersonalDetails"]</h3>+<form asp-route="Register" asp-route-returnurl="@Context.Request.Query["ReturnUrl"]" method="post" ref="form" v-on:submit.prevent="handleSubmit(formSubmit)">+<div class="page registration-page">+<div asp-validation-summary="All" class="message-error"></div>+<div class="card my-3">+ <div class="card-header">+ <h3 class="h5 mb-0">@Loc["Account.YourPersonalDetails"]</h3>+ </div>+ <div class="card-body">+ @if (Model.GenderEnabled)+ {+ <div class="row">+ <div class="col-lg-3 col-sm-12">+ <span>@Loc["Account.Fields.Gender"]:</span></div>- <div class="card-body">- @if (Model.GenderEnabled)- {- <div class="row">- <div class="col-lg-3 col-sm-12">- <span>@Loc["Account.Fields.Gender"]:</span>- </div>- </div>- <fieldset class="gender px-3">- <legend class="sr-only">@Loc["Account.Fields.Gender"]</legend>- <div class="d-flex row">- <label class="male custom-control custom-radio">- <input id="gender-male" name="Gender" type="radio" value="M" checked="@(Model.Gender == "M")" class="custom-control-input">- <span class="custom-control-label"></span>- <span class="forcheckbox custom-control-description">@Loc["Account.Fields.Gender.Male"]</span>- </label>- <label class="female custom-control custom-radio ml-2">- <input id="gender-female" name="Gender" type="radio" value="F" checked="@(Model.Gender == "F")" class="custom-control-input">- <span class="custom-control-label"></span>- <span class="forcheckbox custom-control-description">@Loc["Account.Fields.Gender.Female"]</span>- </label>- </div>- </fieldset>- }- <div class="form-row">- <fieldset class="col-sm-6 col-12 form-group">- <legend class="sr-only">@Loc["account.fields.firstname"]</legend>- @if (Model.FirstLastNameRequired)- {- <validation-provider tag="div" rules="required" name="FirstName" v-slot="{ errors, classes }">- <label asp-for="FirstName" class="col-form-label">@Loc["Account.Fields.FirstName"]:</label>- <span class="required">*</span>- <input asp-for="FirstName" v-model="customer.FirstName" v-bind:class="[classes , 'form-control']" />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="FirstName"></span>- </validation-provider>- }- else- {- <label asp-for="FirstName" class="col-form-label">@Loc["Account.Fields.FirstName"]:</label>- <input asp-for="FirstName" class="form-control" />- }- </fieldset>- <fieldset class="col-sm-6 col-12 form-group">- <legend class="sr-only">@Loc["account.fields.lastname"]</legend>- @if (Model.FirstLastNameRequired)- {- <validation-provider tag="div" rules="required" name="LastName" v-slot="{ errors, classes }">- <label asp-for="LastName" class="col-form-label">@Loc["Account.Fields.LastName"]:</label>- <span class="required">*</span>- <input asp-for="LastName" v-model="customer.LastName" v-bind:class="[classes , 'form-control']" />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="LastName"></span>- </validation-provider>- }- else- {- <label asp-for="LastName" class="col-form-label">@Loc["Account.Fields.LastName"]:</label>- <input asp-for="LastName" class="form-control" />- }- </fieldset>- </div>+ </div>+ <fieldset class="gender px-3">+ <legend class="sr-only">@Loc["Account.Fields.Gender"]</legend>+ <div class="d-flex row">+ <label class="male custom-control custom-radio">+ <input id="gender-male" name="Gender" type="radio" value="M" checked="@(Model.Gender == "M")" class="custom-control-input">+ <span class="custom-control-label"></span>+ <span class="forcheckbox custom-control-description">@Loc["Account.Fields.Gender.Male"]</span>+ </label>+ <label class="female custom-control custom-radio ml-2">+ <input id="gender-female" name="Gender" type="radio" value="F" checked="@(Model.Gender == "F")" class="custom-control-input">+ <span class="custom-control-label"></span>+ <span class="forcheckbox custom-control-description">@Loc["Account.Fields.Gender.Female"]</span>+ </label>+ </div>+ </fieldset>+ }+ <div class="form-row">+ <fieldset class="col-sm-6 col-12 form-group">+ <legend class="sr-only">@Loc["account.fields.firstname"]</legend>+ @if (Model.FirstLastNameRequired)+ {+ <validation-provider tag="div" rules="required" name="FirstName" v-slot="{ errors, classes }">+ <label asp-for="FirstName" class="col-form-label">@Loc["Account.Fields.FirstName"]:</label>+ <span class="required">*</span>+ <input asp-for="FirstName" v-model="customer.FirstName" v-bind:class="[classes , 'form-control']"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="FirstName"></span>+ </validation-provider>+ }+ else+ {+ <label asp-for="FirstName" class="col-form-label">@Loc["Account.Fields.FirstName"]:</label>+ <input asp-for="FirstName" class="form-control"/>+ }+ </fieldset>+ <fieldset class="col-sm-6 col-12 form-group">+ <legend class="sr-only">@Loc["account.fields.lastname"]</legend>+ @if (Model.FirstLastNameRequired)+ {+ <validation-provider tag="div" rules="required" name="LastName" v-slot="{ errors, classes }">+ <label asp-for="LastName" class="col-form-label">@Loc["Account.Fields.LastName"]:</label>+ <span class="required">*</span>+ <input asp-for="LastName" v-model="customer.LastName" v-bind:class="[classes , 'form-control']"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="LastName"></span>+ </validation-provider>+ }+ else+ {+ <label asp-for="LastName" class="col-form-label">@Loc["Account.Fields.LastName"]:</label>+ <input asp-for="LastName" class="form-control"/>+ }+ </fieldset>+ </div>- @if (Model.DateOfBirthEnabled)+ @if (Model.DateOfBirthEnabled)+ {+ <fieldset class="form-group date-of-birth col-sm-12">+ <legend class="sr-only">@Loc["Account.Fields.DateOfBirth"]</legend>+ <div class="row">+ <span class="col-form-label col-12 py-0 px-0">@Loc["Account.Fields.DateOfBirth"]:<span class="required">*</span></span>+ <date-picker-dropdown control-day="@Html.IdFor(x => x.DateOfBirthDay)"+ control-month="@Html.IdFor(x => x.DateOfBirthMonth)"+ control-year="@Html.IdFor(x => x.DateOfBirthYear)"+ begin-year="@(DateTime.Now.Year - 100)"+ end-year="DateTime.Now.Year"+ selected-day="Model.DateOfBirthDay ?? 0"+ selected-month="Model.DateOfBirthMonth ?? 0"+ selected-year="Model.DateOfBirthYear ?? 0"+ class="col-12 input-group px-0"/>+ </div>+ <div class="row">+ <span asp-validation-for="DateOfBirthDay"></span>+ <span asp-validation-for="DateOfBirthMonth"></span>+ <span asp-validation-for="DateOfBirthYear"></span>+ </div>+ </fieldset>+ }+ <fieldset class="form-group mail">+ <legend class="sr-only">@Loc["account.fields.email"]</legend>+ <validation-provider tag="div" rules="required" name="Email" v-slot="{ errors, classes }">+ <label asp-for="Email" class="col-form-label">@Loc["Account.Fields.Email"]:</label>+ <span class="required">*</span>+ <input asp-for="Email" v-model="customer.Email" v-bind:class="[classes , 'form-control']"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="Email"></span>+ </validation-provider>+ </fieldset>++ @if (Model.UsernamesEnabled)+ {+ <div class="form-group row">+ <div class="col-12">+ <label asp-for="Username" class="col-form-label">@Loc["Account.Fields.Username"]:</label>+ <span class="required">*</span>+ </div>+ <div class="col-12">+ <validation-provider tag="div" rules="required" name="Username" v-slot="{ errors, classes }">+ <input asp-for="Username" v-model="customer.Username" v-bind:class="[classes , 'form-control']"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="Username"></span>+ </validation-provider>+ @if (Model.CheckUsernameAvailabilityEnabled){- <fieldset class="form-group date-of-birth col-sm-12">- <legend class="sr-only">@Loc["Account.Fields.DateOfBirth"]</legend>- <div class="row">- <span class="col-form-label col-12 py-0 px-0">@Loc["Account.Fields.DateOfBirth"]:<span class="required">*</span></span>- <date-picker-dropdown control-day="@Html.IdFor(x => x.DateOfBirthDay)"- control-month="@Html.IdFor(x => x.DateOfBirthMonth)"- control-year="@Html.IdFor(x => x.DateOfBirthYear)"- begin-year="@(DateTime.Now.Year - 100)"- end-year="DateTime.Now.Year"- selected-day="Model.DateOfBirthDay ?? 0"- selected-month="Model.DateOfBirthMonth ?? 0"- selected-year="Model.DateOfBirthYear ?? 0"- class="col-12 input-group px-0" />- </div>- <div class="row">- <span asp-validation-for="DateOfBirthDay"></span>- <span asp-validation-for="DateOfBirthMonth"></span>- <span asp-validation-for="DateOfBirthYear"></span>- </div>- </fieldset>+ <partial name="Partials/CheckUsernameAvailability"/>}- <fieldset class="form-group mail">- <legend class="sr-only">@Loc["account.fields.email"]</legend>- <validation-provider tag="div" rules="required" name="Email" v-slot="{ errors, classes }">- <label asp-for="Email" class="col-form-label">@Loc["Account.Fields.Email"]:</label>+ </div>+ </div>+ }+ </div>+</div>++@if (Model.CompanyEnabled)+{+ <div class="card mb-3" no-footer>+ <div class="card-header">+ <h3 class="h5 mb-0">@Loc["Account.CompanyDetails"]</h3>+ </div>+ <div class="card-body">+ <div class="form-group">+ @if (Model.CompanyRequired)+ {+ <validation-provider tag="div" rules="required" name="Company" v-slot="{ errors, classes }">+ <label asp-for="Company" class="col-form-label">@Loc["Account.Fields.Company"]:</label>+ <span class="required">*</span>+ <input asp-for="Company" v-model="customer.Company" v-bind:class="[classes , 'form-control']"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="Company"></span>+ </validation-provider>+ }+ else+ {+ <label asp-for="Company" class="col-form-label">@Loc["Account.Fields.Company"]:</label>+ <input asp-for="Company" class="form-control"/>+ <span asp-validation-for="Company"></span>+ }+ </div>+ </div>+ </div>+}+@if (Model.DisplayVatNumber)+{+ <div class="card mb-3">+ <div class="card-body">+ <div class="form-group">+ <label asp-for="VatNumber" class="col-form-label">@Loc["Account.Fields.VatNumber"]:</label>+ <input asp-for="VatNumber" class="form-control"/>+ <span class="vat-note">+ <em>@Loc["Account.Fields.VatNumber.Note"]</em>+ </span>+ <span asp-validation-for="VatNumber"></span>+ </div>+ </div>+ </div>+}+@if (Model.StreetAddressEnabled ||+ Model.StreetAddress2Enabled ||+ Model.ZipPostalCodeEnabled ||+ Model.CityEnabled ||+ Model.CountryEnabled)+{+ <div class="card mb-3">+ <div class="card-header">+ <h3 class="h5 mb-0">+ @Loc["Account.YourAddress"]+ </h3>+ </div>+ <div class="card-body">+ <div class="row form-fields d-flex">+ @if (Model.StreetAddressEnabled)+ {+ <fieldset class="form-group col-12 col-sm-6">+ <legend class="sr-only">@Loc["account.fields.streetaddress"]</legend>+ @if (Model.StreetAddressRequired)+ {+ <validation-provider tag="div" rules="required" name="StreetAddress" v-slot="{ errors, classes }">+ <label asp-for="StreetAddress" class="col-form-label">@Loc["Account.Fields.StreetAddress"]:</label>+ <span class="required">*</span>+ <input asp-for="StreetAddress" v-model="customer.StreetAddress" v-bind:class="[classes , 'form-control']"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="StreetAddress"></span>+ </validation-provider>+ }+ else+ {+ <label asp-for="StreetAddress" class="col-form-label">@Loc["Account.Fields.StreetAddress"]:</label>+ <input asp-for="StreetAddress" class="form-control"/>+ <span asp-validation-for="StreetAddress"></span>+ }+ </fieldset>+ }+ @if (Model.StreetAddress2Enabled)+ {+ <fieldset class="form-group col-12 col-sm-6">+ <legend class="sr-only">@Loc["account.fields.streetaddress2"]</legend>+ @if (Model.StreetAddress2Required)+ {+ <validation-provider tag="div" rules="required" name="StreetAddress2" v-slot="{ errors, classes }">+ <label asp-for="StreetAddress2" class="col-form-label">@Loc["Account.Fields.StreetAddress2"]:</label>+ <span class="required">*</span>+ <input asp-for="StreetAddress2" v-model="customer.StreetAddress2" v-bind:class="[classes , 'form-control']"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="StreetAddress2"></span>+ </validation-provider>+ }+ else+ {+ <label asp-for="StreetAddress2" class="col-form-label">@Loc["Account.Fields.StreetAddress2"]:</label>+ <input asp-for="StreetAddress2" class="form-control"/>+ <span asp-validation-for="StreetAddress2"></span>+ }+ </fieldset>+ }+ @if (Model.ZipPostalCodeEnabled)+ {+ <fieldset class="form-group col-12 col-sm-6">+ <legend class="sr-only">@Loc["account.fields.zippostalcode"]</legend>+ @if (Model.ZipPostalCodeRequired)+ {+ <validation-provider tag="div" rules="required" name="ZipPostalCode" v-slot="{ errors, classes }">+ <label asp-for="ZipPostalCode" class="col-form-label">@Loc["Account.Fields.ZipPostalCode"]:</label>+ <span class="required">*</span>+ <input asp-for="ZipPostalCode" v-model="customer.ZipPostalCode" v-bind:class="[classes , 'form-control']"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="ZipPostalCode"></span>+ </validation-provider>+ }+ else+ {+ <label asp-for="ZipPostalCode" class="col-form-label">@Loc["Account.Fields.ZipPostalCode"]:</label>+ <input asp-for="ZipPostalCode" class="form-control"/>+ <span asp-validation-for="ZipPostalCode"></span>+ }+ </fieldset>+ }+ @if (Model.CityEnabled)+ {+ <fieldset class="form-group col-12 col-sm-6">+ <legend class="sr-only">@Loc["account.fields.city"]</legend>+ @if (Model.CityRequired)+ {+ <validation-provider tag="div" rules="required" name="City" v-slot="{ errors, classes }">+ <label asp-for="City" class="col-form-label">@Loc["Account.Fields.City"]:</label>+ <span class="required">*</span>+ <input asp-for="City" v-model="customer.City" v-bind:class="[classes , 'form-control']"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="City"></span>+ </validation-provider>+ }+ else+ {+ <label asp-for="City" class="col-form-label">@Loc["Account.Fields.City"]:</label>+ <input asp-for="City" class="form-control"/>+ <span asp-validation-for="City"></span>+ }+ </fieldset>+ }+ @if (Model.CountryEnabled)+ {+ <fieldset class="form-group col-12 col-sm-6">+ <legend class="sr-only">@Loc["account.fields.country"]</legend>+ @if (Model.CountryRequired)+ {+ <validation-provider tag="div" rules="required" name="CountryId" v-slot="{ errors, classes }">+ <label asp-for="CountryId" class="col-form-label">@Loc["Account.Fields.Country"]:</label>+ <span class="required">*</span>+ <select asp-for="CountryId" asp-items="Model.AvailableCountries"+ onchange="@Html.IdFor(model => model.CountryId)_select_element(this)" v-bind:class="[classes , 'form-control custom-select']" v-model="customer.CountryId">+ </select>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="CountryId"></span>+ </validation-provider>+ }+ else+ {+ <label asp-for="CountryId" class="col-form-label">@Loc["Account.Fields.Country"]:</label>+ <select asp-for="CountryId" class="custom-select form-control" asp-items="Model.AvailableCountries"></select>+ <span asp-validation-for="CountryId"></span>+ }+ </fieldset>+ }+ @if (Model.CountryEnabled && Model.StateProvinceEnabled)+ {+ <fieldset class="form-group col-12 col-sm-6">+ <legend class="sr-only">@Loc["account.fields.stateprovince"]</legend>+ <validation-provider tag="div" rules="required" name="StateProvinceId" v-slot="{ errors, classes }">+ <label asp-for="StateProvinceId" class="col-form-label">@Loc["Account.Fields.StateProvince"]:</label><span class="required">*</span>- <input asp-for="Email" v-model="customer.Email" v-bind:class="[classes , 'form-control']" />+ <select asp-for="StateProvinceId" data-val-required="@Loc["Address.Fields.StateProvince.Required"]" v-bind:class="[classes , 'form-control custom-select']"+ onchange="@Html.IdFor(model => model.StateProvinceId)_select_element(this)" asp-items="Model.AvailableStates" v-model="customer.StateProvinceId">+ </select><span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="Email"></span>+ <span asp-validation-for="StateProvinceId"></span>+ <span id="states-loading-progress" style="display: none;" class="please-wait">@Loc["Common.Wait..."]</span></validation-provider></fieldset>+ }+ </div>+ </div>+ </div>+}- @if (Model.UsernamesEnabled)- {- <div class="form-group row">- <div class="col-12">- <label asp-for="Username" class="col-form-label">@Loc["Account.Fields.Username"]:</label>+@if (Model.PhoneEnabled || Model.FaxEnabled)+{+ <div class="card mb-3">+ <div class="card-header">+ <h3 class="h5 mb-0">@Loc["Account.YourContactInformation"]</h3>+ </div>+ <div class="card-body">+ <div class="row d-flex">+ @if (Model.PhoneEnabled)+ {+ <fieldset class="form-group col-12 col-sm-6">+ <legend class="sr-only">@Loc["account.fields.phone"]</legend>+ @if (Model.PhoneRequired)+ {+ <validation-provider tag="div" rules="required" name="Phone" v-slot="{ errors, classes }">+ <label asp-for="Phone" class="col-form-label">@Loc["Account.Fields.Phone"]:</label><span class="required">*</span>- </div>- <div class="col-12">- <validation-provider tag="div" rules="required" name="Username" v-slot="{ errors, classes }">- <input asp-for="Username" v-model="customer.Username" v-bind:class="[classes , 'form-control']" />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="Username"></span>- </validation-provider>- @if (Model.CheckUsernameAvailabilityEnabled)- {- <partial name="Partials/CheckUsernameAvailability" />- }- </div>- </div>- }- </div>+ <input asp-for="Phone" v-model="customer.Phone" v-bind:class="[classes , 'form-control']"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="Phone"></span>+ </validation-provider>+ }+ else+ {+ <label asp-for="Phone" class="col-form-label">@Loc["Account.Fields.Phone"]:</label>+ <input asp-for="Phone" class="form-control"/>+ <span asp-validation-for="Phone"></span>+ }+ </fieldset>+ }+ @if (Model.FaxEnabled)+ {+ <fieldset class="form-group col-12 col-sm-6">+ <legend class="sr-only">@Loc["account.fields.fax"]</legend>+ @if (Model.FaxRequired)+ {+ <validation-provider tag="div" rules="required" name="Fax" v-slot="{ errors, classes }">+ <label asp-for="Fax" class="col-form-label">@Loc["Account.Fields.Fax"]:</label>+ <span class="required">*</span>+ <input asp-for="Fax" v-model="customer.Fax" v-bind:class="[classes , 'form-control']"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="Fax"></span>+ </validation-provider>+ }+ else+ {+ <label asp-for="Fax" class="col-form-label">@Loc["Account.Fields.Fax"]:</label>+ <input asp-for="Fax" class="form-control"/>+ <span asp-validation-for="Fax"></span>+ }+ </fieldset>+ }</div>+ </div>+ </div>+}- @if (Model.CompanyEnabled)- {- <div class="card mb-3" no-footer>- <div class="card-header">- <h3 class="h5 mb-0">@Loc["Account.CompanyDetails"]</h3>- </div>- <div class="card-body">- <div class="form-group">- @if (Model.CompanyRequired)- {- <validation-provider tag="div" rules="required" name="Company" v-slot="{ errors, classes }">- <label asp-for="Company" class="col-form-label">@Loc["Account.Fields.Company"]:</label>- <span class="required">*</span>- <input asp-for="Company" v-model="customer.Company" v-bind:class="[classes , 'form-control']" />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="Company"></span>- </validation-provider>- }- else- {- <label asp-for="Company" class="col-form-label">@Loc["Account.Fields.Company"]:</label>- <input asp-for="Company" class="form-control" />- <span asp-validation-for="Company"></span>- }- </div>- </div>- </div>- }- @if (Model.DisplayVatNumber)- {- <div class="card mb-3">- <div class="card-body">- <div class="form-group">- <label asp-for="VatNumber" class="col-form-label">@Loc["Account.Fields.VatNumber"]:</label>- <input asp-for="VatNumber" class="form-control" />- <span class="vat-note"><em>@Loc["Account.Fields.VatNumber.Note"]</em></span>- <span asp-validation-for="VatNumber"></span>- </div>- </div>- </div>- }- @if (Model.StreetAddressEnabled ||- Model.StreetAddress2Enabled ||- Model.ZipPostalCodeEnabled ||- Model.CityEnabled ||- Model.CountryEnabled)- {- <div class="card mb-3">- <div class="card-header">- <h3 class="h5 mb-0">- @Loc["Account.YourAddress"]- </h3>- </div>- <div class="card-body">- <div class="row form-fields d-flex">- @if (Model.StreetAddressEnabled)- {- <fieldset class="form-group col-12 col-sm-6">- <legend class="sr-only">@Loc["account.fields.streetaddress"]</legend>- @if (Model.StreetAddressRequired)- {- <validation-provider tag="div" rules="required" name="StreetAddress" v-slot="{ errors, classes }">- <label asp-for="StreetAddress" class="col-form-label">@Loc["Account.Fields.StreetAddress"]:</label>- <span class="required">*</span>- <input asp-for="StreetAddress" v-model="customer.StreetAddress" v-bind:class="[classes , 'form-control']" />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="StreetAddress"></span>- </validation-provider>- }- else- {- <label asp-for="StreetAddress" class="col-form-label">@Loc["Account.Fields.StreetAddress"]:</label>- <input asp-for="StreetAddress" class="form-control" />- <span asp-validation-for="StreetAddress"></span>- }- </fieldset>- }- @if (Model.StreetAddress2Enabled)- {- <fieldset class="form-group col-12 col-sm-6">- <legend class="sr-only">@Loc["account.fields.streetaddress2"]</legend>- @if (Model.StreetAddress2Required)- {- <validation-provider tag="div" rules="required" name="StreetAddress2" v-slot="{ errors, classes }">- <label asp-for="StreetAddress2" class="col-form-label">@Loc["Account.Fields.StreetAddress2"]:</label>- <span class="required">*</span>- <input asp-for="StreetAddress2" v-model="customer.StreetAddress2" v-bind:class="[classes , 'form-control']" />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="StreetAddress2"></span>- </validation-provider>- }- else- {- <label asp-for="StreetAddress2" class="col-form-label">@Loc["Account.Fields.StreetAddress2"]:</label>- <input asp-for="StreetAddress2" class="form-control" />- <span asp-validation-for="StreetAddress2"></span>- }- </fieldset>- }- @if (Model.ZipPostalCodeEnabled)- {- <fieldset class="form-group col-12 col-sm-6">- <legend class="sr-only">@Loc["account.fields.zippostalcode"]</legend>- @if (Model.ZipPostalCodeRequired)- {- <validation-provider tag="div" rules="required" name="ZipPostalCode" v-slot="{ errors, classes }">- <label asp-for="ZipPostalCode" class="col-form-label">@Loc["Account.Fields.ZipPostalCode"]:</label>- <span class="required">*</span>- <input asp-for="ZipPostalCode" v-model="customer.ZipPostalCode" v-bind:class="[classes , 'form-control']" />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="ZipPostalCode"></span>- </validation-provider>- }- else- {- <label asp-for="ZipPostalCode" class="col-form-label">@Loc["Account.Fields.ZipPostalCode"]:</label>- <input asp-for="ZipPostalCode" class="form-control" />- <span asp-validation-for="ZipPostalCode"></span>- }- </fieldset>- }- @if (Model.CityEnabled)- {- <fieldset class="form-group col-12 col-sm-6">- <legend class="sr-only">@Loc["account.fields.city"]</legend>- @if (Model.CityRequired)- {- <validation-provider tag="div" rules="required" name="City" v-slot="{ errors, classes }">- <label asp-for="City" class="col-form-label">@Loc["Account.Fields.City"]:</label>- <span class="required">*</span>- <input asp-for="City" v-model="customer.City" v-bind:class="[classes , 'form-control']" />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="City"></span>- </validation-provider>- }- else- {- <label asp-for="City" class="col-form-label">@Loc["Account.Fields.City"]:</label>- <input asp-for="City" class="form-control" />- <span asp-validation-for="City"></span>- }- </fieldset>- }- @if (Model.CountryEnabled)- {- <fieldset class="form-group col-12 col-sm-6">- <legend class="sr-only">@Loc["account.fields.country"]</legend>- @if (Model.CountryRequired)- {- <validation-provider tag="div" rules="required" name="CountryId" v-slot="{ errors, classes }">- <label asp-for="CountryId" class="col-form-label">@Loc["Account.Fields.Country"]:</label>- <span class="required">*</span>- <select asp-for="CountryId" asp-items="Model.AvailableCountries"- onchange="@Html.IdFor(model => model.CountryId)_select_element(this)" v-bind:class="[classes , 'form-control custom-select']" v-model="customer.CountryId"></select>- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="CountryId"></span>- </validation-provider>- }- else- {- <label asp-for="CountryId" class="col-form-label">@Loc["Account.Fields.Country"]:</label>- <select asp-for="CountryId" class="custom-select form-control" asp-items="Model.AvailableCountries"></select>- <span asp-validation-for="CountryId"></span>- }- </fieldset>- }- @if (Model.CountryEnabled && Model.StateProvinceEnabled)- {- <fieldset class="form-group col-12 col-sm-6">- <legend class="sr-only">@Loc["account.fields.stateprovince"]</legend>- <validation-provider tag="div" rules="required" name="StateProvinceId" v-slot="{ errors, classes }">- <label asp-for="StateProvinceId" class="col-form-label">@Loc["Account.Fields.StateProvince"]:</label>- <span class="required">*</span>- <select asp-for="StateProvinceId" data-val-required="@Loc["Address.Fields.StateProvince.Required"]" v-bind:class="[classes , 'form-control custom-select']"- onchange="@Html.IdFor(model => model.StateProvinceId)_select_element(this)" asp-items="Model.AvailableStates" v-model="customer.StateProvinceId"></select>- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="StateProvinceId"></span>- <span id="states-loading-progress" style="display: none;" class="please-wait">@Loc["Common.Wait..."]</span>- </validation-provider>- </fieldset>- }- </div>- </div>- </div>- }-- @if (Model.PhoneEnabled || Model.FaxEnabled)+@if (Model.NewsletterEnabled || Model.CustomerAttributes.Any())+{+ <div class="card mb-3">+ <div class="card-header">+ <h3 class="h5 mb-0">@Loc["Account.Options"]</h3>+ </div>+ <div class="card-body">+ @if (Model.NewsletterEnabled){- <div class="card mb-3">- <div class="card-header">- <h3 class="h5 mb-0">@Loc["Account.YourContactInformation"]</h3>- </div>- <div class="card-body">- <div class="row d-flex">- @if (Model.PhoneEnabled)- {- <fieldset class="form-group col-12 col-sm-6">- <legend class="sr-only">@Loc["account.fields.phone"]</legend>- @if (Model.PhoneRequired)- {- <validation-provider tag="div" rules="required" name="Phone" v-slot="{ errors, classes }">- <label asp-for="Phone" class="col-form-label">@Loc["Account.Fields.Phone"]:</label>- <span class="required">*</span>- <input asp-for="Phone" v-model="customer.Phone" v-bind:class="[classes , 'form-control']" />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="Phone"></span>- </validation-provider>- }- else- {- <label asp-for="Phone" class="col-form-label">@Loc["Account.Fields.Phone"]:</label>- <input asp-for="Phone" class="form-control" />- <span asp-validation-for="Phone"></span>- }- </fieldset>- }- @if (Model.FaxEnabled)- {- <fieldset class="form-group col-12 col-sm-6">- <legend class="sr-only">@Loc["account.fields.fax"]</legend>- @if (Model.FaxRequired)- {- <validation-provider tag="div" rules="required" name="Fax" v-slot="{ errors, classes }">- <label asp-for="Fax" class="col-form-label">@Loc["Account.Fields.Fax"]:</label>- <span class="required">*</span>- <input asp-for="Fax" v-model="customer.Fax" v-bind:class="[classes , 'form-control']" />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="Fax"></span>- </validation-provider>- }- else- {- <label asp-for="Fax" class="col-form-label">@Loc["Account.Fields.Fax"]:</label>- <input asp-for="Fax" class="form-control" />- <span asp-validation-for="Fax"></span>- }- </fieldset>- }- </div>- </div>+ <div class="form-group">+ <label for="Newsletter" class="ml-1 custom-control custom-checkbox">+ <input class="custom-control-input" asp-for="Newsletter" onchange="toggleNewsletterCat()"/>+ <span class="custom-control-label">@Loc["account.fields.newsletter"]</span>+ <span class="sr-only">@Loc["account.fields.newsletter"]</span>+ </label>+ <span asp-validation-for="Newsletter"></span></div>+ <partial name="Partials/NewsLetterCategories" model="Model.NewsletterCategories"/>}-- @if (Model.NewsletterEnabled || Model.CustomerAttributes.Any())+ @if (Model.CustomerAttributes.Any()){- <div class="card mb-3">- <div class="card-header">- <h3 class="h5 mb-0">@Loc["Account.Options"]</h3>- </div>- <div class="card-body">- @if (Model.NewsletterEnabled)- {- <div class="form-group">- <label for="Newsletter" class="ml-1 custom-control custom-checkbox">- <input class="custom-control-input" asp-for="Newsletter" onchange="toggleNewsletterCat()" />- <span class="custom-control-label">@Loc["account.fields.newsletter"]</span>- <span class="sr-only">@Loc["account.fields.newsletter"]</span>- </label>- <span asp-validation-for="Newsletter"></span>- </div>- <partial name="Partials/NewsLetterCategories" model="Model.NewsletterCategories" />- }- @if (Model.CustomerAttributes.Any())- {- <partial name="Partials/CustomerAttributes" model="Model.CustomerAttributes" />- }- </div>- </div>+ <partial name="Partials/CustomerAttributes" model="Model.CustomerAttributes"/>}- <div class="card mb-3">- <div class="card-header">- <h3 class="h5 mb-0">@Loc["Account.YourPassword"]</h3>- </div>- <div class="card-body">- <div class="form-group">- <validation-provider tag="div" vid="customer.Password" rules="required" v-slot="{ errors, classes }">- <label asp-for="Password" class="col-form-label">@Loc["Account.Fields.Password"]:</label>- <input asp-for="Password" v-model="customer.Password" v-bind:class="[classes , 'form-control']" />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="Password"></span>- </validation-provider>- </div>- <div class="form-group">- <validation-provider tag="div" vid="customer.ConfirmPassword" rules="required|confirmed:@@customer.Password" v-slot="{ errors, classes }">- <label asp-for="ConfirmPassword" class="col-form-label">@Loc["Account.Fields.ConfirmPassword"]:</label>- <input asp-for="ConfirmPassword" v-model="customer.ConfirmPassword" v-bind:class="[classes , 'form-control']" />- <span class="field-validation-error">{{ errors[0] }}</span>- <span asp-validation-for="ConfirmPassword"></span>- </validation-provider>- </div>- @if (Model.DisplayCaptcha)- {- <div class="captcha-box form-group">- <captcha />- </div>- }- </div>+ </div>+ </div>+}+<div class="card mb-3">+ <div class="card-header">+ <h3 class="h5 mb-0">@Loc["Account.YourPassword"]</h3>+ </div>+ <div class="card-body">+ <div class="form-group">+ <validation-provider tag="div" vid="customer.Password" rules="required" v-slot="{ errors, classes }">+ <label asp-for="Password" class="col-form-label">@Loc["Account.Fields.Password"]:</label>+ <input asp-for="Password" v-model="customer.Password" v-bind:class="[classes , 'form-control']"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="Password"></span>+ </validation-provider>+ </div>+ <div class="form-group">+ <validation-provider tag="div" vid="customer.ConfirmPassword" rules="required|confirmed:@@customer.Password" v-slot="{ errors, classes }">+ <label asp-for="ConfirmPassword" class="col-form-label">@Loc["Account.Fields.ConfirmPassword"]:</label>+ <input asp-for="ConfirmPassword" v-model="customer.ConfirmPassword" v-bind:class="[classes , 'form-control']"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ <span asp-validation-for="ConfirmPassword"></span>+ </validation-provider>+ </div>+ @if (Model.DisplayCaptcha)+ {+ <div class="captcha-box form-group">+ <captcha/></div>+ }+ </div>+</div>- @if (Model.AcceptPrivacyPolicyEnabled)- {-- <validation-provider tag="div" vid="customer.AcceptPrivacyPolicy" :rules="{ required: { allowFalse: false } }" v-slot="{ errors, classes }">- <div class="d-inline-flex">- <label class="custom-control custom-checkbox">- <input id="accept-privacy-policy" name="acceptprivacypolicy" v-model="customer.AcceptPrivacyPolicy" data-val="true" data-val-required="@Loc["account.fields.acceptprivacypolicy.required"]" type="checkbox" v-bind:class="[classes , 'custom-control-input']">- <span class="custom-control-label"></span>- <span class="custom-control-description">@Loc["Account.Fields.AcceptPrivacyPolicy"]</span>- </label>- <b-link class="read mx-2" onclick="window.open('@Url.RouteUrl("PagePopup", new { SystemName = "privacyinfo" })', 450, 500, true)">@Loc["Account.Fields.AcceptPrivacyPolicy.Read"]</b-link>- </div>- <span class="field-validation-error d-flex w-100">{{ errors[0] }}</span>- </validation-provider>- }+@if (Model.AcceptPrivacyPolicyEnabled)+{+ <validation-provider tag="div" vid="customer.AcceptPrivacyPolicy" :rules="{ required: { allowFalse: false } }" v-slot="{ errors, classes }">+ <div class="d-inline-flex">+ <label class="custom-control custom-checkbox">+ <input id="accept-privacy-policy" name="acceptprivacypolicy" v-model="customer.AcceptPrivacyPolicy" data-val="true" data-val-required="@Loc["account.fields.acceptprivacypolicy.required"]" type="checkbox" v-bind:class="[classes , 'custom-control-input']">+ <span class="custom-control-label"></span>+ <span class="custom-control-description">@Loc["Account.Fields.AcceptPrivacyPolicy"]</span>+ </label>+ <b-link class="read mx-2" onclick="window.open('@Url.RouteUrl("PagePopup", new { SystemName = "privacyinfo" })', 450, 500, true)">@Loc["Account.Fields.AcceptPrivacyPolicy.Read"]</b-link></div>- <input type="submit" id="register-button" class="btn btn-info register-next-step-button my-3" value="@Loc["Account.Register.Button"]" />- </form>+ <span class="field-validation-error d-flex w-100">{{ errors[0] }}</span>+ </validation-provider>+}+</div>+<input type="submit" id="register-button" class="btn btn-info register-next-step-button my-3" value="@Loc["Account.Register.Button"]"/>+</form></validation-observer><script asp-location="Footer" asp-order="300">var customer = new Vue({data: () => ({@{- <text>+ <text>FirstName: '@Html.Raw(Model.FirstName)',LastName: '@Html.Raw(Model.LastName)',Company: '@Html.Raw(Model.Company)',@@ -541,19 +544,23 @@{if (itemValue.IsPreSelected){- <text>customer_attribute_</text> @item.Id <text>: '@itemValue.Id',</text>+ <text>customer_attribute_</text>+ @item.Id+ <text>: '@itemValue.Id',</text>break;- } else {- <text>customer_attribute_</text> @item.Id <text>: '',</text>}++ @:customer_attribute_ @item.Id : '',}}- break;+ break;case AttributeControlType.Checkboxes:case AttributeControlType.RadioList:case AttributeControlType.ReadonlyCheckboxes:{- <text>customer_attribute_</text> @item.Id <text>: [+ <text>customer_attribute_</text>+ @item.Id+ <text>: [@foreach (var itemValue in item.Values){if (itemValue.IsPreSelected)@@ -563,18 +570,25 @@}],</text>}- break;+ break;case AttributeControlType.TextBox:case AttributeControlType.MultilineTextbox:{- <text>customer_attribute_</text> @item.Id <text>: @if (item.DefaultValue != null) { <text>'@item.DefaultValue'</text> } else { <text>''</text> },</text>+ <text>customer_attribute_</text>+ @item.Id+ <text>: @if (item.DefaultValue != null)+ {+ <text>'@item.DefaultValue'</text>+ }+ else+ {+ <text>''</text>+ },</text>}- break;+ break;}-}- </text>- }+ </text>}}),created() {document.addEventListener("DOMContentLoaded", function () {diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/Reviews.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/Reviews.cshtmlindex 687b11b4d..3de5dea26 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/Reviews.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/Reviews.cshtml@@ -6,12 +6,16 @@//titlepagebuilder.AddTitleParts(Loc["Title.Account"]);}+@section left{@await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = AccountNavigationEnum.Reviews })}+<div class="page account-page product-reviews-page pl-lg-3 pt-lg-0 pt-3">- <h1 class="h2 generalTitle"><div>@Loc["Account.Reviews"]</div></h1>+ <h1 class="h2 generalTitle">+ <div>@Loc["Account.Reviews"]</div>+ </h1><a class="left-side-toggler mb-3" onclick="sideToggle()"><div class="inner"><span></span>@@ -27,21 +31,23 @@<div class="product-review-list">@foreach (var review in Model.Reviews){- int ratingStars = review.Rating;+ var ratingStars = review.Rating;<div class="card product-review-item mb-3"><header class="card-header"><div class="review-info d-inline-flex w-100"><b-icon icon="calendar2-check" variant="info" class="mx-2"></b-icon><small class="date d-flex text-muted">- <span class="mr-1">@Loc["Reviews.Date"]:</span>- <span>@review.CreatedOn.ToString("g")</span>+ <span class="mr-1">@Loc["Reviews.Date"]:</span>+ <span>@review.CreatedOn.ToString("g")</span></small></div></header><div class="card-body"><div class="review-title mb-3"><div class="user d-inline-flex align-items-center w-100">- <a href="@Url.RouteUrl("Product", new { SeName = review.ProductSeName })"><h6 class="mb-0">@review.ProductName</h6></a>+ <a href="@Url.RouteUrl("Product", new { SeName = review.ProductSeName })">+ <h6 class="mb-0">@review.ProductName</h6>+ </a></div><b-form-rating id='rating-inline2' class='p-0' variant='warning' no-border size='sm' show-value precision='2' readonly inline value='@(ratingStars)'></b-form-rating></div>@@ -73,4 +79,4 @@@Loc["Account.Reviews.NoExists"]</div>}-</div>+</div>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccountAdd.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccountAdd.cshtmlindex 635148af5..7a652f18c 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccountAdd.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccountAdd.cshtml@@ -6,14 +6,18 @@//titlepagebuilder.AddTitleParts(Loc["Title.Account"]);}+@section left{@await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = AccountNavigationEnum.SubAccounts })}+<validation-observer v-slot="{ handleSubmit }"><form asp-route="CustomerSubAccountAdd" asp-antiforgery="true" method="post" autocomplete="off" ref="form" v-on:submit.prevent="handleSubmit(formSubmit)"><div class="page account-page subaccount-edit-page pl-lg-3 mb-3 pt-lg-0 pt-3">- <h1 class="generalTitle h2"><div>@Loc["Account.SubAccount.AddNew"]</div></h1>+ <h1 class="generalTitle h2">+ <div>@Loc["Account.SubAccount.AddNew"]</div>+ </h1><a class="left-side-toggler mb-3" onclick="sideToggle()"><div class="inner"><span></span>@@ -25,9 +29,9 @@</div></a><div asp-validation-summary="All" class="message-error my-3"></div>- <partial name="Partials/CreateSubAccount" model="Model" />+ <partial name="Partials/CreateSubAccount" model="Model"/><div class="buttons generalMarginSupporter">- <input type="submit" class="btn btn-info save-subaccount-button" value="@Loc["Common.Save"]" />+ <input type="submit" class="btn btn-info save-subaccount-button" value="@Loc["Common.Save"]"/></div></div></form>diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccountEdit.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccountEdit.cshtmlindex cb464f99c..a6285f874 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccountEdit.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccountEdit.cshtml@@ -6,14 +6,18 @@//titlepagebuilder.AddTitleParts(Loc["Title.Account"]);}+@section left{@await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = AccountNavigationEnum.SubAccounts })}+<validation-observer v-slot="{ handleSubmit }"><form asp-route="CustomerSubAccountEdit" asp-antiforgery="true" method="post" autocomplete="off" ref="form" v-on:submit.prevent="handleSubmit(formSubmit)"><div class="page account-page subaccount-edit-page pl-lg-3 mb-3 pt-lg-0 pt-3">- <h1 class="generalTitle h2"><div>@Loc["Account.SubAccount.Edit"]</div></h1>+ <h1 class="generalTitle h2">+ <div>@Loc["Account.SubAccount.Edit"]</div>+ </h1><a class="left-side-toggler mb-3" onclick="sideToggle()"><div class="inner"><span></span>@@ -25,9 +29,9 @@</div></a><div asp-validation-summary="All" class="message-error"></div>- <partial name="Partials/EditSubAccount" model="Model" />+ <partial name="Partials/EditSubAccount" model="Model"/><div class="buttons generalMarginSupporter">- <input type="submit" class="btn btn-info save-subaccount-button" value="@Loc["Common.Save"]" />+ <input type="submit" class="btn btn-info save-subaccount-button" value="@Loc["Common.Save"]"/></div></div></form>diff --git a/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccounts.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccounts.cshtmlindex 080d13137..e9509d442 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccounts.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Account/SubAccounts.cshtml@@ -1,67 +1,73 @@@model IList<SubAccountSimpleModel>@inject IPageHeadBuilder pagebuilder- @{- Layout = "_TwoColumns";+@{+ Layout = "_TwoColumns";- //title- pagebuilder.AddTitleParts(Loc["Title.SubAccounts"]);- }- @section left+ //title+ pagebuilder.AddTitleParts(Loc["Title.SubAccounts"]);+}++@section left{- @await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = AccountNavigationEnum.SubAccounts })- }- <vc:widget widget-zone="customer-subaccounts" additional-data="@Model"></vc:widget>- <div class="page account-page subaccounts-list-page pl-lg-3 pt-lg-0 pt-3">- @Html.AntiForgeryToken()- <h1 class="h2 generalTitle"><div>@Loc["Account.SubAccounts"]</div></h1>- <a class="left-side-toggler mb-3" onclick="sideToggle()">- <div class="inner">- <span></span>- <span></span>- <span></span>- </div>- <div class="text">- @Loc["Account.Navigation"]- </div>- </a>- <div class="w-100">- <button class="btn btn-outline-secondary add-address-button my-3" onclick="location = '@Url.RouteUrl("CustomerSubAccountAdd")'">- <b-icon icon="clipboard-plus"></b-icon> @Loc["Common.AddNew"]- </button>+ @await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = AccountNavigationEnum.SubAccounts })+}++<vc:widget widget-zone="customer-subaccounts" additional-data="@Model"></vc:widget>+<div class="page account-page subaccounts-list-page pl-lg-3 pt-lg-0 pt-3">+ @Html.AntiForgeryToken()+ <h1 class="h2 generalTitle">+ <div>@Loc["Account.SubAccounts"]</div>+ </h1>+ <a class="left-side-toggler mb-3" onclick="sideToggle()">+ <div class="inner">+ <span></span>+ <span></span>+ <span></span></div>- @if (Model.Any())- {- <div class="col-12 px-0">- <div class="row account-list">- @for (int i = 0; i < Model.Count; i++)- {- var account = Model[i];- <div class="col-md-6 col-12 mb-3">- <div class="card">- <div class="card-header">- <h5 class="mb-0"><strong>@account.FirstName @account.LastName</strong></h5>- </div>- <div class="card-body">- <div class="account-item">- @account.Email- </div>+ <div class="text">+ @Loc["Account.Navigation"]+ </div>+ </a>+ <div class="w-100">+ <button class="btn btn-outline-secondary add-address-button my-3" onclick="location = '@Url.RouteUrl("CustomerSubAccountAdd")'">+ <b-icon icon="clipboard-plus"></b-icon> @Loc["Common.AddNew"]+ </button>+ </div>+ @if (Model.Any())+ {+ <div class="col-12 px-0">+ <div class="row account-list">+ @for (var i = 0; i < Model.Count; i++)+ {+ var account = Model[i];+ <div class="col-md-6 col-12 mb-3">+ <div class="card">+ <div class="card-header">+ <h5 class="mb-0">+ <strong>@account.FirstName @account.LastName</strong>+ </h5>+ </div>+ <div class="card-body">+ <div class="account-item">+ @account.Email</div>- <div class="card-footer">- <div class="btn-group">- <button class="btn btn-secondary edit-subaccount-button" onclick="location = '@(Url.RouteUrl("CustomerSubAccountEdit", new { id = account.Id }))'">- @Loc["Common.Edit"]- </button>- <button class="btn btn-danger delete-subaccount-button" onclick="deletecustomersubaccount('@(account.Id)')">- @Loc["Common.Delete"]- </button>- </div>+ </div>+ <div class="card-footer">+ <div class="btn-group">+ <button class="btn btn-secondary edit-subaccount-button" onclick="location = '@(Url.RouteUrl("CustomerSubAccountEdit", new { id = account.Id }))'">+ @Loc["Common.Edit"]+ </button>+ <button class="btn btn-danger delete-subaccount-button" onclick="deletecustomersubaccount('@(account.Id)')">+ @Loc["Common.Delete"]+ </button></div></div></div>- }- </div>+ </div>+ }</div>- <script asp-location="Footer">+ </div>+ <script asp-location="Footer">function deletecustomersubaccount(accountId) {if (confirm('@Loc["Admin.Common.AreYouSure"]')) {var postData = {@@ -90,11 +96,11 @@}}</script>- }- else- {- <div class="no-data alert alert-info my-3">- @Loc["Account.SubAccounts.NotExists"]- </div>- }- </div>+ }+ else+ {+ <div class="no-data alert alert-info my-3">+ @Loc["Account.SubAccounts.NotExists"]+ </div>+ }+</div>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Blog/BlogPost.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Blog/BlogPost.cshtmlindex 91d183f5a..6d59670aa 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Blog/BlogPost.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Blog/BlogPost.cshtml@@ -5,10 +5,11 @@Layout = "_TwoColumns";//title- pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Title);+ pagebuilder.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Title);pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);}+@section left {@await Component.InvokeAsync("Widget", new { widgetZone = "left_side_column_blog_before" })@await Component.InvokeAsync("BlogCategories")@@ -18,6 +19,7 @@@await Component.InvokeAsync("BlogTags")@await Component.InvokeAsync("Widget", new { widgetZone = "left_side_column_blog_after" })}+<div class="page news-item-page"><div class="container"><a class="left-side-toggler" onclick="sideToggle()">@@ -35,7 +37,7 @@<template v-slot:header>@if (!string.IsNullOrEmpty(Model.PictureModel.ImageUrl)){- <img class="img-fluid" src="@Model.PictureModel.ImageUrl" alt="@Model.PictureModel.AlternateText" />+ <img class="img-fluid" src="@Model.PictureModel.ImageUrl" alt="@Model.PictureModel.AlternateText"/>}<div class="content"><h1 class="h5 title generalTitle">@@ -58,10 +60,10 @@{<div class="tags generalMarginSupporter"><div class="col-form-label w-100">@Loc["Blog.Tags"]:</div>- @for (int i = 0; i < Model.Tags.Count; i++)+ @for (var i = 0; i < Model.Tags.Count; i++){var tag = Model.Tags[i];- <b-button variant="light" size="sm" class="mr-2 mb-2" href="@Url.RouteUrl("BlogByTag", new { tag})">@tag</b-button>+ <b-button variant="light" size="sm" class="mr-2 mb-2" href="@Url.RouteUrl("BlogByTag", new { tag })">@tag</b-button>}</div>}@@ -76,37 +78,37 @@@{var result = TempData["Grand.blog.addcomment.result"] as string;}- @if (!String.IsNullOrEmpty(result))+ @if (!string.IsNullOrEmpty(result)){<div class="alert alert-info">@result</div>}</div><validation-observer v-slot="{ handleSubmit }">- <form id="addBlogComment" asp-controller="Blog" asp-action="BlogPost" asp-route-id="@Model.Id" method="post" v-on:submit.prevent="handleSubmit(blog.submitBlogComment)">- <input type="hidden" name="Id" value="@Model.Id"/>- <div class="form-fields">- <div class="form-group">- <validation-provider tag="div" rules="required" v-slot="{ errors, classes }">- <label for="CommentText" class="col-form-label">@Loc["Blog.Comments.CommentText"]:</label>- <textarea name="CommentText" v-model="blog.CommentText"+ <form id="addBlogComment" asp-controller="Blog" asp-action="BlogPost" asp-route-id="@Model.Id" method="post" v-on:submit.prevent="handleSubmit(blog.submitBlogComment)">+ <input type="hidden" name="Id" value="@Model.Id"/>+ <div class="form-fields">+ <div class="form-group">+ <validation-provider tag="div" rules="required" v-slot="{ errors, classes }">+ <label for="CommentText" class="col-form-label">@Loc["Blog.Comments.CommentText"]:</label>+ <textarea name="CommentText" v-model="blog.CommentText"data-val-required="Enter comment"v-bind:class="[classes , 'form-control']" autofocus="autofocus" rows="4"></textarea>- <span class="field-validation-error">{{ errors[0] }}</span>- </validation-provider>- </div>- @if (Model.AddNewComment.DisplayCaptcha)- {- <div class="captcha-box">- <captcha/>- </div>- }- </div>- <div class="buttons text-xs-center text-md-left generalMarginSupporter">- <input type="submit" asp-action="BlogCommentAdd" name="add-comment" class="btn btn-info blog-post-add-comment-button" value="@Loc["Blog.Comments.SubmitButton"]"/>- </div>- </form>- </validation-observer>- <script asp-location="Footer" asp-order="300">+ <span class="field-validation-error">{{ errors[0] }}</span>+ </validation-provider>+ </div>+ @if (Model.AddNewComment.DisplayCaptcha)+ {+ <div class="captcha-box">+ <captcha/>+ </div>+ }+ </div>+ <div class="buttons text-xs-center text-md-left generalMarginSupporter">+ <input type="submit" asp-action="BlogCommentAdd" name="add-comment" class="btn btn-info blog-post-add-comment-button" value="@Loc["Blog.Comments.SubmitButton"]"/>+ </div>+ </form>+ </validation-observer>+ <script asp-location="Footer" asp-order="300">var blog = new Vue({data: function () {return {@@ -179,4 +181,4 @@@await Component.InvokeAsync("Widget", new { widgetZone = "blogpost_page_after_comments", additionalData = Model.Id })@await Component.InvokeAsync("Widget", new { widgetZone = "blogpost_page_bottom", additionalData = Model.Id })</div>-</div>+</div>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogCategories/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogCategories/Default.cshtmlindex 7147f1af0..f45c34014 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogCategories/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogCategories/Default.cshtml@@ -2,14 +2,16 @@@if (Model.Any()){<section id="block-blog-archive" class="block block-blog-archive">- <h2 class="h5"><strong>@Loc["Blog.Category"]</strong></h2>+ <h2 class="h5">+ <strong>@Loc["Blog.Category"]</strong>+ </h2><div class="viewBox"><ul class="list">@foreach (var category in Model){<li><a href="@Url.RouteUrl("BlogByCategory", new { categorySeName = category.SeName })">- @category.Name+ @category.Name(@(category.BlogPostCount))</a></li>diff --git a/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogMonths/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogMonths/Default.cshtmlindex 418ec2849..441b9c1b2 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogMonths/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogMonths/Default.cshtml@@ -2,7 +2,9 @@@if (Model.Any()){<section id="block-blog-archive" class="block block-blog-archive">- <h2 class="h5"><strong>@Loc["Blog.Archive"]</strong></h2>+ <h2 class="h5">+ <strong>@Loc["Blog.Archive"]</strong>+ </h2><div class="viewBox"><ul class="list" id="blog-month-list">@foreach (var yearItem in Model)diff --git a/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogTags/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogTags/Default.cshtmlindex 3d950f231..3a5e43549 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogTags/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Blog/Components/BlogTags/Default.cshtml@@ -2,7 +2,9 @@@if (Model.Tags.Any()){<div id="block-popular-blogtags" class="block block-popular-blogtags">- <h2 class="h5"><strong>@Loc["Blog.TagCloud"]</strong></h2>+ <h2 class="h5">+ <strong>@Loc["Blog.TagCloud"]</strong>+ </h2><div class="viewBox"><div class="product-tags-list">@foreach (var item in Model.Tags)diff --git a/src/Plugins/Theme.Modern/Views/Modern/Blog/List.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Blog/List.cshtmlindex 55926ae08..8e6b53965 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Blog/List.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Blog/List.cshtml@@ -7,6 +7,7 @@//titlepagebuilder.AddTitleParts(Loc["Title.Blog"]);}+@section left {@await Component.InvokeAsync("Widget", new { widgetZone = "left_side_column_blog_before" })@await Component.InvokeAsync("BlogCategories")@@ -16,84 +17,87 @@@await Component.InvokeAsync("BlogTags")@await Component.InvokeAsync("Widget", new { widgetZone = "left_side_column_blog_after" })}+<div class="page blog-page"><div class="container"><h2 class="generalTitle">- @if (String.IsNullOrEmpty(Model.PagingFilteringContext.Tag))- {- if (Model.PagingFilteringContext.GetParsedMonth().HasValue)+ @if (string.IsNullOrEmpty(Model.PagingFilteringContext.Tag)){- @String.Format(Loc["Blog.FilteredByMonth"], Model.PagingFilteringContext.GetParsedMonth().Value.Year, Model.PagingFilteringContext.GetParsedMonth().Value.ToString("MMMM"))+ if (Model.PagingFilteringContext.GetParsedMonth().HasValue)+ {+ @string.Format(Loc["Blog.FilteredByMonth"], Model.PagingFilteringContext.GetParsedMonth().Value.Year, Model.PagingFilteringContext.GetParsedMonth().Value.ToString("MMMM"))+ }+ else+ {+ @Loc["Blog"]+ }}else{- @Loc["Blog"]+ @string.Format(Loc["Blog.TaggedWith"], Model.PagingFilteringContext.Tag)+ }+ @if (!string.IsNullOrEmpty(Model.SearchKeyword))+ {+ <label class="mb-0 error-label red">+ @Loc["Blog.ResultsFor"] <i>@Model.SearchKeyword</i>+ </label>}- }- else- {- @String.Format(Loc["Blog.TaggedWith"], Model.PagingFilteringContext.Tag)- }- @if (!string.IsNullOrEmpty(Model.SearchKeyword))- {- <label class="mb-0 error-label red">@Loc["Blog.ResultsFor"] <i>@Model.SearchKeyword</i></label>- }- </h2>- <form method="get" id="small-search-box-form-blog" asp-action="BlogByKeyword" asp-controller="Blog" novalidate="novalidate">- <div class="mb-3 input-group">- <span role="status" aria-live="polite" class="ui-helper-hidden-accessible"></span>- <input type="text" class="form-control search-box-text ui-autocomplete-input" id="small-searchterms-blog"- autocomplete="off" name="SearchKeyword" placeholder="@Loc["Blog.SearchPlaceholder"]">+ </h2>+ <form method="get" id="small-search-box-form-blog" asp-action="BlogByKeyword" asp-controller="Blog" novalidate="novalidate">+ <div class="mb-3 input-group">+ <span role="status" aria-live="polite" class="ui-helper-hidden-accessible"></span>+ <input type="text" class="form-control search-box-text ui-autocomplete-input" id="small-searchterms-blog"+ autocomplete="off" name="SearchKeyword" placeholder="@Loc["Blog.SearchPlaceholder"]">- <span class="input-group-append">- <b-button type="submit" variant="secondary" class="search-box-button d-flex align-items-center float-sm-right">- <span class="sr-only">Search store</span>- <b-icon icon="search" class="mx-1"></b-icon>- <span class="d-none d-lg-block">@Loc["Blog.Search"]</span>- </b-button>- </span>- </div>- </form>- <a class="left-side-toggler mb-3" onclick="sideToggle()">- <div class="inner">- <span></span>- <span></span>- <span></span>- </div>- <div class="text">- @Loc["catalog.selectors.fiters"]- </div>- </a>- @await Component.InvokeAsync("Widget", new { widgetZone = "bloglist_page_before_posts" })- <b-row class="blog-posts">- @foreach (var item in Model.BlogPosts)- {- <b-col xl="4" lg="6" md="6" sm="6" cols="12">- <b-card class="post-news mb-3">- <template v-slot:header>- @if (!string.IsNullOrEmpty(item.PictureModel.ImageUrl))- {- <b-link class="img-container">- <img src="@item.PictureModel.ImageUrl" alt="@item.PictureModel.AlternateText" />- </b-link>- }- <h3 class="h5 title">- <b-link href="@Url.RouteUrl("BlogPost", new { item.SeName })">- @item.Title- </b-link>- </h3>- <div class="date">- @item.CreatedOn.ToString("D")+ <span class="input-group-append">+ <b-button type="submit" variant="secondary" class="search-box-button d-flex align-items-center float-sm-right">+ <span class="sr-only">Search store</span>+ <b-icon icon="search" class="mx-1"></b-icon>+ <span class="d-none d-lg-block">@Loc["Blog.Search"]</span>+ </b-button>+ </span>+ </div>+ </form>+ <a class="left-side-toggler mb-3" onclick="sideToggle()">+ <div class="inner">+ <span></span>+ <span></span>+ <span></span>+ </div>+ <div class="text">+ @Loc["catalog.selectors.fiters"]+ </div>+ </a>+ @await Component.InvokeAsync("Widget", new { widgetZone = "bloglist_page_before_posts" })+ <b-row class="blog-posts">+ @foreach (var item in Model.BlogPosts)+ {+ <b-col xl="4" lg="6" md="6" sm="6" cols="12">+ <b-card class="post-news mb-3">+ <template v-slot:header>+ @if (!string.IsNullOrEmpty(item.PictureModel.ImageUrl))+ {+ <b-link class="img-container">+ <img src="@item.PictureModel.ImageUrl" alt="@item.PictureModel.AlternateText"/>+ </b-link>+ }+ <h3 class="h5 title">+ <b-link href="@Url.RouteUrl("BlogPost", new { item.SeName })">+ @item.Title+ </b-link>+ </h3>+ <div class="date">+ @item.CreatedOn.ToString("D")+ </div>+ </template>+ <div class="buttons mt-3">+ <a class="btn btn-sm btn-outline-secondary read-more" href="@Url.RouteUrl("BlogPost", new { item.SeName })">@Loc["Blog.MoreInfo"]</a></div>- </template>- <div class="buttons mt-3">- <a class="btn btn-sm btn-outline-secondary read-more" href="@Url.RouteUrl("BlogPost", new { item.SeName })">@Loc["Blog.MoreInfo"]</a>- </div>- </b-card>- </b-col>+ </b-card>+ </b-col>- @*+ @*@await Component.InvokeAsync("Widget", new { widgetZone = "bloglist_page_before_post", additionalData = item.Id })<b-col xl="4" lg="4" cols="12" class="mb-3"><b-card class="blog-post" onclick="window.location.href = '@Url.RouteUrl("BlogPost", new { SeName = item.SeName })'">@@ -126,10 +130,10 @@</b-col>@await Component.InvokeAsync("Widget", new { widgetZone = "bloglist_page_after_post", additionalData = item.Id })*@- }- </b-row>- <page-navigation asp-query-param="pagenumber" asp-pagination="Model.PagingFilteringContext" />+ }+ </b-row>+ <page-navigation asp-query-param="pagenumber" asp-pagination="Model.PagingFilteringContext"/>- @await Component.InvokeAsync("Widget", new { widgetZone = "bloglist_page_after_posts" })+ @await Component.InvokeAsync("Widget", new { widgetZone = "bloglist_page_after_posts" })</div>-</div>+</div>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Catalog/BrandLayout.GridOrLines.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Catalog/BrandLayout.GridOrLines.cshtmlindex 8fad7b6c3..e56b40399 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Catalog/BrandLayout.GridOrLines.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Catalog/BrandLayout.GridOrLines.cshtml@@ -4,14 +4,14 @@@{Layout = "_TwoColumns";- pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);+ pagebuilder.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);var canonicalUrlsEnabled = seoSettings.CanonicalUrlsEnabled;if (canonicalUrlsEnabled){- var collectionUrl = Url.RouteUrl("Brand", new { Model.SeName }, this.Url.ActionContext.HttpContext.Request.Scheme);+ var collectionUrl = Url.RouteUrl("Brand", new { Model.SeName }, Url.ActionContext.HttpContext.Request.Scheme);pagebuilder.AddCanonicalUrlParts(collectionUrl);}diff --git a/src/Plugins/Theme.Modern/Views/Modern/Catalog/CategoryLayout.GridOrLines.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Catalog/CategoryLayout.GridOrLines.cshtmlindex 769002a06..7ff2a57a6 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Catalog/CategoryLayout.GridOrLines.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Catalog/CategoryLayout.GridOrLines.cshtml@@ -4,26 +4,26 @@@{Layout = "_TwoColumns";- pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);+ pagebuilder.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);var canonicalUrlsEnabled = seoSettings.CanonicalUrlsEnabled;if (canonicalUrlsEnabled){- var categoryUrl = Url.RouteUrl("Category", new { Model.SeName }, this.Url.ActionContext.HttpContext.Request.Scheme);+ var categoryUrl = Url.RouteUrl("Category", new { Model.SeName }, Url.ActionContext.HttpContext.Request.Scheme);pagebuilder.AddCanonicalUrlParts(categoryUrl);}}@* Rednering category breadcrumbs*@+@section Breadcrumb- {+{@if (Model.DisplayCategoryBreadcrumb){-var count = 0;- <ol class="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList">+ <ol class="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList"><li class="breadcrumb-item" itemprop="itemListElement" itemscope="itemscope" itemtype="http://schema.org/ListItem"><a href="@Url.RouteUrl("HomePage")" title="@Loc["Categories.Breadcrumb.Top"]"><b-icon icon="house-door" scale="1.25" shift-v="1.25" aria-hidden="true"></b-icon>@@ -31,7 +31,7 @@<span itemprop="item" itemscope itemtype="http://schema.org/Thing"id="@Url.RouteUrl("HomePage")"></span>- <meta itemprop="position" content="@count" />+ <meta itemprop="position" content="@count"/></a></li>@foreach (var cat in Model.CategoryBreadcrumb)@@ -44,9 +44,9 @@<a><strong class="current-item" itemprop="name">@cat.Name</strong><span itemprop="item" itemscope itemtype="http://schema.org/Thing"- id="@Url.RouteUrl("Category", new { cat.SeName})">+ id="@Url.RouteUrl("Category", new { cat.SeName })"></span>- <meta itemprop="position" content="@count" />+ <meta itemprop="position" content="@count"/></a></li>}@@ -58,110 +58,113 @@<span itemprop="item" itemscope itemtype="http://schema.org/Thing"id="@Url.RouteUrl("Category", new { cat.SeName })"></span>- <meta itemprop="position" content="@count" />+ <meta itemprop="position" content="@count"/></a></li>}-}</ol>@await Component.InvokeAsync("Widget", new { widgetZone = "categorydetails_after_breadcrumb", additionalData = Model.Id })}}- <div class="page category-page catalog-page mb-2">- <template v-if="catalog.Model.Description !== null">- <div v-html="catalog.Model.Description"></div>- </template>- <h1 class="generalTitle h2"><div>{{catalog.Model.Name}}</div></h1>- @await Component.InvokeAsync("Widget", new { widgetZone = "categorydetails_top", additionalData = Model.Id })- @*Rendering category description*@- @await Component.InvokeAsync("Widget", new { widgetZone = "categorydetails_before_subcategories", additionalData = Model.Id })- @*Rendering subcategories*@- <template v-if="catalog.Model.SubCategories.length > 0">- <div id="subcatslider" class="mb-3">- <swiper ref="SubCategories"- :options="subcatslider.swiperOptions">- <template v-for="item in catalog.Model.SubCategories">- <swiper-slide>- <b-link class="category-item" :href="'/' + item.SeName" :title="item.PictureModel.Title">- <img :src="item.PictureModel.ImageUrl" :alt="item.PictureModel.AlternateText" />- <div class="content">- <h6 class="title mb-0">{{item.Name}}</h6>- </div>- </b-link>- </swiper-slide>- </template>- </swiper>- </div>- </template>- @await Component.InvokeAsync("Widget", new { widgetZone = "categorydetails_before_featured_products", additionalData = Model.Id })- @*Rendering featured products section*@- <template v-if="catalog.Model.FeaturedProducts.length > 0">- <b-col cols="12" class="product-grid featured-product-grid px-0">- <h2 class="generalTitle mb-3">- <span>@Loc["Products.FeaturedProducts"]</span>- </h2>- <div class="item-row">- <template :key="Model" v-for="Model in catalog.Model.FeaturedProducts">- <b-col lg="4" sm="6" cols="6" class="product-container new-col-6 px-0 mb-2">- <product-box-vue :Model="Model"></product-box-vue>- </b-col>- </template>- </div>- </b-col>- </template>- @await Component.InvokeAsync("Widget", new { widgetZone = "categorydetails_after_featured_products", additionalData = Model.Id })- @await Component.InvokeAsync("Widget", new { widgetZone = "categorydetails_before_filters", additionalData = Model.Id })- <div id="catalog-products">- <template v-if="catalog.Model !== undefined">- <partial name="Partials/Selectors" />- <template v-if="catalog.Model.Products.length > 0">- <template v-if="catalog.Model.PagingFilteringContext.ViewMode == 'grid'">- <b-col cols="12" class="product-grid standard px-0">- <b-form-row>- <template :key="Model.Id" v-for="Model in catalog.Model.Products">- <b-col lg="3" sm="4" cols="6" class="product-container px-0 mb-2">- <product-box-vue :Model="Model"></product-box-vue>- </b-col>- </template>- </b-form-row>- </b-col>- </template>- <template v-else>- <div class="product-list">- <b-col cols="12">- <b-row>- <template :key="Model.Id" v-for="Model in catalog.Model.Products">- <product-box-list-vue :Model="Model"></product-box-list-vue>- </template>- </b-row>- </b-col>++<div class="page category-page catalog-page mb-2">+ <template v-if="catalog.Model.Description !== null">+ <div v-html="catalog.Model.Description"></div>+ </template>+ <h1 class="generalTitle h2">+ <div>{{catalog.Model.Name}}</div>+ </h1>+ @await Component.InvokeAsync("Widget", new { widgetZone = "categorydetails_top", additionalData = Model.Id })+ @*Rendering category description*@+ @await Component.InvokeAsync("Widget", new { widgetZone = "categorydetails_before_subcategories", additionalData = Model.Id })+ @*Rendering subcategories*@+ <template v-if="catalog.Model.SubCategories.length > 0">+ <div id="subcatslider" class="mb-3">+ <swiper ref="SubCategories"+ :options="subcatslider.swiperOptions">+ <template v-for="item in catalog.Model.SubCategories">+ <swiper-slide>+ <b-link class="category-item" :href="'/' + item.SeName" :title="item.PictureModel.Title">+ <img :src="item.PictureModel.ImageUrl" :alt="item.PictureModel.AlternateText"/>+ <div class="content">+ <h6 class="title mb-0">{{item.Name}}</h6></div>- </template>- @*<partial name="Partials/Pagination" />*@- <partial name="Partials/ScrollPagination" />- </template>- <template v-else>- <b-alert variant="info" show class="my-3">- @Loc["search.noresultstext"]- </b-alert>- </template>+ </b-link>+ </swiper-slide>+ </template>+ </swiper>+ </div>+ </template>+ @await Component.InvokeAsync("Widget", new { widgetZone = "categorydetails_before_featured_products", additionalData = Model.Id })+ @*Rendering featured products section*@+ <template v-if="catalog.Model.FeaturedProducts.length > 0">+ <b-col cols="12" class="product-grid featured-product-grid px-0">+ <h2 class="generalTitle mb-3">+ <span>@Loc["Products.FeaturedProducts"]</span>+ </h2>+ <div class="item-row">+ <template :key="Model" v-for="Model in catalog.Model.FeaturedProducts">+ <b-col lg="4" sm="6" cols="6" class="product-container new-col-6 px-0 mb-2">+ <product-box-vue :Model="Model"></product-box-vue>+ </b-col></template></div>- @*Rendering bottom description*@- <template v-if="catalog.Model.BottomDescription !== null">- <div v-html="catalog.Model.BottomDescription"></div>+ </b-col>+ </template>+ @await Component.InvokeAsync("Widget", new { widgetZone = "categorydetails_after_featured_products", additionalData = Model.Id })+ @await Component.InvokeAsync("Widget", new { widgetZone = "categorydetails_before_filters", additionalData = Model.Id })+ <div id="catalog-products">+ <template v-if="catalog.Model !== undefined">+ <partial name="Partials/Selectors"/>+ <template v-if="catalog.Model.Products.length > 0">+ <template v-if="catalog.Model.PagingFilteringContext.ViewMode == 'grid'">+ <b-col cols="12" class="product-grid standard px-0">+ <b-form-row>+ <template :key="Model.Id" v-for="Model in catalog.Model.Products">+ <b-col lg="3" sm="4" cols="6" class="product-container px-0 mb-2">+ <product-box-vue :Model="Model"></product-box-vue>+ </b-col>+ </template>+ </b-form-row>+ </b-col>+ </template>+ <template v-else>+ <div class="product-list">+ <b-col cols="12">+ <b-row>+ <template :key="Model.Id" v-for="Model in catalog.Model.Products">+ <product-box-list-vue :Model="Model"></product-box-list-vue>+ </template>+ </b-row>+ </b-col>+ </div>+ </template>+ @*<partial name="Partials/Pagination" />*@+ <partial name="Partials/ScrollPagination"/></template>- @*Rendering rccently viewed products section*@- @await Component.InvokeAsync("RecentlyViewedProductsBlock", new { productThumbPictureSize = 235 })- </div>+ <template v-else>+ <b-alert variant="info" show class="my-3">+ @Loc["search.noresultstext"]+ </b-alert>+ </template>+ </template>+ </div>+ @*Rendering bottom description*@+ <template v-if="catalog.Model.BottomDescription !== null">+ <div v-html="catalog.Model.BottomDescription"></div>+ </template>+ @*Rendering rccently viewed products section*@+ @await Component.InvokeAsync("RecentlyViewedProductsBlock", new { productThumbPictureSize = 235 })+</div>+@section filters- {+{@*Rendering filtering section*@@if (Model.PagingFilteringContext.SpecificationFilter.Enabled){- <partial name="Partials/Filtering" />+ <partial name="Partials/Filtering"/>}}-<partial name="Partials/ModelScript" model="@Json.Serialize(Model)" />\ No newline at end of file+<partial name="Partials/ModelScript" model="@Json.Serialize(Model)"/>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Catalog/CollectionLayout.GridOrLines.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Catalog/CollectionLayout.GridOrLines.cshtmlindex 368ae7bca..662dcaa74 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Catalog/CollectionLayout.GridOrLines.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Catalog/CollectionLayout.GridOrLines.cshtml@@ -3,14 +3,14 @@@inject IPageHeadBuilder pagebuilder@{Layout = "_TwoColumns";- pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);+ pagebuilder.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);var canonicalUrlsEnabled = seoSettings.CanonicalUrlsEnabled;if (canonicalUrlsEnabled){- var collectionUrl = Url.RouteUrl("Collection", new { Model.SeName }, this.Url.ActionContext.HttpContext.Request.Scheme);+ var collectionUrl = Url.RouteUrl("Collection", new { Model.SeName }, Url.ActionContext.HttpContext.Request.Scheme);pagebuilder.AddCanonicalUrlParts(collectionUrl);}}@@ -27,7 +27,9 @@<template v-if="catalog.Model.Description !== null"><div v-html="catalog.Model.Description"></div></template>- <h1 class="generalTitle h2"><div>{{catalog.Model.Name}}</div></h1>+ <h1 class="generalTitle h2">+ <div>{{catalog.Model.Name}}</div>+ </h1>@await Component.InvokeAsync("Widget", new { widgetZone = "collectiondetails_top", additionalData = Model.Id })@await Component.InvokeAsync("Widget", new { widgetZone = "collectiondetails_before_featured_products", additionalData = Model.Id })@*Rendering featured products section*@@@ -47,42 +49,42 @@</template>@await Component.InvokeAsync("Widget", new { widgetZone = "collectiondetails_after_featured_products", additionalData = Model.Id })<div id="catalog-products">- @await Component.InvokeAsync("Widget", new { widgetZone = "collectiondetails_before_filters", additionalData = Model.Id })- <template v-if="catalog.Model !== undefined">- <partial name="Partials/Selectors" />- <template v-if="catalog.Model.Products.length > 0">- <template v-if="catalog.Model.PagingFilteringContext.ViewMode == 'grid'">- <b-col cols="12" class="product-grid standard px-0">- <b-form-row>+ @await Component.InvokeAsync("Widget", new { widgetZone = "collectiondetails_before_filters", additionalData = Model.Id })+ <template v-if="catalog.Model !== undefined">+ <partial name="Partials/Selectors"/>+ <template v-if="catalog.Model.Products.length > 0">+ <template v-if="catalog.Model.PagingFilteringContext.ViewMode == 'grid'">+ <b-col cols="12" class="product-grid standard px-0">+ <b-form-row>+ <template :key="Model.Id" v-for="Model in catalog.Model.Products">+ <b-col lg="3" sm="4" cols="6" class="product-container px-0 mb-2">+ <product-box-vue :Model="Model"></product-box-vue>+ </b-col>+ </template>+ </b-form-row>+ </b-col>+ </template>+ <template v-else>+ <div class="product-list">+ <b-col cols="12">+ <b-row><template :key="Model.Id" v-for="Model in catalog.Model.Products">- <b-col lg="3" sm="4" cols="6" class="product-container px-0 mb-2">- <product-box-vue :Model="Model"></product-box-vue>- </b-col>+ <product-box-list-vue :Model="Model"></product-box-list-vue></template>- </b-form-row>+ </b-row></b-col>- </template>- <template v-else>- <div class="product-list">- <b-col cols="12">- <b-row>- <template :key="Model.Id" v-for="Model in catalog.Model.Products">- <product-box-list-vue :Model="Model"></product-box-list-vue>- </template>- </b-row>- </b-col>- </div>- </template>- @*<partial name="Partials/Pagination" />*@- <partial name="Partials/ScrollPagination" />- </template>- <template v-else>- <b-alert variant="info" show class="my-3">- @Loc["search.noresultstext"]- </b-alert>+ </div></template>+ @*<partial name="Partials/Pagination" />*@+ <partial name="Partials/ScrollPagination"/>+ </template>+ <template v-else>+ <b-alert variant="info" show class="my-3">+ @Loc["search.noresultstext"]+ </b-alert></template>- </div>+ </template>+ </div>@*Rendering bottom description section*@<template v-if="catalog.Model.BottomDescription !== null">@@ -93,13 +95,13 @@</div></b-skeleton-wrapper>- @section filters+@section filters+{+ @*Rendering filtering section*@+ @if (Model.PagingFilteringContext.SpecificationFilter.Enabled){- @*Rendering filtering section*@- @if (Model.PagingFilteringContext.SpecificationFilter.Enabled)- {- <partial name="Partials/Filtering" />- }+ <partial name="Partials/Filtering"/>}+}- <partial name="Partials/ModelScript" model="@Json.Serialize(Model)" />+<partial name="Partials/ModelScript" model="@Json.Serialize(Model)"/>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Catalog/Partials/Pagination.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Catalog/Partials/Pagination.cshtmlindex 70b3ccb67..541fd84d6 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Catalog/Partials/Pagination.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Catalog/Partials/Pagination.cshtml@@ -28,4 +28,4 @@</template></div></template>-</template>+</template>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Catalog/ProductsByTag.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Catalog/ProductsByTag.cshtmlindex 6eb2fdd69..c44dd61df 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Catalog/ProductsByTag.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Catalog/ProductsByTag.cshtml@@ -11,7 +11,7 @@var canonicalUrlsEnabled = seoSettings.CanonicalUrlsEnabled;if (canonicalUrlsEnabled){- var productsByTagUrl = Url.RouteUrl("ProductsByTag", new { productTagId = Model.Id, SeName = Model.TagSeName }, this.Url.ActionContext.HttpContext.Request.Scheme);+ var productsByTagUrl = Url.RouteUrl("ProductsByTag", new { productTagId = Model.Id, SeName = Model.TagSeName }, Url.ActionContext.HttpContext.Request.Scheme);pagebuilder.AddCanonicalUrlParts(productsByTagUrl);}}@@ -23,10 +23,12 @@</div></template><div id="catalog-products" class="page product-tag-page">- <h1 class="generalTitle h2"><div>@String.Format(Loc["Products.Tags.ProductsTaggedWith"], Model.TagName)</div></h1>+ <h1 class="generalTitle h2">+ <div>@string.Format(Loc["Products.Tags.ProductsTaggedWith"], Model.TagName)</div>+ </h1>@await Component.InvokeAsync("Widget", new { widgetZone = "productsbytag_top", additionalData = Model.Id })<div id="catalog-products">- <partial name="Partials/Selectors" />+ <partial name="Partials/Selectors"/><template v-if="catalog.Model.Products.length > 0"><template v-if="catalog.Model.PagingFilteringContext.ViewMode == 'grid'"><b-col cols="12" class="product-grid px-0">@@ -50,7 +52,7 @@</b-col></div></template>- <partial name="Partials/ScrollPagination" />+ <partial name="Partials/ScrollPagination"/></template><template v-else><b-alert variant="info" show class="my-3">@@ -62,4 +64,4 @@</b-skeleton-wrapper>@await Component.InvokeAsync("Widget", new { widgetZone = "productsbytag_bottom", additionalData = Model.Id })-<partial name="Partials/ModelScript" model="@Json.Serialize(Model)" />\ No newline at end of file+<partial name="Partials/ModelScript" model="@Json.Serialize(Model)"/>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Catalog/Search.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Catalog/Search.cshtmlindex 1870eef93..46826d49a 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Catalog/Search.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Catalog/Search.cshtml@@ -1,4 +1,4 @@-@model Grand.Web.Models.Catalog.SearchModel+@model SearchModel@inject IPageHeadBuilder pagebuilder@{Layout = "_TwoColumns";@@ -22,7 +22,9 @@</script><div class="page search-page">- <h1 class="generalTitle h2"><div>@Loc["Search"]</div></h1>+ <h1 class="generalTitle h2">+ <div>@Loc["Search"]</div>+ </h1><div class="search-input"><form asp-route="ProductSearch" method="get"><div class="fieldset">@@ -30,16 +32,16 @@<div class="basic-search"><label class="col-form-label" asp-for="q">@Loc["Search.SearchTerm"]:</label><div class="input-group mb-2">- <input asp-for="q" type="search" class="form-control search-text" />+ <input asp-for="q" type="search" class="form-control search-text"/><div class="input-group-append">- <input type="submit" class="btn btn-secondary search-button" value="@Loc["Search.Button"]" />+ <input type="submit" class="btn btn-secondary search-button" value="@Loc["Search.Button"]"/></div></div>@await Component.InvokeAsync("Widget", new { widgetZone = "productsearch_page_basic" })<div class="inputs reversed"><label for="adv" class="custom-control custom-checkbox"><span class="sr-only">adv</span>- <input asp-for="adv" class="custom-control-input" />+ <input asp-for="adv" class="custom-control-input"/><span class="custom-control-label"></span><span class="custom-control-description">@Loc["search.advancedsearch"]</span></label>@@ -80,18 +82,18 @@<div class="price-range flex-sm-row row"><div class="col"><label class="col-form-label" asp-for="pf">@Loc["Search.PriceRange.From"]</label>- <input asp-for="pf" class="form-control price-from" />+ <input asp-for="pf" class="form-control price-from"/></div><div class="col"><label class="col-form-label" asp-for="pt">@Loc["Search.PriceRange.To"]</label>- <input asp-for="pt" class="form-control price-to" />+ <input asp-for="pt" class="form-control price-to"/></div></div></div></div><div class="inputs reversed"><label for="sid" class="custom-control custom-checkbox">- <input asp-for="sid" class="custom-control-input" />+ <input asp-for="sid" class="custom-control-input"/><span class="custom-control-label"></span><span class="custom-control-description">@Loc["search.searchindescriptions"]</span></label>@@ -107,7 +109,7 @@<div class="search-results"><div id="catalog-products">@await Component.InvokeAsync("Widget", new { widgetZone = "productsearch_page_before_results" })- <partial name="Partials/Selectors" />+ <partial name="Partials/Selectors"/><template v-if="catalog.Model.Products.length > 0"><template v-if="catalog.Model.PagingFilteringContext.ViewMode == 'grid'"><b-col cols="12" class="product-grid px-0">@@ -132,10 +134,10 @@</div></template>@*<partial name="Partials/Pagination" />*@- <partial name="Partials/ScrollPagination" />+ <partial name="Partials/ScrollPagination"/></template></div>- @if (!String.IsNullOrEmpty(Model.Warning))+ @if (!string.IsNullOrEmpty(Model.Warning)){<div class="warning alert alert-danger my-3">@Model.Warning@@ -156,7 +158,8 @@@*Rendering filtering section*@@if (Model.PagingFilteringContext.SpecificationFilter.Enabled){- <partial name="Partials/Filtering" model="Model.PagingFilteringContext.SpecificationFilter" />+ <partial name="Partials/Filtering" model="Model.PagingFilteringContext.SpecificationFilter"/>}}-<partial name="Partials/ModelScript" model="@Json.Serialize(Model)" />\ No newline at end of file++<partial name="Partials/ModelScript" model="@Json.Serialize(Model)"/>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Catalog/Vendor.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Catalog/Vendor.cshtmlindex b8e242f51..664deab1a 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Catalog/Vendor.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Catalog/Vendor.cshtml@@ -3,14 +3,14 @@@inject IPageHeadBuilder pagebuilder@{Layout = "_TwoColumns";- pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);+ pagebuilder.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);var canonicalUrlsEnabled = seoSettings.CanonicalUrlsEnabled;if (canonicalUrlsEnabled){- var vendorUrl = Url.RouteUrl("Vendor", new { Model.SeName }, this.Url.ActionContext.HttpContext.Request.Scheme);+ var vendorUrl = Url.RouteUrl("Vendor", new { Model.SeName }, Url.ActionContext.HttpContext.Request.Scheme);pagebuilder.AddCanonicalUrlParts(vendorUrl);}}@@ -32,7 +32,7 @@@if (Model.VendorReviewOverview.AllowCustomerReviews){<div>- <partial name="Partials/VendorReviewOverview" model="Model.VendorReviewOverview" />+ <partial name="Partials/VendorReviewOverview" model="Model.VendorReviewOverview"/></div>}</div>@@ -41,7 +41,7 @@<div class="row"><div class="col-12"><b-tabs class="mt-3" content-class="mt-3" align="center">- @if (!String.IsNullOrEmpty(Model.Description))+ @if (!string.IsNullOrEmpty(Model.Description)){<b-tab id="description-tab" title="@Loc["vendor.Description"]" active><article class="text-xs-center generalMarginSupporter vendor-description" v-html="catalog.Model.Description"></article>@@ -51,21 +51,21 @@{<b-tab id="address-tab" title="@Loc["Vendor.Address"]"><ul class="info px-0 mb-0">- @if (Model.Address.CompanyEnabled && !String.IsNullOrEmpty(Model.Address.Company))+ @if (Model.Address.CompanyEnabled && !string.IsNullOrEmpty(Model.Address.Company)){<li class="company"><label class="col-form-label">@Loc["Address.Fields.Company"]:</label>@Model.Address.Company</li>}- @if (Model.Address.StreetAddressEnabled && !String.IsNullOrEmpty(Model.Address.Address1))+ @if (Model.Address.StreetAddressEnabled && !string.IsNullOrEmpty(Model.Address.Address1)){<li class="address1"><label class="col-form-label w-100">@Loc["Address.Fields.Address1"]:</label>@Model.Address.Address1</li>}- @if (Model.Address.StreetAddress2Enabled && !String.IsNullOrEmpty(Model.Address.Address2))+ @if (Model.Address.StreetAddress2Enabled && !string.IsNullOrEmpty(Model.Address.Address2)){<li class="address2"><label class="col-form-label">@Loc["Address.Fields.Address2"]:</label>@@ -75,7 +75,7 @@@if (Model.Address.CityEnabled || Model.Address.StateProvinceEnabled || Model.Address.ZipPostalCodeEnabled){var cityStateZip = "";- if (Model.Address.CityEnabled && !String.IsNullOrEmpty(Model.Address.City))+ if (Model.Address.CityEnabled && !string.IsNullOrEmpty(Model.Address.City)){cityStateZip = Model.Address.City;if (Model.Address.StateProvinceEnabled || Model.Address.ZipPostalCodeEnabled)@@ -83,43 +83,48 @@cityStateZip += ",";}}+if (Model.Address.StateProvinceEnabled){- if (!String.IsNullOrEmpty(cityStateZip))+ if (!string.IsNullOrEmpty(cityStateZip)){cityStateZip += " ";}+cityStateZip += Model.Address.StateProvinceName;}+if (Model.Address.ZipPostalCodeEnabled){- if (!String.IsNullOrEmpty(cityStateZip))+ if (!string.IsNullOrEmpty(cityStateZip)){cityStateZip += " ";}+cityStateZip += Model.Address.ZipPostalCode;}- if (!String.IsNullOrEmpty(cityStateZip))++ if (!string.IsNullOrEmpty(cityStateZip)){<li class="city-state-zip">@cityStateZip</li>}}- @if (Model.Address.CountryEnabled && !String.IsNullOrEmpty(Model.Address.CountryName))+ @if (Model.Address.CountryEnabled && !string.IsNullOrEmpty(Model.Address.CountryName)){<li class="country">@Model.Address.CountryName</li>}- @if (Model.Address.PhoneEnabled && !String.IsNullOrEmpty(Model.Address.PhoneNumber))+ @if (Model.Address.PhoneEnabled && !string.IsNullOrEmpty(Model.Address.PhoneNumber)){<li class="phone"><label class="col-form-label">@Loc["Address.Fields.PhoneNumber"]:</label>@Model.Address.PhoneNumber</li>}- @if (Model.Address.FaxEnabled && !String.IsNullOrEmpty(Model.Address.FaxNumber))+ @if (Model.Address.FaxEnabled && !string.IsNullOrEmpty(Model.Address.FaxNumber)){<li class="fax"><label class="col-form-label">@Loc["Address.Fields.FaxNumber"]:</label>@@ -147,7 +152,7 @@</div></div><div id="catalog-products">- <partial name="Partials/Selectors" />+ <partial name="Partials/Selectors"/><template v-if="catalog.Model.Products.length > 0"><template v-if="catalog.Model.PagingFilteringContext.ViewMode == 'grid'"><b-col cols="12" class="product-grid standard px-0">@@ -172,7 +177,7 @@</div></template>@*<partial name="Partials/Pagination" />*@- <partial name="Partials/ScrollPagination" />+ <partial name="Partials/ScrollPagination"/></template><template v-else><div class="alert alert-info my-3">@@ -185,7 +190,7 @@{<div id="captcha-container"><div class="captcha-box" id="captcha-box">- <captcha />+ <captcha/></div></div>}@@ -196,8 +201,8 @@@*Rendering filtering*@@if (Model.PagingFilteringContext.SpecificationFilter.Enabled){- <partial name="Partials/Filtering" model="Model.PagingFilteringContext.SpecificationFilter" />+ <partial name="Partials/Filtering" model="Model.PagingFilteringContext.SpecificationFilter"/>}}-<partial name="Partials/ModelScript" model="@Json.Serialize(Model)" />\ No newline at end of file+<partial name="Partials/ModelScript" model="@Json.Serialize(Model)"/>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Checkout/Partials/Summary.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Checkout/Partials/Summary.cshtmlindex 438adfcc3..710f511e4 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Checkout/Partials/Summary.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Checkout/Partials/Summary.cshtml@@ -1,12 +1,11 @@@{-var modelExists = Model != null;}<div class="order-summary-content mt-3" id="ordersummarypagecart" v-if="vmorder.cart">@await Component.InvokeAsync("Widget", new { widgetZone = "checkout_summary_content_before" })<div v-if="typeof vmorder.cart.Items !== 'undefined' && vmorder.cart.Items.length > 0"><template v-if="vmorder.OrderReviewData && vmorder.Confirm">- <partial name="Partials/ReviewData" />+ <partial name="Partials/ReviewData"/></template><ul v-if="typeof vmorder.cart.Warnings !== 'undefined' && vmorder.cart.Warnings.length > 0" class="px-0 mb-3"><li v-for="item in vmorder.cart.Warnings">@@ -28,81 +27,81 @@<col span="1"></colgroup><thead>- <tr>- <th v-if="vmorder.cart.ShowProductImages" class="product-picture text-center">- @Loc["ShoppingCart.Image"]- </th>- <th class="product text-center">- @Loc["ShoppingCart.Product(s)"]- </th>- <th class="unit-price text-center">- @Loc["ShoppingCart.UnitPrice"]- </th>- <th class="quantity text-center">- @Loc["ShoppingCart.Quantity"]- </th>- <th class="subtotal text-center">- @Loc["ShoppingCart.ItemTotal"]- </th>- </tr>+ <tr>+ <th v-if="vmorder.cart.ShowProductImages" class="product-picture text-center">+ @Loc["ShoppingCart.Image"]+ </th>+ <th class="product text-center">+ @Loc["ShoppingCart.Product(s)"]+ </th>+ <th class="unit-price text-center">+ @Loc["ShoppingCart.UnitPrice"]+ </th>+ <th class="quantity text-center">+ @Loc["ShoppingCart.Quantity"]+ </th>+ <th class="subtotal text-center">+ @Loc["ShoppingCart.ItemTotal"]+ </th>+ </tr></thead><tbody>- <tr v-for="item in vmorder.cart.Items">- <td v-if="vmorder.cart.ShowProductImages" class="product-picture text-center">- <a :href="'/' + item.ProductSeName">- <img alt="item.Picture.AlternateText" :src="item.Picture.ImageUrl" title="item.Picture.Title" />+ <tr v-for="item in vmorder.cart.Items">+ <td v-if="vmorder.cart.ShowProductImages" class="product-picture text-center">+ <a :href="'/' + item.ProductSeName">+ <img alt="item.Picture.AlternateText" :src="item.Picture.ImageUrl" title="item.Picture.Title"/>+ </a>+ </td>+ <td class="product">+ <div class="mb-2">+ <a :href="'/' + item.ProductSeName" class="product-name">+ {{item.ProductName}}</a>- </td>- <td class="product">- <div class="mb-2">- <a :href="'/' + item.ProductSeName" class="product-name">- {{item.ProductName}}- </a>+ </div>+ <span v-if="vmorder.cart.ShowSku" class="sku-number">+ {{item.Sku}}+ </span>+ <div v-if="item.AttributeInfo !== ''" v-html="item.AttributeInfo" class="attributes small"></div>+ <div v-if="item.WarehouseName !== null" v-html="item.WarehouseName" class="attributes small"></div>+ <div v-if="item.VendorName !== null" v-html="item.VendorName" class="attributes small"></div>+ <div v-if="item.AuctionInfo !== null" v-html="item.AuctionInfo" class="attributes small"></div>+ <div v-if="item.RecurringInfo !== null" v-html="item.RecurringInfo" class="recurring-info"></div>+ <div v-if="item.ReservationInfo !== null" v-html="item.ReservationInfo" class="rental-info attributes small"></div>+ <div v-if="vmorder.cart.IsEditable && item.AllowItemEditing" class="edit-item mb-1 mt-1">+ <a class="btn btn-sm btn-secondary" :href="'/' + item.ProductSeName + '?updatecartitemid=' + item.Id">@Loc["Common.Edit"]</a>+ </div>+ <div v-if="typeof item.Warnings !== 'undefined' && item.Warnings.length > 0" class="message-error alert alert-danger">+ <ul v-for="warning in item.Warnings" class="mb-0 p-0">+ <li>{{warning}}</li>+ </ul>+ </div>+ </td>+ <td class="unit-price">+ <span class="product-unit-price price">{{item.UnitPrice}}</span>+ <div v-if="item.UnitPriceWithoutDiscountValue != item.UnitPriceValue && item.UnitPriceWithoutDiscountValue > 0" class="text-center">+ <del class="small text-danger">{{item.UnitPriceWithoutDiscount}}</del>+ </div>+ </td>+ <td class="quantity">+ <span :id="'itemquantity' + item.Id" :name="'itemquantity' + item.Id" class="qty-opc">+ {{item.Quantity}}+ </span>+ </td>+ <td class="subtotal">+ <div v-if="item.Discount" class="d-flex flex-column">+ <p class="mb-0 prod-total">{{item.SubTotal}}</p>+ <div class="discount text-success text-center">+ <span>@Loc["ShoppingCart.ItemYouSave"]: </span>+ <span>{{item.Discount}}</span>+ <span v-if="item.DiscountedQty > 0" class="font-weight-light font-italic">@Loc["ShoppingCart.DiscountedQty"]: </span>+ <span v-if="item.DiscountedQty > 0" class="font-weight-light font-italic">{{item.DiscountedQty}}</span></div>- <span v-if="vmorder.cart.ShowSku" class="sku-number">- {{item.Sku}}- </span>- <div v-if="item.AttributeInfo !== ''" v-html="item.AttributeInfo" class="attributes small"></div>- <div v-if="item.WarehouseName !== null" v-html="item.WarehouseName" class="attributes small"></div>- <div v-if="item.VendorName !== null" v-html="item.VendorName" class="attributes small"></div>- <div v-if="item.AuctionInfo !== null" v-html="item.AuctionInfo" class="attributes small"></div>- <div v-if="item.RecurringInfo !== null" v-html="item.RecurringInfo" class="recurring-info"></div>- <div v-if="item.ReservationInfo !== null" v-html="item.ReservationInfo" class="rental-info attributes small"></div>- <div v-if="vmorder.cart.IsEditable && item.AllowItemEditing" class="edit-item mb-1 mt-1">- <a class="btn btn-sm btn-secondary" :href="'/' + item.ProductSeName + '?updatecartitemid=' + item.Id">@Loc["Common.Edit"]</a>- </div>- <div v-if="typeof item.Warnings !== 'undefined' && item.Warnings.length > 0" class="message-error alert alert-danger">- <ul v-for="warning in item.Warnings" class="mb-0 p-0">- <li>{{warning}}</li>- </ul>- </div>- </td>- <td class="unit-price">- <span class="product-unit-price price">{{item.UnitPrice}}</span>- <div v-if="item.UnitPriceWithoutDiscountValue != item.UnitPriceValue && item.UnitPriceWithoutDiscountValue > 0" class="text-center">- <del class="small text-danger">{{item.UnitPriceWithoutDiscount}}</del>- </div>- </td>- <td class="quantity">- <span :id="'itemquantity' + item.Id" :name="'itemquantity' + item.Id" class="qty-opc">- {{item.Quantity}}- </span>- </td>- <td class="subtotal">- <div v-if="item.Discount" class="d-flex flex-column">- <p class="mb-0 prod-total">{{item.SubTotal}}</p>- <div class="discount text-success text-center">- <span>@Loc["ShoppingCart.ItemYouSave"]: </span>- <span>{{item.Discount}}</span>- <span v-if="item.DiscountedQty > 0" class="font-weight-light font-italic">@Loc["ShoppingCart.DiscountedQty"]: </span>- <span v-if="item.DiscountedQty > 0" class="font-weight-light font-italic">{{item.DiscountedQty}}</span>- </div>- </div>- <div v-else>- <p class="mb-0 prod-total">{{item.SubTotal}}</p>- </div>- </td>- </tr>+ </div>+ <div v-else>+ <p class="mb-0 prod-total">{{item.SubTotal}}</p>+ </div>+ </td>+ </tr></tbody></table></div>@@ -118,7 +117,7 @@</div><div class="col-lg-4 col-12 totals"><div class="totals-inner">- <partial name="Partials/OrderTotals" />+ <partial name="Partials/OrderTotals"/></div></div></div>diff --git a/src/Plugins/Theme.Modern/Views/Modern/Home/Index.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Home/Index.cshtmlindex 05dc8e8d1..e4b9ff913 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Home/Index.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Home/Index.cshtml@@ -1,4 +1,5 @@-@inject Grand.Business.Core.Interfaces.Storage.IPictureService pictureService+@using Grand.Business.Core.Interfaces.Storage+@inject IPictureService pictureService@inject SeoSettings seoSettings@{Layout = "_SingleColumn";@@ -8,29 +9,30 @@@section meta {@if (seoSettings.OpenGraphMetaTags){- <meta property="og:type" content="website" />- <meta property="og:title" content="@seoSettings.DefaultTitle" />- <meta property="og:description" content="@Html.Encode(seoSettings.DefaultMetaDescription)" />- @if (!String.IsNullOrWhiteSpace(seoSettings.StorePictureId))+ <meta property="og:type" content="website"/>+ <meta property="og:title" content="@seoSettings.DefaultTitle"/>+ <meta property="og:description" content="@Html.Encode(seoSettings.DefaultMetaDescription)"/>+ @if (!string.IsNullOrWhiteSpace(seoSettings.StorePictureId)){var picture = await pictureService.GetPictureUrl(seoSettings.StorePictureId);- <meta property="og:image" content="@picture" />+ <meta property="og:image" content="@picture"/>}- <meta property="og:url" content="@this.Url.ActionContext.HttpContext.Request.GetEncodedUrl()" />++ <meta property="og:url" content="@Url.ActionContext.HttpContext.Request.GetEncodedUrl()"/>}@if (seoSettings.TwitterMetaTags){- <meta property="twitter:card" content="summary" />- <meta property="twitter:site" content="@seoSettings.DefaultTitle" />- <meta property="twitter:title" content="@seoSettings.DefaultTitle" />- <meta property="twitter:description" content="@Html.Encode(seoSettings.DefaultMetaDescription)" />- @if (!String.IsNullOrWhiteSpace(seoSettings.StorePictureId))+ <meta property="twitter:card" content="summary"/>+ <meta property="twitter:site" content="@seoSettings.DefaultTitle"/>+ <meta property="twitter:title" content="@seoSettings.DefaultTitle"/>+ <meta property="twitter:description" content="@Html.Encode(seoSettings.DefaultMetaDescription)"/>+ @if (!string.IsNullOrWhiteSpace(seoSettings.StorePictureId)){var picture = await pictureService.GetPictureUrl(seoSettings.StorePictureId);- <meta property="twitter:image" content="@picture" />+ <meta property="twitter:image" content="@picture"/>}- <meta property="twitter:url" content="@this.Url.ActionContext.HttpContext.Request.GetEncodedUrl()" />+ <meta property="twitter:url" content="@Url.ActionContext.HttpContext.Request.GetEncodedUrl()"/>}}@@ -58,4 +60,4 @@@await Component.InvokeAsync("Widget", new { widgetZone = "home_page_before_blog" })@await Component.InvokeAsync("HomePageBlog")@await Component.InvokeAsync("Widget", new { widgetZone = "home_page_bottom" })-</div>+</div>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/MerchandiseReturn/CustomerMerchandiseReturns.cshtml b/src/Plugins/Theme.Modern/Views/Modern/MerchandiseReturn/CustomerMerchandiseReturns.cshtmlindex 3e0ca4357..b478efe15 100644--- a/src/Plugins/Theme.Modern/Views/Modern/MerchandiseReturn/CustomerMerchandiseReturns.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/MerchandiseReturn/CustomerMerchandiseReturns.cshtml@@ -1,5 +1,5 @@-@model CustomerMerchandiseReturnsModel-@using System.Globalization+@using System.Globalization+@model CustomerMerchandiseReturnsModel@inject IPageHeadBuilder pagebuilder@{Layout = "_TwoColumns";@@ -7,12 +7,16 @@//titlepagebuilder.AddTitleParts(Loc["Title.Account"]);}+@section left- {+{@await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = AccountNavigationEnum.MerchandiseReturns })}+<div class="page account-page return-request-list-page pl-lg-3 pt-3 pt-lg-0">- <h1 class="h2 generalTitle"><div>@Loc["Account.CustomerMerchandiseReturns"]</div></h1>+ <h1 class="h2 generalTitle">+ <div>@Loc["Account.CustomerMerchandiseReturns"]</div>+ </h1><a class="left-side-toggler mb-3" onclick="sideToggle()"><div class="inner"><span></span>@@ -61,4 +65,4 @@@Loc["Account.CustomerMerchandiseReturns.NoMerchandiseReturns"]</div>}-</div>+</div>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/News/List.cshtml b/src/Plugins/Theme.Modern/Views/Modern/News/List.cshtmlindex 78ebdf8a0..cd5d47cf0 100644--- a/src/Plugins/Theme.Modern/Views/Modern/News/List.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/News/List.cshtml@@ -7,7 +7,9 @@pagebuilder.AddTitleParts(Loc["Title.NewsArchive"]);}<div class="page news-list-page">- <h1 class="generalTitle h2"><div>@Loc["News"]</div></h1>+ <h1 class="generalTitle h2">+ <div>@Loc["News"]</div>+ </h1>@await Component.InvokeAsync("Widget", new { widgetZone = "newslist_page_before_items" })<a class="left-side-toggler mb-3" onclick="sideToggle()"><div class="inner">@@ -28,7 +30,7 @@@if (!string.IsNullOrEmpty(item.PictureModel.ImageUrl)){<b-link class="img-container">- <img src="@item.PictureModel.ImageUrl" alt="@item.PictureModel.AlternateText" />+ <img src="@item.PictureModel.ImageUrl" alt="@item.PictureModel.AlternateText"/></b-link>}<h3 class="h5 title">@@ -51,8 +53,8 @@</b-card></b-col>}- <page-navigation asp-query-param="pagenumber" asp-pagination="Model.PagingFilteringContext" />+ <page-navigation asp-query-param="pagenumber" asp-pagination="Model.PagingFilteringContext"/>@await Component.InvokeAsync("Widget", new { widgetZone = "newslist_page_after_items" })</b-row>-</div>+</div>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/News/NewsItem.cshtml b/src/Plugins/Theme.Modern/Views/Modern/News/NewsItem.cshtmlindex d8fdc7b3d..8d781484d 100644--- a/src/Plugins/Theme.Modern/Views/Modern/News/NewsItem.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/News/NewsItem.cshtml@@ -4,88 +4,90 @@Layout = "_TwoColumns";//title- pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Title);+ pagebuilder.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Title);pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);<link rel="stylesheet" type="text/css" asp-src="/Plugins/Theme.Modern/Content/css/blog-news/blog-news.css">}- <div class="page news-item-page">- <a class="left-side-toggler" onclick="sideToggle()">- <div class="inner">- <span></span>- <span></span>- <span></span>- </div>- <div class="text">- @Loc["catalog.selectors.fiters"]- </div>- </a>- <b-card class="post-news mt-3">- <template v-slot:header>- @if (!string.IsNullOrEmpty(Model.PictureModel.ImageUrl))- {- <img class="img-fluid" src="@Model.PictureModel.ImageUrl" alt="@Model.PictureModel.AlternateText" />- }- <h1 class="h5 title generalTitle">- <div>@Model.Title</div>- </h1>- <span class="date">- @Model.CreatedOn.ToString("D")- </span>- </template>- @await Component.InvokeAsync("Widget", new { widgetZone = "newsitem_page_before_body", additionalData = Model.Id })- @Html.Raw(Model.Full)- </b-card>- @await Component.InvokeAsync("Widget", new { widgetZone = "newsitem_page_before_comments", additionalData = Model.Id })- @if (Model.AllowComments)+<div class="page news-item-page">+ <a class="left-side-toggler" onclick="sideToggle()">+ <div class="inner">+ <span></span>+ <span></span>+ <span></span>+ </div>+ <div class="text">+ @Loc["catalog.selectors.fiters"]+ </div>+ </a>+ <b-card class="post-news mt-3">+ <template v-slot:header>+ @if (!string.IsNullOrEmpty(Model.PictureModel.ImageUrl)){- <fieldset class="new-comment py-3 px-0" id="comments">- <h5><strong>@Loc["News.Comments.LeaveYourComment"]</strong></h5>- <div class="notifications">- <div asp-validation-summary="All" class="message-error"></div>- @{- var result = TempData["Grand.news.addcomment.result"] as string;- }- @if (!String.IsNullOrEmpty(result))- {- <div class="result alert alert-info">@result</div>- }- </div>- <validation-observer v-slot="{ handleSubmit }">- <form id="addNewsComment" asp-action="NewsCommentAdd" asp-controller="News" method="post" v-on:submit.prevent="handleSubmit(news.submitNewsComment)">- <input type="hidden" name="Id" value="@Model.Id"/>- <fieldset class="form-group">- <validation-provider tag="div" rules="required" name="CommentTitle" v-slot="{ errors, classes }">- <label for="CommentTitle" class="col-form-label">@Loc["News.Comments.CommentTitle"]:</label>- <input name="CommentTitle" v-bind:class="[classes , 'form-control enter-comment-title']"- data-val-required="@Loc["News.Comments.CommentTitle.Required"]"- v-model="news.CommentTitle"/>- <span class="field-validation-error">{{ errors[0] }}</span>- </validation-provider>- </fieldset>- <fieldset class="form-group">- <validation-provider tag="div" rules="required" name="CommentText" v-slot="{ errors, classes }">- <label for="CommentText" class="col-form-label">@Loc["News.Comments.CommentText"]:</label>- <textarea name="CommentText" v-model="news.CommentText"+ <img class="img-fluid" src="@Model.PictureModel.ImageUrl" alt="@Model.PictureModel.AlternateText"/>+ }+ <h1 class="h5 title generalTitle">+ <div>@Model.Title</div>+ </h1>+ <span class="date">+ @Model.CreatedOn.ToString("D")+ </span>+ </template>+ @await Component.InvokeAsync("Widget", new { widgetZone = "newsitem_page_before_body", additionalData = Model.Id })+ @Html.Raw(Model.Full)+ </b-card>+ @await Component.InvokeAsync("Widget", new { widgetZone = "newsitem_page_before_comments", additionalData = Model.Id })+ @if (Model.AllowComments)+ {+ <fieldset class="new-comment py-3 px-0" id="comments">+ <h5>+ <strong>@Loc["News.Comments.LeaveYourComment"]</strong>+ </h5>+ <div class="notifications">+ <div asp-validation-summary="All" class="message-error"></div>+ @{+ var result = TempData["Grand.news.addcomment.result"] as string;+ }+ @if (!string.IsNullOrEmpty(result))+ {+ <div class="result alert alert-info">@result</div>+ }+ </div>+ <validation-observer v-slot="{ handleSubmit }">+ <form id="addNewsComment" asp-action="NewsCommentAdd" asp-controller="News" method="post" v-on:submit.prevent="handleSubmit(news.submitNewsComment)">+ <input type="hidden" name="Id" value="@Model.Id"/>+ <fieldset class="form-group">+ <validation-provider tag="div" rules="required" name="CommentTitle" v-slot="{ errors, classes }">+ <label for="CommentTitle" class="col-form-label">@Loc["News.Comments.CommentTitle"]:</label>+ <input name="CommentTitle" v-bind:class="[classes , 'form-control enter-comment-title']"+ data-val-required="@Loc["News.Comments.CommentTitle.Required"]"+ v-model="news.CommentTitle"/>+ <span class="field-validation-error">{{ errors[0] }}</span>+ </validation-provider>+ </fieldset>+ <fieldset class="form-group">+ <validation-provider tag="div" rules="required" name="CommentText" v-slot="{ errors, classes }">+ <label for="CommentText" class="col-form-label">@Loc["News.Comments.CommentText"]:</label>+ <textarea name="CommentText" v-model="news.CommentText"data-val-required="@Loc["News.Comments.CommentText.Required"]"v-bind:class="[classes , 'form-control']" autofocus="autofocus" rows="4"></textarea>- <span class="field-validation-error">{{ errors[0] }}</span>- </validation-provider>- </fieldset>- @if (Model.AddNewComment.DisplayCaptcha)- {- <div class="captcha-box">- <captcha/>- </div>- }- <div class="buttons text-xs-center text-md-left generalMarginSupporter">- <input type="submit" name="add-comment" class="btn btn-info news-item-add-comment-button" value="@Loc["News.Comments.SubmitButton"]"/>- </div>- </form>- </validation-observer>- </fieldset>- <script asp-location="Footer" asp-order="300">+ <span class="field-validation-error">{{ errors[0] }}</span>+ </validation-provider>+ </fieldset>+ @if (Model.AddNewComment.DisplayCaptcha)+ {+ <div class="captcha-box">+ <captcha/>+ </div>+ }+ <div class="buttons text-xs-center text-md-left generalMarginSupporter">+ <input type="submit" name="add-comment" class="btn btn-info news-item-add-comment-button" value="@Loc["News.Comments.SubmitButton"]"/>+ </div>+ </form>+ </validation-observer>+ </fieldset>+ <script asp-location="Footer" asp-order="300">var news = new Vue({data: () => {return {@@ -156,6 +158,6 @@</div></div></template>- }- @await Component.InvokeAsync("Widget", new { widgetZone = "newsitem_page_after_comments", additionalData = Model.Id })- </div>+ }+ @await Component.InvokeAsync("Widget", new { widgetZone = "newsitem_page_after_comments", additionalData = Model.Id })+</div>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Order/CustomerOrders.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Order/CustomerOrders.cshtmlindex ae28f149d..903d8840e 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Order/CustomerOrders.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Order/CustomerOrders.cshtml@@ -6,12 +6,16 @@//titlepagebuilder.AddTitleParts(Loc["Title.Account"]);}+@section left{@await Component.InvokeAsync("CustomerNavigation", new { selectedTabId = AccountNavigationEnum.Orders })}+<div class="page account-page order-list-page pl-lg-3 pt-lg-0 pt-3">- <h1 class="generalTitle h2"><div>@Loc["Account.CustomerOrders"]</div></h1>+ <h1 class="generalTitle h2">+ <div>@Loc["Account.CustomerOrders"]</div>+ </h1><a class="left-side-toggler mb-3" onclick="sideToggle()"><div class="inner"><span></span>@@ -27,45 +31,45 @@<div class="account-order table-responsive"><table class="table table-bordered hover-table"><thead>- <tr>- <th scope="col">@Loc["Account.CustomerOrders.OrderNumber"]</th>- <th scope="col">@Loc["Account.CustomerOrders.OrderStatus"]</th>- <th scope="col">@Loc["Account.CustomerOrders.OrderDate"]</th>- <th scope="col">@Loc["Account.CustomerOrders.OrderTotal"]</th>- <th scope="col"></th>- </tr>+ <tr>+ <th scope="col">@Loc["Account.CustomerOrders.OrderNumber"]</th>+ <th scope="col">@Loc["Account.CustomerOrders.OrderStatus"]</th>+ <th scope="col">@Loc["Account.CustomerOrders.OrderDate"]</th>+ <th scope="col">@Loc["Account.CustomerOrders.OrderTotal"]</th>+ <th scope="col"></th>+ </tr></thead><tbody>- @foreach (var order in Model.Orders)- {- <tr>- <td>- <span>@order.OrderNumber</span>- </td>- <td>- <span class="@order.OrderStatus.ToLower() badge status order-status">@order.OrderStatus</span>- </td>- <td>- <span>@order.CreatedOn.ToString("g")</span>- </td>- <td>- <span class="order-total">@order.OrderTotal</span>- </td>- <td>- <div class="buttons d-flex flex-column">- <input type="button" value="@Loc["Account.CustomerOrders.OrderDetails"]" class="btn btn-sm btn-info order-details-button" onclick="location = ('@Url.RouteUrl("OrderDetails", new { orderId = order.Id })')" />- @if (order.IsMerchandiseReturnAllowed)- {- <input type="button" value="@Loc["Account.CustomerOrders.ReturnItems"]" class="btn btn-sm btn-warning text-white return-items-button mt-1" onclick="location = ('@Url.RouteUrl("MerchandiseReturn", new { orderId = order.Id })')" />- }- </div>- </td>- </tr>- }+ @foreach (var order in Model.Orders)+ {+ <tr>+ <td>+ <span>@order.OrderNumber</span>+ </td>+ <td>+ <span class="@order.OrderStatus.ToLower() badge status order-status">@order.OrderStatus</span>+ </td>+ <td>+ <span>@order.CreatedOn.ToString("g")</span>+ </td>+ <td>+ <span class="order-total">@order.OrderTotal</span>+ </td>+ <td>+ <div class="buttons d-flex flex-column">+ <input type="button" value="@Loc["Account.CustomerOrders.OrderDetails"]" class="btn btn-sm btn-info order-details-button" onclick="location = ('@Url.RouteUrl("OrderDetails", new { orderId = order.Id })')"/>+ @if (order.IsMerchandiseReturnAllowed)+ {+ <input type="button" value="@Loc["Account.CustomerOrders.ReturnItems"]" class="btn btn-sm btn-warning text-white return-items-button mt-1" onclick="location = ('@Url.RouteUrl("MerchandiseReturn", new { orderId = order.Id })')"/>+ }+ </div>+ </td>+ </tr>+ }</tbody></table></div>- <page-navigation asp-query-param="pagenumber" asp-pagination="Model.PagingContext" />+ <page-navigation asp-query-param="pagenumber" asp-pagination="Model.PagingContext"/>}else{diff --git a/src/Plugins/Theme.Modern/Views/Modern/Order/Details.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Order/Details.cshtmlindex a8719bd17..9de01d7ed 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Order/Details.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Order/Details.cshtml@@ -8,386 +8,416 @@pagebuilder.AddTitleParts(Loc["Title.OrderDetails"]);}<div class="page order-details-page mb-3">- <h1 class="generalTitle h2"><div>@Loc["Order.OrderInformation"]</div></h1>- <div asp-validation-summary="All"></div>+<h1 class="generalTitle h2">+ <div>@Loc["Order.OrderInformation"]</div>+</h1>+<div asp-validation-summary="All"></div>- <div class="btn-group btn-group-sm">- @if (!Model.PdfInvoiceDisabled)- {- <a href="@Url.RouteUrl("GetOrderPdfInvoice", new { orderId = Model.Id })" class="btn btn-outline-secondary pdf-invoice-button">@Loc["Order.GetPDFInvoice"]</a>- }+<div class="btn-group btn-group-sm">+ @if (!Model.PdfInvoiceDisabled)+ {+ <a href="@Url.RouteUrl("GetOrderPdfInvoice", new { orderId = Model.Id })" class="btn btn-outline-secondary pdf-invoice-button">@Loc["Order.GetPDFInvoice"]</a>+ }- @if (Model.ShowAddOrderNote)- {- <a @@click="$bvModal.show('ModalAddOrderNote')" class="btn btn-outline-secondary">@Loc["Order.AddOrderNote"]</a>+ @if (Model.ShowAddOrderNote)+ {+ <a @@click="$bvModal.show('ModalAddOrderNote')" class="btn btn-outline-secondary">@Loc["Order.AddOrderNote"]</a>- var notemodel = new AddOrderNoteModel- {- OrderId = Model.Id- };+ var notemodel = new AddOrderNoteModel+ {+ OrderId = Model.Id+ };- <partial name="Partials/AddOrderNote" model="@notemodel" />- }- </div>- @if (Model.UserCanCancelUnpaidOrder)- {- <a href="@Url.RouteUrl("CancelOrder", new { orderId = Model.Id })" class="btn btn-danger btn-sm cancel-unpaid-order-button float-right" onclick="return confirm('@Loc["Admin.Common.AreYouSure"]');">@Loc["Order.CancelOrder"]</a>+ <partial name="Partials/AddOrderNote" model="@notemodel"/>}- @await Component.InvokeAsync("Widget", new { widgetZone = "orderdetails_page_top", additionalData = Model.Id })+</div>+@if (Model.UserCanCancelUnpaidOrder)+{+ <a href="@Url.RouteUrl("CancelOrder", new { orderId = Model.Id })" class="btn btn-danger btn-sm cancel-unpaid-order-button float-right" onclick="return confirm('@Loc["Admin.Common.AreYouSure"]');">@Loc["Order.CancelOrder"]</a>+}+@await Component.InvokeAsync("Widget", new { widgetZone = "orderdetails_page_top", additionalData = Model.Id })- <div class="order-details-area mt-3">- <div class="card">- <div class="card-body">- <div class="form-row">- <div class="col-lg-4 col-md-6 col-12 order-info">- <ul class="order-overview px-0">- <li class="title">- <h5 class="order-number h4">- <span class="d-flex"><strong>@Loc["Order.Order#"]</strong><strong>@Model.OrderNumber</strong></span>- </h5>+<div class="order-details-area mt-3">+ <div class="card">+ <div class="card-body">+ <div class="form-row">+ <div class="col-lg-4 col-md-6 col-12 order-info">+ <ul class="order-overview px-0">+ <li class="title">+ <h5 class="order-number h4">+ <span class="d-flex">+ <strong>@Loc["Order.Order#"]</strong><strong>@Model.OrderNumber</strong>+ </span>+ </h5>+ </li>+ @if (!string.IsNullOrEmpty(Model.OrderCode))+ {+ <li class="order-code d-flex">+ <span class="mx-1">@Loc["Order.OrderCode"]:</span><span>@Model.OrderCode</span></li>- @if (!string.IsNullOrEmpty(Model.OrderCode))- {- <li class="order-code d-flex">- <span class="mx-1">@Loc["Order.OrderCode"]:</span><span>@Model.OrderCode</span>- </li>- }- <li class="order-date d-flex">- <span class="mx-1">@Loc["Order.OrderDate"]:</span>- <span>@Model.CreatedOn.ToString("D")</span>+ }+ <li class="order-date d-flex">+ <span class="mx-1">@Loc["Order.OrderDate"]:</span>+ <span>@Model.CreatedOn.ToString("D")</span>+ </li>+ <li class="order-status d-flex">+ <span class="mx-1">@Loc["Order.OrderStatus"]:</span><span>@Model.OrderStatus</span>+ </li>+ <li class="order-total d-flex">+ <span class="mx-1">@Loc["Order.OrderTotal"]:</span>+ <span class="h5 mb-0">+ <strong>@Model.OrderTotal</strong>+ </span>+ </li>+ @await Component.InvokeAsync("Widget", new { widgetZone = "orderdetails_page_overview", additionalData = Model.Id })+ </ul>+ </div>+ <div class="col-lg-4 col-md-6 col-12 billing">+ <ul class="billing-info px-0">+ <li class="title">+ <h5 class="generalTitle">@Loc["Order.BillingAddress"]</h5>+ </li>+ <li class="name">+ @Model.BillingAddress.FirstName @Model.BillingAddress.LastName+ </li>+ <li class="email">+ @Loc["Order.Email"]: @Model.BillingAddress.Email+ </li>+ @if (Model.BillingAddress.PhoneEnabled)+ {+ <li class="phone">+ @Loc["Order.Phone"]: @Model.BillingAddress.PhoneNumber</li>- <li class="order-status d-flex">- <span class="mx-1">@Loc["Order.OrderStatus"]:</span><span>@Model.OrderStatus</span>+ }+ @if (Model.BillingAddress.FaxEnabled)+ {+ <li class="fax">+ @Loc["Order.Fax"]: @Model.BillingAddress.FaxNumber</li>- <li class="order-total d-flex">- <span class="mx-1">@Loc["Order.OrderTotal"]:</span><span class="h5 mb-0"><strong>@Model.OrderTotal</strong></span>+ }+ @if (Model.BillingAddress.CompanyEnabled && !string.IsNullOrEmpty(Model.BillingAddress.Company))+ {+ <li class="company">+ @Model.BillingAddress.Company</li>- @await Component.InvokeAsync("Widget", new { widgetZone = "orderdetails_page_overview", additionalData = Model.Id })- </ul>- </div>- <div class="col-lg-4 col-md-6 col-12 billing">- <ul class="billing-info px-0">+ }+ @if (Model.BillingAddress.VatNumberEnabled && !string.IsNullOrEmpty(Model.BillingAddress.VatNumber))+ {+ <li class="company">+ @Model.BillingAddress.VatNumber+ </li>+ }+ @if (Model.BillingAddress.StreetAddressEnabled)+ {+ <li class="address1">+ @Model.BillingAddress.Address1+ </li>+ }+ @if (Model.BillingAddress.StreetAddress2Enabled && !string.IsNullOrEmpty(Model.BillingAddress.Address2))+ {+ <li class="address2">+ @Model.BillingAddress.Address2+ </li>+ }+ @if (Model.BillingAddress.CityEnabled ||+ Model.BillingAddress.StateProvinceEnabled ||+ Model.BillingAddress.ZipPostalCodeEnabled)+ {+ <li class="city-state-zip">+ @if (Model.BillingAddress.CityEnabled)+ {+ @Model.BillingAddress.City+ }+ @if (Model.BillingAddress.CityEnabled && (Model.BillingAddress.StateProvinceEnabled || Model.BillingAddress.ZipPostalCodeEnabled))+ {+ <text>, </text>+ }+ @if (Model.BillingAddress.StateProvinceEnabled)+ {+ @Model.BillingAddress.StateProvinceName+ }+ @if (Model.BillingAddress.ZipPostalCodeEnabled)+ {+ <text> </text>+ @Model.BillingAddress.ZipPostalCode+ }+ </li>+ }+ @if (Model.BillingAddress.CountryEnabled && !string.IsNullOrEmpty(Model.BillingAddress.CountryName))+ {+ <li class="country">+ @Model.BillingAddress.CountryName+ </li>+ }+ @if (!string.IsNullOrEmpty(Model.VatNumber))+ {+ <li class="vat">+ <span class="label">+ @Loc["Order.VATNumber"]+ </span>+ <span class="value">+ @Model.VatNumber+ </span>+ </li>+ }+ @if (!string.IsNullOrEmpty(Model.BillingAddress.FormattedCustomAddressAttributes))+ {+ <li class="custom-attributes-view">+ @Html.Raw(Model.BillingAddress.FormattedCustomAddressAttributes)+ </li>+ }+ @if (!string.IsNullOrEmpty(Model.PaymentMethod))+ {<li class="title">- <h5 class="generalTitle">@Loc["Order.BillingAddress"]</h5>+ <h5 class="generalMarginSupporter generalTitle">@Loc["Order.Payment"]</h5></li>- <li class="name">- @Model.BillingAddress.FirstName @Model.BillingAddress.LastName+ <li class="payment-method">+ <span class="label">+ @Loc["Order.Payment.Method"]:+ </span>+ <span class="value">+ @Model.PaymentMethod+ </span></li>- <li class="email">- @Loc["Order.Email"]: @Model.BillingAddress.Email+ <li class="payment-method-status">+ <span class="label">+ @Loc["Order.Payment.Status"]:+ </span>+ <span class="value">+ @Model.PaymentMethodStatus+ </span></li>- @if (Model.BillingAddress.PhoneEnabled)- {- <li class="phone">- @Loc["Order.Phone"]: @Model.BillingAddress.PhoneNumber- </li>- }- @if (Model.BillingAddress.FaxEnabled)- {- <li class="fax">- @Loc["Order.Fax"]: @Model.BillingAddress.FaxNumber- </li>- }- @if (Model.BillingAddress.CompanyEnabled && !String.IsNullOrEmpty(Model.BillingAddress.Company))- {- <li class="company">- @Model.BillingAddress.Company- </li>- }- @if (Model.BillingAddress.VatNumberEnabled && !String.IsNullOrEmpty(Model.BillingAddress.VatNumber))- {- <li class="company">- @Model.BillingAddress.VatNumber- </li>- }- @if (Model.BillingAddress.StreetAddressEnabled)- {- <li class="address1">- @Model.BillingAddress.Address1- </li>- }- @if (Model.BillingAddress.StreetAddress2Enabled && !String.IsNullOrEmpty(Model.BillingAddress.Address2))- {- <li class="address2">- @Model.BillingAddress.Address2- </li>- }- @if (Model.BillingAddress.CityEnabled ||- Model.BillingAddress.StateProvinceEnabled ||- Model.BillingAddress.ZipPostalCodeEnabled)- {- <li class="city-state-zip">- @if (Model.BillingAddress.CityEnabled)- {- @Model.BillingAddress.City- }- @if (Model.BillingAddress.CityEnabled && (Model.BillingAddress.StateProvinceEnabled || Model.BillingAddress.ZipPostalCodeEnabled))- {- <text>, </text>- }- @if (Model.BillingAddress.StateProvinceEnabled)- {- @Model.BillingAddress.StateProvinceName- }- @if (Model.BillingAddress.ZipPostalCodeEnabled)- {- <text> </text> @Model.BillingAddress.ZipPostalCode- }- </li>- }- @if (Model.BillingAddress.CountryEnabled && !String.IsNullOrEmpty(Model.BillingAddress.CountryName))+ if (Model.CanRePostProcessPayment){- <li class="country">- @Model.BillingAddress.CountryName+ <li class="repost">+ <form asp-route="OrderDetails" method="post">+ <input type="hidden" name="orderId" value="@Model.Id"/>+ <input type="submit" asp-action="RePostPayment" name="repost-payment" value="@Loc["Order.RetryPayment"]" class="btn btn-secondary re-order-button"/>+ <p class="hint">+ <em>@Loc["Order.RetryPayment.Hint"]</em>+ </p>+ </form></li>}- @if (!String.IsNullOrEmpty(Model.VatNumber))+ }+ @if (Model.CustomValues != null)+ {+ foreach (var item in Model.CustomValues){- <li class="vat">+ <li class="custom-value"><span class="label">- @Loc["Order.VATNumber"]+ @item.Key:</span><span class="value">- @Model.VatNumber+ @(item.Value != null ? item.Value.ToString() : "")</span></li>}- @if (!String.IsNullOrEmpty(Model.BillingAddress.FormattedCustomAddressAttributes))+ }+ </ul>+ </div>+ @if (Model.IsShippable)+ {+ <div class="col-lg-4 col-md-6 col-12 shipping">+ <ul class="shipping-info px-0">+ <li class="title">+ <h5 class="generalTitle">@(Model.PickUpInStore ? Loc["Order.PickupAddress"] : Loc["Order.ShippingAddress"])</h5>+ </li>+ @if (!Model.PickUpInStore){- <li class="custom-attributes-view">- @Html.Raw(Model.BillingAddress.FormattedCustomAddressAttributes)+ <li class="name">+ @Model.ShippingAddress.FirstName @Model.ShippingAddress.LastName</li>- }- @if (!String.IsNullOrEmpty(Model.PaymentMethod))- {- <li class="title">- <h5 class="generalMarginSupporter generalTitle">@Loc["Order.Payment"]</h5>+ <li class="email">+ @Loc["Order.Email"]: @Model.ShippingAddress.Email</li>- <li class="payment-method">- <span class="label">- @Loc["Order.Payment.Method"]:- </span>- <span class="value">- @Model.PaymentMethod- </span>- </li>- <li class="payment-method-status">- <span class="label">- @Loc["Order.Payment.Status"]:- </span>- <span class="value">- @Model.PaymentMethodStatus- </span>+ if (Model.ShippingAddress.PhoneEnabled)+ {+ <li class="phone">+ @Loc["Order.Phone"]: @Model.ShippingAddress.PhoneNumber+ </li>+ }++ if (Model.ShippingAddress.FaxEnabled)+ {+ <li class="fax">+ @Loc["Order.Fax"]: @Model.ShippingAddress.FaxNumber+ </li>+ }++ if (Model.ShippingAddress.CompanyEnabled && !string.IsNullOrEmpty(Model.ShippingAddress.Company))+ {+ <li class="company">+ @Model.ShippingAddress.Company</li>- if (Model.CanRePostProcessPayment)+ }++ if (Model.ShippingAddress.StreetAddressEnabled){- <li class="repost">- <form asp-route="OrderDetails" method="post">- <input type="hidden" name="orderId" value="@Model.Id" />- <input type="submit" asp-action="RePostPayment" name="repost-payment" value="@Loc["Order.RetryPayment"]" class="btn btn-secondary re-order-button" />- <p class="hint">- <em>@Loc["Order.RetryPayment.Hint"]</em>- </p>- </form>+ <li class="address1">+ @Model.ShippingAddress.Address1+ </li>+ }++ if (Model.ShippingAddress.StreetAddress2Enabled && !string.IsNullOrEmpty(Model.ShippingAddress.Address2))+ {+ <li class="address2">+ @Model.ShippingAddress.Address2+ </li>+ }++ if (Model.ShippingAddress.CityEnabled ||+ Model.ShippingAddress.StateProvinceEnabled ||+ Model.ShippingAddress.ZipPostalCodeEnabled)+ {+ <li class="city-state-zip">+ @if (Model.ShippingAddress.CityEnabled)+ {+ @Model.ShippingAddress.City+ }+ @if (Model.ShippingAddress.CityEnabled && (Model.ShippingAddress.StateProvinceEnabled || Model.ShippingAddress.ZipPostalCodeEnabled))+ {+ <text>, </text>+ }+ @if (Model.ShippingAddress.StateProvinceEnabled)+ {+ @Model.ShippingAddress.StateProvinceName+ }+ @if (Model.ShippingAddress.ZipPostalCodeEnabled)+ {+ <text> </text>+ @Model.ShippingAddress.ZipPostalCode+ }+ </li>+ }++ if (Model.ShippingAddress.CountryEnabled && !string.IsNullOrEmpty(Model.ShippingAddress.CountryName))+ {+ <li class="country">+ @Model.ShippingAddress.CountryName+ </li>+ }++ if (!string.IsNullOrEmpty(Model.ShippingAddress.FormattedCustomAddressAttributes))+ {+ <li class="custom-attributes-view">+ @Html.Raw(Model.ShippingAddress.FormattedCustomAddressAttributes)</li>}}- @if (Model.CustomValues != null)+ else{- foreach (var item in Model.CustomValues)+ if (!string.IsNullOrEmpty(Model.PickupAddress.Address1)){- <li class="custom-value">- <span class="label">- @item.Key:- </span>- <span class="value">- @(item.Value != null ? item.Value.ToString() : "")- </span>+ <li class="address1">+ @Model.PickupAddress.Address1</li>}- }- </ul>- </div>- @if (Model.IsShippable)- {- <div class="col-lg-4 col-md-6 col-12 shipping">- <ul class="shipping-info px-0">- <li class="title">- <h5 class="generalTitle">@(Model.PickUpInStore ? Loc["Order.PickupAddress"] : Loc["Order.ShippingAddress"])</h5>- </li>- @if (!Model.PickUpInStore)++ if (!string.IsNullOrEmpty(Model.PickupAddress.City) || !string.IsNullOrEmpty(Model.PickupAddress.ZipPostalCode)){- <li class="name">- @Model.ShippingAddress.FirstName @Model.ShippingAddress.LastName+ <li class="city-state-zip">+ @if (!string.IsNullOrEmpty(Model.PickupAddress.City))+ {+ @Model.PickupAddress.City+ }+ @if (!string.IsNullOrEmpty(Model.PickupAddress.ZipPostalCode))+ {+ <text>,</text>+ @Model.PickupAddress.ZipPostalCode+ }</li>- <li class="email">- @Loc["Order.Email"]: @Model.ShippingAddress.Email+ }++ if (!string.IsNullOrEmpty(Model.PickupAddress.CountryName))+ {+ <li class="country">+ @Model.PickupAddress.CountryName</li>- if (Model.ShippingAddress.PhoneEnabled)- {- <li class="phone">- @Loc["Order.Phone"]: @Model.ShippingAddress.PhoneNumber- </li>- }- if (Model.ShippingAddress.FaxEnabled)- {- <li class="fax">- @Loc["Order.Fax"]: @Model.ShippingAddress.FaxNumber- </li>- }- if (Model.ShippingAddress.CompanyEnabled && !String.IsNullOrEmpty(Model.ShippingAddress.Company))- {- <li class="company">- @Model.ShippingAddress.Company- </li>- }- if (Model.ShippingAddress.StreetAddressEnabled)- {- <li class="address1">- @Model.ShippingAddress.Address1- </li>- }- if (Model.ShippingAddress.StreetAddress2Enabled && !String.IsNullOrEmpty(Model.ShippingAddress.Address2))- {- <li class="address2">- @Model.ShippingAddress.Address2- </li>- }- if (Model.ShippingAddress.CityEnabled ||- Model.ShippingAddress.StateProvinceEnabled ||- Model.ShippingAddress.ZipPostalCodeEnabled)- {- <li class="city-state-zip">- @if (Model.ShippingAddress.CityEnabled)- {- @Model.ShippingAddress.City- }- @if (Model.ShippingAddress.CityEnabled && (Model.ShippingAddress.StateProvinceEnabled || Model.ShippingAddress.ZipPostalCodeEnabled))- {- <text>, </text>- }- @if (Model.ShippingAddress.StateProvinceEnabled)- {- @Model.ShippingAddress.StateProvinceName- }- @if (Model.ShippingAddress.ZipPostalCodeEnabled)- {- <text> </text> @Model.ShippingAddress.ZipPostalCode- }- </li>- }- if (Model.ShippingAddress.CountryEnabled && !String.IsNullOrEmpty(Model.ShippingAddress.CountryName))- {- <li class="country">- @Model.ShippingAddress.CountryName- </li>- }- if (!String.IsNullOrEmpty(Model.ShippingAddress.FormattedCustomAddressAttributes))- {- <li class="custom-attributes-view">- @Html.Raw(Model.ShippingAddress.FormattedCustomAddressAttributes)- </li>- }}- else+ }+ <li class="title">+ <h5 class="generalMarginSupporter generalTitle">@Loc["Order.Shipping"]</h5>+ </li>+ <li class="shipping-method">+ <span class="label">+ @Loc["Order.Shipping.Name"]:+ </span>+ <span class="value">+ @Model.ShippingMethod+ </span>+ @if (!string.IsNullOrEmpty(Model.ShippingAdditionDescription)){- if (!string.IsNullOrEmpty(Model.PickupAddress.Address1))- {- <li class="address1">- @Model.PickupAddress.Address1- </li>- }- if (!string.IsNullOrEmpty(Model.PickupAddress.City) || !string.IsNullOrEmpty(Model.PickupAddress.ZipPostalCode))- {- <li class="city-state-zip">- @if (!string.IsNullOrEmpty(Model.PickupAddress.City))- {- @Model.PickupAddress.City- }- @if (!string.IsNullOrEmpty(Model.PickupAddress.ZipPostalCode))- {- <text>,</text>- @Model.PickupAddress.ZipPostalCode- }- </li>- }- if (!string.IsNullOrEmpty(Model.PickupAddress.CountryName))- {- <li class="country">- @Model.PickupAddress.CountryName- </li>- }+ <div> @Html.Raw(Model.ShippingAdditionDescription)</div>}- <li class="title">- <h5 class="generalMarginSupporter generalTitle">@Loc["Order.Shipping"]</h5>- </li>- <li class="shipping-method">++ </li>+ @if (!Model.PickUpInStore)+ {+ <li class="shipping-status"><span class="label">- @Loc["Order.Shipping.Name"]:+ @Loc["Order.Shipping.Status"]:</span><span class="value">- @Model.ShippingMethod+ @Model.ShippingStatus</span>- @if (!string.IsNullOrEmpty(Model.ShippingAdditionDescription))- {- <div> @Html.Raw(Model.ShippingAdditionDescription)</div>- }-</li>- @if (!Model.PickUpInStore)- {- <li class="shipping-status">- <span class="label">- @Loc["Order.Shipping.Status"]:- </span>- <span class="value">- @Model.ShippingStatus- </span>- </li>- }- </ul>- </div>- }- </div>+ }+ </ul>+ </div>+ }</div></div></div>+</div>- @if (Model.Items.Any())- {- @await Component.InvokeAsync("Widget", new { widgetZone = "orderdetails_page_beforeproducts", additionalData = Model.Id })-<div class="products mt-3 shopping-cart-page">- <div>- <div class="col-12 px-0">- <div class="row">- <div class="col-xl-8 col-12 cart-out-container">- <h5 class="generalTitle">@Loc["Order.Product(s)"]</h5>- <div class="shopping-cart-container">- <div id="order-details" class="table-responsive">- <table class="table">- <thead role="rowgroup">+@if (Model.Items.Any())+{+ @await Component.InvokeAsync("Widget", new { widgetZone = "orderdetails_page_beforeproducts", additionalData = Model.Id })+ <div class="products mt-3 shopping-cart-page">+ <div>+ <div class="col-12 px-0">+ <div class="row">+ <div class="col-xl-8 col-12 cart-out-container">+ <h5 class="generalTitle">@Loc["Order.Product(s)"]</h5>+ <div class="shopping-cart-container">+ <div id="order-details" class="table-responsive">+ <table class="table">+ <thead role="rowgroup"><tr role="row">- <th role="columnheader" class="text-center"><div>@Loc["Order.Product(s).Picture"]</div></th>- <th role="columnheader" class="text-center"><div>@Loc["Order.Product(s).Name"]</div></th>- <th role="columnheader" class="text-center"><div>@Loc["Order.Product(s).Price"]</div></th>- <th role="columnheader" class="text-center"><div>@Loc["Order.Product(s).Quantity"]</div></th>- <th role="columnheader" class="text-center"><div>@Loc["Order.Product(s).Total"]</div></th>+ <th role="columnheader" class="text-center">+ <div>@Loc["Order.Product(s).Picture"]</div>+ </th>+ <th role="columnheader" class="text-center">+ <div>@Loc["Order.Product(s).Name"]</div>+ </th>+ <th role="columnheader" class="text-center">+ <div>@Loc["Order.Product(s).Price"]</div>+ </th>+ <th role="columnheader" class="text-center">+ <div>@Loc["Order.Product(s).Quantity"]</div>+ </th>+ <th role="columnheader" class="text-center">+ <div>@Loc["Order.Product(s).Total"]</div>+ </th></tr>- </thead>- <tbody role="rowgroup">+ </thead>+ <tbody role="rowgroup">@foreach (var item in Model.Items){<tr role="row"><td class="text-center"><div><a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })">- <img alt="@item.Picture.AlternateText" src="@item.Picture.ImageUrl" title="@item.Picture.Title" />+ <img alt="@item.Picture.AlternateText" src="@item.Picture.ImageUrl" title="@item.Picture.Title"/></a></div></td><td class="text-center"><div>- <em><a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })">@item.ProductName</a></em>+ <em>+ <a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })">@item.ProductName</a>+ </em>@if (Model.ShowSku){<div class="sku w-100 text-center text-md-left">@item.Sku</div>@@ -400,14 +430,16 @@{<div class="rental-info">@Html.Raw(item.RentalInfo)</div>}- @if (!String.IsNullOrEmpty(item.DownloadId))+ @if (!string.IsNullOrEmpty(item.DownloadId)){- <div class="download"><a href="@Url.RouteUrl("GetDownload", new { orderItemId = item.OrderItemGuid })">@Loc["DownloadableProducts.Fields.Download"]</a></div>+ <div class="download">+ <a href="@Url.RouteUrl("GetDownload", new { orderItemId = item.OrderItemGuid })">@Loc["DownloadableProducts.Fields.Download"]</a>+ </div>}- @if (!String.IsNullOrEmpty(item.LicenseId))+ @if (!string.IsNullOrEmpty(item.LicenseId)){<div class="download license">- <a href="@Url.RouteUrl("GetLicense", new {orderItemId = item.OrderItemGuid})">@Loc["DownloadableProducts.Fields.DownloadLicense"]</a>+ <a href="@Url.RouteUrl("GetLicense", new { orderItemId = item.OrderItemGuid })">@Loc["DownloadableProducts.Fields.DownloadLicense"]</a></div>}@await Component.InvokeAsync("Widget", new { widgetZone = "orderdetails_product_line", additionalData = item.Id })@@ -434,22 +466,24 @@<span class="product-subtotal price prod-total">@item.SubTotal</span>@if (!string.IsNullOrEmpty(item.Discount)){- <div class="discount text-success text-center"><span>@Loc["ShoppingCart.Discount"]: </span><span>@item.Discount</span></div>+ <div class="discount text-success text-center">+ <span>@Loc["ShoppingCart.Discount"]: </span><span>@item.Discount</span>+ </div>}</div></td></tr>}- </tbody>- </table>+ </tbody>+ </table>+ </div></div></div>- </div>- <div class="col-lg-4 col-12 totals">- <div class="totals-inner">- <div class="total-info table-responsive px-0">- <table class="table table-hover">- <tbody>+ <div class="col-lg-4 col-12 totals">+ <div class="totals-inner">+ <div class="total-info table-responsive px-0">+ <table class="table table-hover">+ <tbody><tr><td class="cart-total-left"><label>@Loc["Order.SubTotal"]:</label>@@ -557,172 +591,176 @@<label>@Loc["Order.OrderTotal"]:</label></td><td class="cart-total-right text-right">- <span><strong>@Model.OrderTotal</strong></span>+ <span>+ <strong>@Model.OrderTotal</strong>+ </span></td></tr>- </tbody>- </table>- </div>- <div class="d-inline-flex w-100 justify-content-between flex-wrap">- @if (!String.IsNullOrEmpty(Model.CheckoutAttributeInfo))- {- <div class="selected-checkout-attributes">- @Html.Raw(Model.CheckoutAttributeInfo)- </div>- }+ </tbody>+ </table>+ </div>+ <div class="d-inline-flex w-100 justify-content-between flex-wrap">+ @if (!string.IsNullOrEmpty(Model.CheckoutAttributeInfo))+ {+ <div class="selected-checkout-attributes">+ @Html.Raw(Model.CheckoutAttributeInfo)+ </div>+ }<div class="actions">@if (Model.IsReOrderAllowed){- <input type="button" value="@Loc["Order.Reorder"]" class="btn btn-outline-info re-order-button" onclick="location = ('@Url.RouteUrl("ReOrder", new { orderId = Model.Id }) ')" />+ <input type="button" value="@Loc["Order.Reorder"]" class="btn btn-outline-info re-order-button" onclick="location = ('@Url.RouteUrl("ReOrder", new { orderId = Model.Id }) ')"/>}@if (Model.IsMerchandiseReturnAllowed){- <input type="button" value="@Loc["Order.ReturnItems"]" class="btn btn-outline-info return-items-button" onclick="location = ('@Url.RouteUrl("MerchandiseReturn", new { orderId = Model.Id }) ')" />+ <input type="button" value="@Loc["Order.ReturnItems"]" class="btn btn-outline-info return-items-button" onclick="location = ('@Url.RouteUrl("MerchandiseReturn", new { orderId = Model.Id }) ')"/>}</div>+ </div></div></div></div></div></div></div>-</div>-@await Component.InvokeAsync("Widget", new { widgetZone = "orderdetails_page_afterproducts", additionalData = Model.Id })+ @await Component.InvokeAsync("Widget", new { widgetZone = "orderdetails_page_afterproducts", additionalData = Model.Id })}else{-<script>var mix = {}</script>+ <script>var mix = {}</script>}- @if (Model.Shipments.Any())- {- <div class="shipments px-0">- <h5><strong>@Loc["Order.Shipments"]</strong></h5>- <div class="col-12 px-1">- <table class="table table-hover">- <colgroup>- <col />- </colgroup>- <thead class="table-inverse">- <tr>- <th>- <div class="row">- <div class="shipment-id col-md-2 col-sm-12">- @Loc["Order.Shipments.ID"]- </div>- <div class="tracking-number col-sm-2 d-none d-md-block">- @Loc["Order.Shipments.TrackingNumber"]- </div>- <div class="shipping-date col-sm-3 d-none d-md-block">- @Loc["Order.Shipments.ShippedDate"]- </div>- <div class="delivery-date col-sm-3 d-none d-md-block">- @Loc["Order.Shipments.DeliveryDate"]- </div>- <div class="view-details col-sm-2 d-none d-md-block">- @Loc["Order.Shipments.ViewDetails"]- </div>+@if (Model.Shipments.Any())+{+ <div class="shipments px-0">+ <h5>+ <strong>@Loc["Order.Shipments"]</strong>+ </h5>+ <div class="col-12 px-1">+ <table class="table table-hover">+ <colgroup>+ <col/>+ </colgroup>+ <thead class="table-inverse">+ <tr>+ <th>+ <div class="row">+ <div class="shipment-id col-md-2 col-sm-12">+ @Loc["Order.Shipments.ID"]+ </div>+ <div class="tracking-number col-sm-2 d-none d-md-block">+ @Loc["Order.Shipments.TrackingNumber"]+ </div>+ <div class="shipping-date col-sm-3 d-none d-md-block">+ @Loc["Order.Shipments.ShippedDate"]+ </div>+ <div class="delivery-date col-sm-3 d-none d-md-block">+ @Loc["Order.Shipments.DeliveryDate"]+ </div>+ <div class="view-details col-sm-2 d-none d-md-block">+ @Loc["Order.Shipments.ViewDetails"]+ </div>+ </div>+ </th>+ </tr>+ </thead>+ <tbody>+ @foreach (var item in Model.Shipments)+ {+ <tr>+ <td>+ <div class="row">+ <div class="shipment-id col-md-2 col-sm-12">+ <strong class="d-lg-none">@Loc["Order.Shipments.ID"]: </strong>+ <span>@item.ShipmentNumber.ToString()</span>+ </div>+ <div class="tracking-number col-md-2 col-sm-12">+ <strong class="d-lg-none">@Loc["Order.Shipments.TrackingNumber"]: </strong>+ @item.TrackingNumber+ </div>+ <div class="shipped-date col-md-3 col-sm-12">+ <div class="d-flex">+ @if (item.ShippedDate.HasValue)+ {+ <strong class="mx-1 d-lg-none">@Loc["Order.Shipments.ShippedDate"]:</strong>+ <span>@item.ShippedDate.Value.ToString("D")</span>+ }+ else+ {+ <strong class="d-lg-none">@Loc["Order.Shipments.ShippedDate"]: </strong>+ <span>@Loc["Order.Shipments.ShippedDate.NotYet"]</span>+ }</div>- </th>- </tr>- </thead>- <tbody>- @foreach (var item in Model.Shipments)- {- <tr>- <td>- <div class="row">- <div class="shipment-id col-md-2 col-sm-12">- <strong class="d-lg-none">@Loc["Order.Shipments.ID"]: </strong>- <span>@item.ShipmentNumber.ToString()</span>- </div>- <div class="tracking-number col-md-2 col-sm-12">- <strong class="d-lg-none">@Loc["Order.Shipments.TrackingNumber"]: </strong>- @item.TrackingNumber- </div>- <div class="shipped-date col-md-3 col-sm-12">- <div class="d-flex">- @if (item.ShippedDate.HasValue)- {- <strong class="mx-1 d-lg-none">@Loc["Order.Shipments.ShippedDate"]:</strong>- <span>@item.ShippedDate.Value.ToString("D")</span>- }- else- {- <strong class="d-lg-none">@Loc["Order.Shipments.ShippedDate"]: </strong>- <span>@Loc["Order.Shipments.ShippedDate.NotYet"]</span>- }- </div>- </div>- <div class="delivery-date col-md-3 col-sm-12">- <div class="d-fle">- @if (item.DeliveryDate.HasValue)- {- <strong class="mx-1 d-lg-none">@Loc["Order.Shipments.OrderDate"]:</strong>- <span>@item.DeliveryDate.Value.ToString("D")</span>- }- else- {- <span class="d-lg-none">@Loc["Order.Shipments.ViewDetails"]</span>- <span>@Loc["Order.Shipments.DeliveryDate.NotYet"]</span>- }- </div>- </div>- <div class="view-details col-md-2 col-sm-12">- <a class="btn btn-sm btn-secondary" href="@Url.RouteUrl("ShipmentDetails", new { shipmentId = item.Id })" title="@Loc["Order.Shipments.ViewDetails"]">@Loc["Order.Shipments.ViewDetails"]</a>- </div>- </div>- </td>- </tr>- }- </tbody>- </table>- </div>- </div>- }- @if (Model.OrderNotes.Any())- {- <div class="order-notes">- <h5>- @Loc["Order.Notes"]- </h5>- <div class="table-responsive">- <table class="table table-hover data-table">- <colgroup>- <col />- <col />- </colgroup>- <thead class="table-inverse">- <tr class="row mx-0">- <th class="created-on col-4">- @Loc["Order.Notes.CreatedOn"]- </th>- <th class="note col-8">- @Loc["Order.Notes.Note"]- </th>- </tr>- </thead>- <tbody>- @foreach (var item in Model.OrderNotes)- {- <tr class="row mx-0">- <td class="created-on col-4">- @item.CreatedOn.ToString(CultureInfo.InvariantCulture)- </td>- <td class="note col-8">- @Html.Raw(item.Note)- @if (item.HasDownload)+ </div>+ <div class="delivery-date col-md-3 col-sm-12">+ <div class="d-fle">+ @if (item.DeliveryDate.HasValue){- <p class="download">- <a href="@Url.RouteUrl("GetOrderNoteFile", new { ordernoteid = item.Id })">@Loc["Order.Notes.Download"]</a>- </p>+ <strong class="mx-1 d-lg-none">@Loc["Order.Shipments.OrderDate"]:</strong>+ <span>@item.DeliveryDate.Value.ToString("D")</span>}- </td>- </tr>+ else+ {+ <span class="d-lg-none">@Loc["Order.Shipments.ViewDetails"]</span>+ <span>@Loc["Order.Shipments.DeliveryDate.NotYet"]</span>+ }+ </div>+ </div>+ <div class="view-details col-md-2 col-sm-12">+ <a class="btn btn-sm btn-secondary" href="@Url.RouteUrl("ShipmentDetails", new { shipmentId = item.Id })" title="@Loc["Order.Shipments.ViewDetails"]">@Loc["Order.Shipments.ViewDetails"]</a>+ </div>+ </div>+ </td>+ </tr>+ }+ </tbody>+ </table>+ </div>+ </div>+}+@if (Model.OrderNotes.Any())+{+ <div class="order-notes">+ <h5>+ @Loc["Order.Notes"]+ </h5>+ <div class="table-responsive">+ <table class="table table-hover data-table">+ <colgroup>+ <col/>+ <col/>+ </colgroup>+ <thead class="table-inverse">+ <tr class="row mx-0">+ <th class="created-on col-4">+ @Loc["Order.Notes.CreatedOn"]+ </th>+ <th class="note col-8">+ @Loc["Order.Notes.Note"]+ </th>+ </tr>+ </thead>+ <tbody>+ @foreach (var item in Model.OrderNotes)+ {+ <tr class="row mx-0">+ <td class="created-on col-4">+ @item.CreatedOn.ToString(CultureInfo.InvariantCulture)+ </td>+ <td class="note col-8">+ @Html.Raw(item.Note)+ @if (item.HasDownload)+ {+ <p class="download">+ <a href="@Url.RouteUrl("GetOrderNoteFile", new { ordernoteid = item.Id })">@Loc["Order.Notes.Download"]</a>+ </p>}- </tbody>- </table>- </div>- </div>- }- @await Component.InvokeAsync("Widget", new { widgetZone = "orderdetails_page_bottom", additionalData = Model.Id })+ </td>+ </tr>+ }+ </tbody>+ </table>+ </div>+ </div>+}+@await Component.InvokeAsync("Widget", new { widgetZone = "orderdetails_page_bottom", additionalData = Model.Id })</div>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Product/CompareProducts.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Product/CompareProducts.cshtmlindex c7ff6a3ad..6ef7239c4 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Product/CompareProducts.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Product/CompareProducts.cshtml@@ -20,99 +20,105 @@}}<div class="page compare-products-page">- <h2 class="text-center generalTitle"><div>@Loc["Products.Compare.Title"]</div></h2>+ <h2 class="text-center generalTitle">+ <div>@Loc["Products.Compare.Title"]</div>+ </h2><template v-if="compareproducts !== null && compareproducts.Products.length > 0"><a class="btn btn-danger mb-3" @@click="removeFromCompareList(); getCompareList('@Url.RouteUrl("CompareProducts")')">@Loc["Products.Compare.Clear"]</a><div class="table-responsive"><table class="table table-hover compare-products-table table-bordered"><tbody>- <tr class="remove-product">- <td class="empty"> </td>- <template v-for="product in compareproducts.Products">- <td class="same-width">- <button type="button" title="@Loc["Common.Remove"]" class="btn btn-sm btn-link remove-button d-flex align-items-center justify-content-center" @@click="removeFromCompareList(product.Id); getCompareList('@Url.RouteUrl("CompareProducts")')">- <b-icon icon="trash" variant="danger" aria-hidden="true"></b-icon>- </button>- </td>- </template>- </tr>- <tr class="product-picture">- <td class="empty"> </td>+ <tr class="remove-product">+ <td class="empty"> </td>+ <template v-for="product in compareproducts.Products">+ <td class="same-width">+ <button type="button" title="@Loc["Common.Remove"]" class="btn btn-sm btn-link remove-button d-flex align-items-center justify-content-center" @@click="removeFromCompareList(product.Id); getCompareList('@Url.RouteUrl("CompareProducts")')">+ <b-icon icon="trash" variant="danger" aria-hidden="true"></b-icon>+ </button>+ </td>+ </template>+ </tr>+ <tr class="product-picture">+ <td class="empty"> </td>+ <template v-for="product in compareproducts.Products">+ <td class="same-width">+ <a class="picture" :href="product.Url">+ <img class="compare-img" :alt="product.DefaultPictureModel.AlternateText" :src="product.DefaultPictureModel.ImageUrl" :title="product.DefaultPictureModel.Title"/>+ </a>+ </td>+ </template>+ </tr>+ <tr class="product-name">+ <td>+ <label>@Loc["Products.Compare.Name"]</label>+ </td>+ <template v-for="product in compareproducts.Products">+ <td class="same-width">+ <a :href="product.Url">{{product.Name}}</a>+ </td>+ </template>+ </tr>+ <tr class="product-price">+ <td>+ <label>+ <strong>@Loc["Products.Compare.Price"]</strong>+ </label>+ </td>+ <template v-for="product in compareproducts.Products">+ <td class="same-width">+ <strong>{{product.ProductPrice.Price}}</strong>+ </td>+ </template>+ </tr>+ <template v-if="compareproducts.IncludeShortDescriptionInCompareProducts">+ <tr class="short-description">+ <td>+ <label>@Loc["Products.Compare.ShortDescription"]</label>+ </td><template v-for="product in compareproducts.Products"><td class="same-width">- <a class="picture" :href="product.Url"><img class="compare-img" :alt="product.DefaultPictureModel.AlternateText" :src="product.DefaultPictureModel.ImageUrl" :title="product.DefaultPictureModel.Title" /></a>+ <div v-html="product.ShortDescription"></div></td></template></tr>- <tr class="product-name">+ </template>+ <template v-for="specificationAttribute in specificationAttributes.Model">+ <tr class="specification"><td>- <label>@Loc["Products.Compare.Name"]</label>+ <label>{{specificationAttribute.SpecificationAttributeName}}</label></td><template v-for="product in compareproducts.Products"><td class="same-width">- <a :href="product.Url">{{product.Name}}</a>+ <template v-for="spec in product.SpecificationAttributeModels">+ <template v-if="spec.SpecificationAttributeId == specificationAttribute.SpecificationAttributeId">+ <template v-if="spec.ColorSquaresRgb == null">+ <div v-html="spec.ValueRaw" class="d-inline-flex mx-1"></div>+ </template>+ <template v-else>+ <div class="color-squares d-inline-flex mx-1">+ <span class="color-container" :title="spec.ValueRaw">+ <span class="color" :style="'background-color:' + spec.ColorSquaresRgb"> </span>+ </span>+ </div>+ </template>+ </template>+ </template></td></template></tr>- <tr class="product-price">+ </template>+ <template v-if="compareproducts.IncludeFullDescriptionInCompareProducts">+ <tr class="full-description"><td>- <label><strong>@Loc["Products.Compare.Price"]</strong></label>+ <label>@Loc["Products.Compare.FullDescription"]</label></td><template v-for="product in compareproducts.Products"><td class="same-width">- <strong>{{product.ProductPrice.Price}}</strong>+ <div v-html="product.FullDescription"></div></td></template></tr>- <template v-if="compareproducts.IncludeShortDescriptionInCompareProducts">- <tr class="short-description">- <td>- <label>@Loc["Products.Compare.ShortDescription"]</label>- </td>- <template v-for="product in compareproducts.Products">- <td class="same-width">- <div v-html="product.ShortDescription"></div>- </td>- </template>- </tr>- </template>- <template v-for="specificationAttribute in specificationAttributes.Model">- <tr class="specification">- <td>- <label>{{specificationAttribute.SpecificationAttributeName}}</label>- </td>- <template v-for="product in compareproducts.Products">- <td class="same-width">- <template v-for="spec in product.SpecificationAttributeModels">- <template v-if="spec.SpecificationAttributeId == specificationAttribute.SpecificationAttributeId">- <template v-if="spec.ColorSquaresRgb == null">- <div v-html="spec.ValueRaw" class="d-inline-flex mx-1"></div>- </template>- <template v-else>- <div class="color-squares d-inline-flex mx-1">- <span class="color-container" :title="spec.ValueRaw">- <span class="color" :style="'background-color:' + spec.ColorSquaresRgb"> </span>- </span>- </div>- </template>- </template>- </template>- </td>- </template>- </tr>- </template>- <template v-if="compareproducts.IncludeFullDescriptionInCompareProducts">- <tr class="full-description">- <td>- <label>@Loc["Products.Compare.FullDescription"]</label>- </td>- <template v-for="product in compareproducts.Products">- <td class="same-width">- <div v-html="product.FullDescription"></div>- </td>- </template>- </tr>- </template>+ </template></tbody></table></div>diff --git a/src/Plugins/Theme.Modern/Views/Modern/Product/Components/ProductReviews/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Product/Components/ProductReviews/Default.cshtmlindex eb2e8d49c..eb4124569 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Product/Components/ProductReviews/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Product/Components/ProductReviews/Default.cshtml@@ -10,12 +10,14 @@@Loc["reviews.onlyregistereduserscanwritereviews"]</div></template>-<partial name="Partials/ProductReview.Modal.cshtml" model="Model" />+<partial name="Partials/ProductReview.Modal.cshtml" model="Model"/><template id="product-review-list" v-if="productreviews.Model !== null"><div class="product-review-list"><template v-if="productreviews.Model.Items.length > 0">- <h5 class="mb-3"><strong>@Loc["Reviews.ExistingReviews"]</strong></h5>+ <h5 class="mb-3">+ <strong>@Loc["Reviews.ExistingReviews"]</strong>+ </h5><template v-for="review in productreviews.Model.Items"><div class="card product-review-item mb-3"><div class="card-header">@@ -34,7 +36,7 @@<div class="card-body"><div class="review-title mb-3"><h5 class="mb-0">{{review.Title}}</h5>- <b-form-rating id='rating-inline2' class='p-0' variant='warning' no-border size='sm' show-value precision='2' readonly inline :value='review.Rating'></b-form-rating>+ <b-form-rating id="rating-inline2" class="p-0" variant="warning" no-border size="sm" show-value precision="2" readonly inline :value="review.Rating"></b-form-rating></div><div class="review-content"><div class="review-text">@@ -57,8 +59,12 @@<div class="product-review-helpfulness d-inline-flex justify-content-end align-items-center flex-wrap"><span class="question">@Loc["Reviews.Helpfulness.WasHelpful?"]</span><span class="vote-options btn-group">- <span :id="'vote-yes-' + review.Helpfulness.ProductReviewId" @@click="productreviews.setProductReviewHelpfulness('@Url.RouteUrl("SetProductReviewHelpfulness")', 'true' , review.Id, '@Model.ProductId' , '@Loc[" Reviews.Helpfulness.WasHelpful?"]' )" class="btn btn-sm btn-outline vote"><b-icon variant="success" icon="hand-thumbs-up"></b-icon></span>- <span :id="'vote-no-' + review.Helpfulness.ProductReviewId" @@click="productreviews.setProductReviewHelpfulness('@Url.RouteUrl("SetProductReviewHelpfulness")', 'false' , review.Id, '@Model.ProductId' , '@Loc[" Reviews.Helpfulness.WasHelpful?"]' )" class="btn btn-sm btn-outline vote"><b-icon variant="danger" icon="hand-thumbs-down"></b-icon></span>+ <span :id="'vote-yes-' + review.Helpfulness.ProductReviewId" @@click="productreviews.setProductReviewHelpfulness('@Url.RouteUrl("SetProductReviewHelpfulness")', 'true' , review.Id, '@Model.ProductId' , '@Loc[" Reviews.Helpfulness.WasHelpful?"]' )" class="btn btn-sm btn-outline vote">+ <b-icon variant="success" icon="hand-thumbs-up"></b-icon>+ </span>+ <span :id="'vote-no-' + review.Helpfulness.ProductReviewId" @@click="productreviews.setProductReviewHelpfulness('@Url.RouteUrl("SetProductReviewHelpfulness")', 'false' , review.Id, '@Model.ProductId' , '@Loc[" Reviews.Helpfulness.WasHelpful?"]' )" class="btn btn-sm btn-outline vote">+ <b-icon variant="danger" icon="hand-thumbs-down"></b-icon>+ </span></span><span class="vote-stats d-inline-flex">(<span :id="'helpfulness-vote-yes-' + review.Helpfulness.ProductReviewId">{{review.Helpfulness.HelpfulYesTotal}}</span>/<span :id="'helpfulness-vote-no-' + review.Helpfulness.ProductReviewId">{{review.Helpfulness.HelpfulNoTotal}}</span>)diff --git a/src/Plugins/Theme.Modern/Views/Modern/Product/Components/ProductReviews/Partials/ProductReview.Modal.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Product/Components/ProductReviews/Partials/ProductReview.Modal.cshtmlindex 5ec357360..5438966fd 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Product/Components/ProductReviews/Partials/ProductReview.Modal.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Product/Components/ProductReviews/Partials/ProductReview.Modal.cshtml@@ -6,22 +6,28 @@<b-modal id="ModalProductReview" ref="ModalProductReview" :dark-theme="darkMode" size="xl" @@shown="productreviews.modalReviewShown()" @@hide="productreviews.modalReviewClose()" centered hide-footer hide-header><template v-if="productreviews.Model !== null">- <h2 class="generalTitle h3">@Loc["Reviews.ProductReviewsFor"] <a :href="'@productlink'">{{productreviews.Model.ProductName}}</a></h2>- <a class="modal-close" @@click="$bvModal.hide('ModalProductReview')"><b-icon icon="x"></b-icon></a>+ <h2 class="generalTitle h3">+ @Loc["Reviews.ProductReviewsFor"] <a :href="'@productlink'">{{productreviews.Model.ProductName}}</a>+ </h2>+ <a class="modal-close" @@click="$bvModal.hide('ModalProductReview')">+ <b-icon icon="x"></b-icon>+ </a><template v-if="!productreviews.Model.AddProductReview.SuccessfullyAdded"><div class="write-review" id="review-form">- <h5 class="generalTitle"><strong>@Loc["Reviews.Write"]</strong></h5>+ <h5 class="generalTitle">+ <strong>@Loc["Reviews.Write"]</strong>+ </h5><validation-observer v-slot="{ handleSubmit }"><form id="addReviewForm" asp-route="ProductReviews" asp-route-ProductId="@Model.ProductId" method="post" ref="modalForm"v-on:submit.prevent="handleSubmit(productreviews.submitProductReview)" :data-title="'@Loc["Reviews.ProductReviewsFor"] ' + productreviews.Model.ProductName">- <input type="hidden" asp-for="@Model.ProductId" />+ <input type="hidden" asp-for="@Model.ProductId"/><div asp-validation-summary="All" class="message-error my-3"></div><fieldset><div class="form-fields"><div class="form-group"><validation-provider tag="div" rules="required" name="AddProductReview.Title" v-slot="{ errors, classes }"><label for="AddProductReview_Title" class="col-form-label">@Loc["Reviews.Fields.Title"]:</label>- <input data-val-required="@Loc["reviews.fields.title.required"]" v-model="productreviews.Model.AddProductReview.Title" id="AddProductReview_Title" name="AddProductReview.Title" v-bind:class="[classes , 'form-control review-title']" :disabled="!productreviews.Model.AddProductReview.CanCurrentCustomerLeaveReview" />+ <input data-val-required="@Loc["reviews.fields.title.required"]" v-model="productreviews.Model.AddProductReview.Title" id="AddProductReview_Title" name="AddProductReview.Title" v-bind:class="[classes , 'form-control review-title']" :disabled="!productreviews.Model.AddProductReview.CanCurrentCustomerLeaveReview"/><span class="field-validation-error">{{ errors[0] }}</span></validation-provider></div>@@ -35,7 +41,7 @@<div class="form-group review-rating d-flex flex-wrap"><label for="AddProductReview_Rating" class="col-form-label w-100">@Loc["Reviews.Fields.Rating"]:</label><b-form-rating v-model="value" variant="warning" show-value value="5" inline></b-form-rating>- <input class="sr-only" id="AddProductReview_Rating" name="AddProductReview.Rating" v-model="value" />+ <input class="sr-only" id="AddProductReview_Rating" name="AddProductReview.Rating" v-model="value"/></div><template v-if="productreviews.Model.AddProductReview.DisplayCaptcha"><div id="captcha-popup"></div>@@ -43,7 +49,7 @@</div></fieldset><div class="buttons my-3">- <input type="submit" class="btn btn-info write-product-review-button" value="@Loc[" Reviews.SubmitButton"]" :disabled="!productreviews.Model.AddProductReview.CanCurrentCustomerLeaveReview" />+ <input type="submit" class="btn btn-info write-product-review-button" value="@Loc[" Reviews.SubmitButton"]" :disabled="!productreviews.Model.AddProductReview.CanCurrentCustomerLeaveReview"/></div></form></validation-observer>diff --git a/src/Plugins/Theme.Modern/Views/Modern/Product/NewProducts.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Product/NewProducts.cshtmlindex a2ced5ba1..34f44192f 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Product/NewProducts.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Product/NewProducts.cshtml@@ -7,14 +7,16 @@pagebuilder.AddTitleParts(Loc["Title.NewProducts"]);}<div class="page recently-added-products-page col-12 px-0">- <h1 class="h2 generalTitle text-center"><div>@Loc["Products.NewProducts"]</div></h1>+ <h1 class="h2 generalTitle text-center">+ <div>@Loc["Products.NewProducts"]</div>+ </h1>@if (Model.Any()){<div class="item-row">@foreach (var product in Model){<b-col xl="3" lg="3" sm="6" cols="6" class="product-container mb-2">- <partial name="Partials/CatalogProductView" model="product" />+ <partial name="Partials/CatalogProductView" model="product"/></b-col>}</div>diff --git a/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/AddToCart.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/AddToCart.cshtmlindex d2bf9d3d6..8f5952044 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/AddToCart.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/AddToCart.cshtml@@ -1,10 +1,10 @@@model ProductDetailsModel.AddToCartModel-@{+@{var shoppingCartType = Model.UpdateShoppingCartItemType ?? ShoppingCartType.ShoppingCart;}@if (!string.IsNullOrEmpty(Model.UpdatedShoppingCartItemId)){- <input asp-for="UpdatedShoppingCartItemId" type="hidden" />+ <input asp-for="UpdatedShoppingCartItemId" type="hidden"/>}@if (Model.EnteredPrice){@@ -25,6 +25,7 @@{<div class="min-qty-notification text-danger w-100 mb-2">@Model.MinimumQuantityNotification</div>}+if (!Model.DisableBuyButton){@if (Model.AllowedQuantities.Any())@@ -39,7 +40,6 @@}else{-var addId = "addtocart_" + Model.ProductId + "_EnteredQuantity";<label for="@addId" class="sr-only">@Loc["ShoppingCart.AddToCart"]</label><div class="qty-controls">@@ -68,8 +68,8 @@@Model.MeasureUnit</span>}-}+{var addToCartText = "";if (!string.IsNullOrEmpty(Model.UpdatedShoppingCartItemId) && Model.UpdateShoppingCartItemType is ShoppingCartType.ShoppingCart or ShoppingCartType.OnHoldCart)@@ -83,15 +83,18 @@{addToCartText = Loc["ShoppingCart.Reservation"];}+if (Model.AvailableForPreOrder){addToCartText = Loc["ShoppingCart.PreOrder"];}+if (Model.IsAuction){addToCartText = Loc["ShoppingCart.BuyNow"];}}+<div class="input-group-append"><button type="button" id="[email protected]" class="btn btn-info w-100 add-to-cart-button d-inline-flex" data-productid="@Model.ProductId" onclick="AxiosCart.addproducttocart_details('@Url.RouteUrl("AddProductDetails", new { productId = Model.ProductId, shoppingCartTypeId = (int)shoppingCartType })', @($"'#product-details-form-{Model.ProductId}'"));return false;"><span>@addToCartText</span>@@ -100,4 +103,4 @@}}}-</div>+</div>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/AddToWishlist.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/AddToWishlist.cshtmlindex 0387fa0e3..a3bd30952 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/AddToWishlist.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/AddToWishlist.cshtml@@ -11,8 +11,8 @@addToWishlistText = Loc["ShoppingCart.AddToWishlist"];}-<b-button variant="outline-secondary" id="[email protected]" class="add-to-wishlist-button mr-1" data-productid="@Model.ProductId" onclick="AxiosCart.addproducttocart_details('@Url.RouteUrl("AddProductDetails", new { productId = Model.ProductId, shoppingCartTypeId = (int)ShoppingCartType.Wishlist })', @($"'#product-details-form-{Model.ProductId}'"));return false;" v-b-tooltip.hover.bottom title="@addToWishlistText">- <span class="sr-only">@addToWishlistText</span>- <span class="icons icon-heart"></span>-</b-button>-}+ <b-button variant="outline-secondary" id="[email protected]" class="add-to-wishlist-button mr-1" data-productid="@Model.ProductId" onclick="AxiosCart.addproducttocart_details('@Url.RouteUrl("AddProductDetails", new { productId = Model.ProductId, shoppingCartTypeId = (int)ShoppingCartType.Wishlist })', @($"'#product-details-form-{Model.ProductId}'"));return false;" v-b-tooltip.hover.bottom title="@addToWishlistText">+ <span class="sr-only">@addToWishlistText</span>+ <span class="icons icon-heart"></span>+ </b-button>+}\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/Breadcrumbs.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/Breadcrumbs.cshtmlindex 09a1e154d..d7356d1cf 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/Breadcrumbs.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/Breadcrumbs.cshtml@@ -2,37 +2,37 @@@if (Model.Enabled){var count = 1;- <ol class="breadcrumb mb-0" itemscope="itemscope" itemtype="http://schema.org/BreadcrumbList">- @await Component.InvokeAsync("Widget", new { widgetZone = "productbreadcrumb_before" })- <li class="breadcrumb-item" itemprop="itemListElement" itemscope="itemscope" itemtype="http://schema.org/ListItem">- <a href="@Url.RouteUrl("HomePage")" target="_self">- <b-icon icon="house-door" scale="1.25" shift-v="1.25" aria-hidden="true"></b-icon>- <span itemprop="name">@Loc["Products.Breadcrumb.Top"]</span>+ <ol class="breadcrumb mb-0" itemscope="itemscope" itemtype="http://schema.org/BreadcrumbList">+ @await Component.InvokeAsync("Widget", new { widgetZone = "productbreadcrumb_before" })+ <li class="breadcrumb-item" itemprop="itemListElement" itemscope="itemscope" itemtype="http://schema.org/ListItem">+ <a href="@Url.RouteUrl("HomePage")" target="_self">+ <b-icon icon="house-door" scale="1.25" shift-v="1.25" aria-hidden="true"></b-icon>+ <span itemprop="name">@Loc["Products.Breadcrumb.Top"]</span>+ <span itemprop="item" itemscope itemtype="http://schema.org/Thing"+ id="@Url.RouteUrl("HomePage")">+ </span>+ <meta itemprop="position" content="@count"/>+ </a>+ </li>+ @foreach (var category in Model.CategoryBreadcrumb)+ {+ count++;+ <li itemprop="itemListElement" itemscope="itemscope" itemtype="http://schema.org/ListItem" class="breadcrumb-item">+ <a href="@Url.RouteUrl("Category", new { category.SeName })" target="_self">+ <span itemprop="name">@category.Name</span><span itemprop="item" itemscope itemtype="http://schema.org/Thing"- id="@Url.RouteUrl("HomePage")">+ id="@Url.RouteUrl("Category", new { category.SeName })"></span>- <meta itemprop="position" content="@count" />+ <meta itemprop="position" content="@count"/></a></li>- @foreach (var category in Model.CategoryBreadcrumb)- {- count++;- <li itemprop="itemListElement" itemscope="itemscope" itemtype="http://schema.org/ListItem" class="breadcrumb-item">- <a href="@Url.RouteUrl("Category", new { category.SeName })" target="_self">- <span itemprop="name">@category.Name</span>- <span itemprop="item" itemscope itemtype="http://schema.org/Thing"- id="@Url.RouteUrl("Category", new { category.SeName })">- </span>- <meta itemprop="position" content="@count" />- </a>- </li>- }- <li itemprop="itemListElement" itemscope="itemscope" itemtype="http://schema.org/ListItem" class="breadcrumb-item active">- <strong class="current-item" itemprop="name">@Model.ProductName</strong>- <span itemprop="item" itemscope itemtype="http://schema.org/Thing"- id="@Url.RouteUrl("Product", new { SeName = Model.ProductSeName })">- </span>- <meta itemprop="position" content="@(count+1)" />- </li>- </ol>+ }+ <li itemprop="itemListElement" itemscope="itemscope" itemtype="http://schema.org/ListItem" class="breadcrumb-item active">+ <strong class="current-item" itemprop="name">@Model.ProductName</strong>+ <span itemprop="item" itemscope itemtype="http://schema.org/Thing"+ id="@Url.RouteUrl("Product", new { SeName = Model.ProductSeName })">+ </span>+ <meta itemprop="position" content="@(count + 1)"/>+ </li>+ </ol>}\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/Pictures.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/Pictures.cshtmlindex 7164370c5..a75d730dc 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/Pictures.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/Pictures.cshtml@@ -19,7 +19,7 @@@foreach (var picture in Model.PictureModels){<swiper-slide>- <img src="@picture.ThumbImageUrl" alt="@picture.AlternateText" title="@picture.Title" />+ <img src="@picture.ThumbImageUrl" alt="@picture.AlternateText" title="@picture.Title"/></swiper-slide>}</swiper>@@ -28,7 +28,7 @@@foreach (var picture in Model.PictureModels){<swiper-slide>- <img src="@picture.ImageUrl" data-srcs="@picture.ImageUrl" data-zoom-src="@picture.FullSizeImageUrl" alt="@picture.AlternateText" title="@picture.Title" />+ <img src="@picture.ImageUrl" data-srcs="@picture.ImageUrl" data-zoom-src="@picture.FullSizeImageUrl" alt="@picture.AlternateText" title="@picture.Title"/>@if (Model.DefaultPictureZoomEnabled){<div class="zoom-button" onclick="zoomImg(this)">diff --git a/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/ProductAttributes.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/ProductAttributes.cshtmlindex 9afc5a60d..f79425eaa 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/ProductAttributes.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/ProductAttributes.cshtml@@ -1,5 +1,4 @@-@using System.Text;-@model ProductDetailsModel+@model ProductDetailsModel<div id="product-attributes"></div>@{@@ -14,31 +13,32 @@switch (attribute.AttributeControlType){case AttributeControlType.DropdownList:- {- attributeChangeScriptsBuilder.Append($"document.querySelector('#{controlId}').addEventListener('change', function (){{{attributeChangeHandlerFuncName}();}});\n");- }+ {+ attributeChangeScriptsBuilder.Append($"document.querySelector('#{controlId}').addEventListener('change', function (){{{attributeChangeHandlerFuncName}();}});\n");+ }break;case AttributeControlType.RadioList:case AttributeControlType.ColorSquares:case AttributeControlType.ImageSquares:+ {+ foreach (var attributeValue in attribute.Values){- foreach (var attributeValue in attribute.Values)- {- attributeChangeScriptsBuilder.Append($"document.querySelector('#{controlId}_{attributeValue.Id}').addEventListener('click',function(e){{{attributeChangeHandlerFuncName}();}},false);\n");- }+ attributeChangeScriptsBuilder.Append($"document.querySelector('#{controlId}_{attributeValue.Id}').addEventListener('click',function(e){{{attributeChangeHandlerFuncName}();}},false);\n");}+ }break;case AttributeControlType.Checkboxes:case AttributeControlType.ReadonlyCheckboxes:+ {+ foreach (var attributeValue in attribute.Values){- foreach (var attributeValue in attribute.Values)- {- attributeChangeScriptsBuilder.Append($"document.querySelector('#{controlId}_{attributeValue.Id}').addEventListener('click',function(e){{{attributeChangeHandlerFuncName}();}},false);\n");- }+ attributeChangeScriptsBuilder.Append($"document.querySelector('#{controlId}_{attributeValue.Id}').addEventListener('click',function(e){{{attributeChangeHandlerFuncName}();}},false);\n");}+ }break;}}+//render scripts<div id="product-attributes"><template v-if="standardProductAttributes_@(Model.Id).ProductAttributes !== 'undefined'">@@ -57,7 +57,7 @@<td :id="'product_attribute_input_' + attribute.Id"><template v-if="attribute.AttributeControlType==4"><label :for="'product_attribute_' + attribute.Id" class="sr-only">product_attribute_{{attribute.Id}}</label>- <input :name="'attributes[' + attribute.Id+']'" type="text" class="form-control textbox" :id="'product_attribute_' + attribute.Id" :value="attribute.DefaultValue" @@change="standardProductAttributes_@(Model.Id).attrchange" />+ <input :name="'attributes[' + attribute.Id+']'" type="text" class="form-control textbox" :id="'product_attribute_' + attribute.Id" :value="attribute.DefaultValue" @@change="standardProductAttributes_@(Model.Id).attrchange"/></template><template v-if="attribute.AttributeControlType==1"><label :for="'product_attribute_' + attribute.Id" class="sr-only">product_attribute_{{attribute.Id}}</label>@@ -88,7 +88,7 @@:value="attributeValue.Id":checked="attributeValue.IsPreSelected":data-disable="attributeValue.Id"- @@change="standardProductAttributes_@(Model.Id).attrchange" />+ @@change="standardProductAttributes_@(Model.Id).attrchange"/><span class="custom-control-label"></span><span class="custom-control-description" :for="'product_attribute_' + attribute.Id + '_' + attributeValue.Id"><template v-if="attributeValue.PriceAdjustment==null">@@ -117,7 +117,7 @@:value="attributeValue.Id":checked="attributeValue.IsPreSelected"@@change="standardProductAttributes_@(Model.Id).attrchange"- disabled="disabled" />+ disabled="disabled"/><input v-elseclass="custom-control-input":id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id"@@ -126,7 +126,7 @@:value="attributeValue.Id":checked="attributeValue.IsPreSelected":data-disable="attributeValue.Id"- @@change="standardProductAttributes_@(Model.Id).attrchange" />+ @@change="standardProductAttributes_@(Model.Id).attrchange"/><span class="custom-control-label"></span><span class="custom-control-description" :for="'product_attribute_' + attribute.Id + '_' + attributeValue.Id"><template v-if="attributeValue.PriceAdjustment==null">@@ -152,7 +152,7 @@id="qqfile"name="qqfile":data-url="'@fileLink/' + attribute.Id + '?productId=' + attribute.ProductId"- @@change="vm.uploadFile($event.target)" />+ @@change="vm.uploadFile($event.target)"/></div></template><input class="hidden-upload-input"@@ -160,20 +160,26 @@:id="'product_attribute_' + attribute.Id":name="'attributes[' + attribute.Id+']'"v-model="attribute.DefaultValue"- :value="attribute.DefaultValue" />+ :value="attribute.DefaultValue"/><div id="download-message" class="alert my-2" style="display: none;"></div>- <div :id="'product_attribute_' + attribute.Id + 'downloadurl'" class="download-file" style="display: none;"><a class="btn btn-outline-info"> Download </a></div>+ <div :id="'product_attribute_' + attribute.Id + 'downloadurl'" class="download-file" style="display: none;">+ <a class="btn btn-outline-info"> Download </a>+ </div></template><template v-if="attribute.AttributeControlType==40"><ul class="option-list color-squares w-100 d-inline-flex flex-wrap px-0 mb-0" :id="'color-squares-' + attribute.Id"><li v-for="attributeValue in attribute.Values" class="mr-1 p-0"><label :for="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" class="mb-0">- <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="standardProductAttributes_@(Model.Id).attrchange" />+ <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="standardProductAttributes_@(Model.Id).attrchange"/><template v-if="attributeValue.PriceAdjustment==null">- <span class="color-container" :title="attributeValue.Name"> <span class="color" :style="'background-color:' + attributeValue.ColorSquaresRgb"></span> </span>+ <span class="color-container" :title="attributeValue.Name">+ <span class="color" :style="'background-color:' + attributeValue.ColorSquaresRgb"></span>+ </span></template><template v-else>- <span class="color-container" :title="attributeValue.Name + ' [' + attributeValue.PriceAdjustment + ']'"> <span class="color" :style="'background-color:' + attributeValue.ColorSquaresRgb"></span> </span>+ <span class="color-container" :title="attributeValue.Name + ' [' + attributeValue.PriceAdjustment + ']'">+ <span class="color" :style="'background-color:' + attributeValue.ColorSquaresRgb"></span>+ </span></template></label></li>@@ -184,20 +190,24 @@<li v-for="attributeValue in attribute.Values" class="mr-1 p-0"><label :for="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" class="mb-0"><template v-if="attributeValue.PriceAdjustment==null">- <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="standardProductAttributes_@(Model.Id).attrchange" />+ <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="standardProductAttributes_@(Model.Id).attrchange"/><span :id="'imgSqr_' + attributeValue.Id" class="color-container"><span class="color" :style="'background: url(' + attributeValue.ImageSquaresPictureModel.ImageUrl + ') 50% 50% no-repeat;'"></span></span><b-tooltip :target="'imgSqr_' + attributeValue.Id" placement="bottom">- <div class="image-square-tooltip"><img :src="attributeValue.ImageSquaresPictureModel.FullSizeImageUrl" :alt="attributeValue.Name" /> <span>{{attributeValue.Name}}</span></div>+ <div class="image-square-tooltip">+ <img :src="attributeValue.ImageSquaresPictureModel.FullSizeImageUrl" :alt="attributeValue.Name"/> <span>{{attributeValue.Name}}</span>+ </div></b-tooltip></template><template v-else>- <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="standardProductAttributes_@(Model.Id).attrchange" />- <span :id="'imgSqr_' + attributeValue.Id" class="color-container"> <span class="color" :style="'background: url(' + attributeValue.ImageSquaresPictureModel.ImageUrl + ') 50% 50% no-repeat;'"></span> </span>+ <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="standardProductAttributes_@(Model.Id).attrchange"/>+ <span :id="'imgSqr_' + attributeValue.Id" class="color-container">+ <span class="color" :style="'background: url(' + attributeValue.ImageSquaresPictureModel.ImageUrl + ') 50% 50% no-repeat;'"></span>+ </span><b-tooltip :target="'imgSqr_' + attributeValue.Id" placement="bottom"><div class="image-square-tooltip">- <img :src="attributeValue.ImageSquaresPictureModel.FullSizeImageUrl" :alt="attributeValue.Name + ' [' + attributeValue.PriceAdjustment + ']'" />+ <img :src="attributeValue.ImageSquaresPictureModel.FullSizeImageUrl" :alt="attributeValue.Name + ' [' + attributeValue.PriceAdjustment + ']'"/><span>{{attributeValue.Name}}[{{attributeValue.PriceAdjustment}}]</span></div></b-tooltip>diff --git a/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/ProductTags.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/ProductTags.cshtmlindex 2d6ccb4be..5290c25c5 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/ProductTags.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Product/Partials/ProductTags.cshtml@@ -1,11 +1,11 @@@model IList<ProductTagModel><b-col cols="12" class="product-tags-box px-0"><div class="product-tags-list">- @for (int i = 0; i < Model.Count; i++)+ @for (var i = 0; i < Model.Count; i++){<b-button size="sm" variant="outline-secondary" class="producttag" href="@Url.RouteUrl("ProductsByTagName", new { Model[i].SeName })">@Model[i].Name <span>@Loc["Products.Tags.Count", Model[i].ProductCount]</span></b-button>}</div>-</b-col>+</b-col>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Product/ProductEmailAFriend.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Product/ProductEmailAFriend.cshtmlindex 84d15079c..c7aae6825 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Product/ProductEmailAFriend.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Product/ProductEmailAFriend.cshtml@@ -8,9 +8,13 @@pagebuilder.AddTitleParts(Loc["Title.ProductEmailAFriend"]);}<div class="page email-a-friend-page">- <h1 class="h2 text-center generalTitle"><div>@Loc["Products.EmailAFriend.Title"]</div></h1>+ <h1 class="h2 text-center generalTitle">+ <div>@Loc["Products.EmailAFriend.Title"]</div>+ </h1><div class="mb-3">- <h4 class="mb-0"><a href="@Url.RouteUrl("Product", new { SeName = Model.ProductSeName })" class="product">@Model.ProductName</a></h4>+ <h4 class="mb-0">+ <a href="@Url.RouteUrl("Product", new { SeName = Model.ProductSeName })" class="product">@Model.ProductName</a>+ </h4>@if (Model.SuccessfullySent){<div class="alert alert-info my-3 text-center result">@@ -25,13 +29,13 @@<div class="form-group"><label asp-for="FriendEmail" class="col-form-label">@Loc["Products.EmailAFriend.FriendEmail"]:</label><input asp-for="FriendEmail" class="form-control friend-email"- v-validate="'required|email'" placeholder="@Loc["Products.EmailAFriend.FriendEmail.Hint"]" />+ v-validate="'required|email'" placeholder="@Loc["Products.EmailAFriend.FriendEmail.Hint"]"/><span class="field-validation-error">{{veeErrors.first('FriendEmail')}}</span><span asp-validation-for="FriendEmail"></span></div><div class="form-group"><label asp-for="YourEmailAddress" class="col-form-label">@Loc["Products.EmailAFriend.YourEmailAddress"]:</label>- <input asp-for="YourEmailAddress" class="form-control your-email" v-validate="'required|email'" placeholder="@Loc["Products.EmailAFriend.YourEmailAddress.Hint"]" />+ <input asp-for="YourEmailAddress" class="form-control your-email" v-validate="'required|email'" placeholder="@Loc["Products.EmailAFriend.YourEmailAddress.Hint"]"/><span class="field-validation-error">{{veeErrors.first('YourEmailAddress')}}</span><span asp-validation-for="YourEmailAddress"></span></div>@@ -44,12 +48,12 @@@if (Model.DisplayCaptcha){<div class="captcha-box">- <captcha />+ <captcha/></div>}</div><div class="btn-group">- <input type="submit" name="send-email" class="btn btn-secondary send-email-a-friend-button" value="@Loc["Products.EmailAFriend.Button"]" />+ <input type="submit" name="send-email" class="btn btn-secondary send-email-a-friend-button" value="@Loc["Products.EmailAFriend.Button"]"/></div></form>}diff --git a/src/Plugins/Theme.Modern/Views/Modern/Product/ProductLayout.Grouped.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Product/ProductLayout.Grouped.cshtmlindex db46fa12c..c3c12f1d1 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Product/ProductLayout.Grouped.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Product/ProductLayout.Grouped.cshtml@@ -17,130 +17,134 @@pagebuilder.AddCanonicalUrlParts(productUrl);}}+@section meta{@if (seoSettings.OpenGraphMetaTags){- <meta property="og:type" content="product" />- <meta property="og:title" content="@Html.Encode(Model.Name)" />- <meta property="og:description" content="@Html.Encode(Model.MetaDescription)" />- <meta property="og:image" content="@Model.DefaultPictureModel.ImageUrl" />- <meta property="og:image:url" content="@Model.DefaultPictureModel.ImageUrl" />- <meta property="og:url" content="@this.Url.ActionContext.HttpContext.Request.GetEncodedUrl()" />- <meta property="og:site_name" content="@Html.Encode(Model.CurrentStoreName)" />+ <meta property="og:type" content="product"/>+ <meta property="og:title" content="@Html.Encode(Model.Name)"/>+ <meta property="og:description" content="@Html.Encode(Model.MetaDescription)"/>+ <meta property="og:image" content="@Model.DefaultPictureModel.ImageUrl"/>+ <meta property="og:image:url" content="@Model.DefaultPictureModel.ImageUrl"/>+ <meta property="og:url" content="@Url.ActionContext.HttpContext.Request.GetEncodedUrl()"/>+ <meta property="og:site_name" content="@Html.Encode(Model.CurrentStoreName)"/>}@if (seoSettings.TwitterMetaTags){- <meta property="twitter:card" content="summary" />- <meta property="twitter:site" content="@Html.Encode(Model.CurrentStoreName)" />- <meta property="twitter:title" content="@Html.Encode(Model.Name)" />- <meta property="twitter:description" content="@Html.Encode(Model.MetaDescription)" />- <meta property="twitter:image" content="@Model.DefaultPictureModel.ImageUrl" />- <meta property="twitter:url" content="@this.Url.ActionContext.HttpContext.Request.GetEncodedUrl()" />+ <meta property="twitter:card" content="summary"/>+ <meta property="twitter:site" content="@Html.Encode(Model.CurrentStoreName)"/>+ <meta property="twitter:title" content="@Html.Encode(Model.Name)"/>+ <meta property="twitter:description" content="@Html.Encode(Model.MetaDescription)"/>+ <meta property="twitter:image" content="@Model.DefaultPictureModel.ImageUrl"/>+ <meta property="twitter:url" content="@Url.ActionContext.HttpContext.Request.GetEncodedUrl()"/>}}+<!--product breadcrumb-->+@section Breadcrumb{- <partial name="Partials/Breadcrumbs" model="Model.Breadcrumb" />+ <partial name="Partials/Breadcrumbs" model="Model.Breadcrumb"/>}+@await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_after_breadcrumb", additionalData = Model.Id })- <div class="page product-details-page product-standard product-grouped">- @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_top", additionalData = Model.Id })- <validation-observer ref="ProductFormObserver">- <div itemscope itemtype="http://schema.org/Product" data-productid="@Model.Id">- <div class="product-essential">- <b-col>- <b-row>- <vc:widget widget-zone="productdetails_before_pictures" additional-data="@Model.Id"></vc:widget>- <!--product pictures-->- <partial name="Partials/Pictures" model="Model" />- <vc:widget widget-zone="productdetails_after_pictures" additional-data="@Model.Id"></vc:widget>- <b-col xl="5" lg="6" md="7" cols="12" class="overview pl-md-3 pl-0 pr-0">- <partial name="Partials/Unavailable" model="Model" />- <div class="product-name">- <h1 class="generalTitle mb-3" itemprop="name">- @Model.Name- </h1>- </div>- @if (!String.IsNullOrEmpty(Model.ShortDescription))- {- <div class="short-description mb-3">- @Html.Raw(Model.ShortDescription)- </div>- }- @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_overview_top", additionalData = Model.Id })- <!--product reviews-->- @if (Model.ProductReviewOverview.AllowCustomerReviews)- {- <partial name="Partials/ProductReviewOverview" model="Model.ProductReviewOverview" />- }- <!--product collections-->- @if (Model.ProductCollections.Any())- {- <partial name="Partials/Collections" model="Model.ProductCollections" />- }- <!--warehouses-->- @if (Model.AllowToSelectWarehouse)- {- <partial name="Partials/Warehouses" model="Model" />- }- <!--compare, email a friend-->- <b-btn-group class="mt-2 mb-3 w-100">- @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_inside_overview_buttons_before", additionalData = Model.Id })- <partial name="Partials/ProductsComparison" model="Model" />- <partial name="Partials/SendFriend" model="Model" />- @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_inside_overview_buttons_after", additionalData = Model.Id })- </b-btn-group>- <partial name="Partials/ShareButton" model="Model" />- @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_overview_bottom", additionalData = Model.Id })- </b-col>- </b-row>+<div class="page product-details-page product-standard product-grouped">+ @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_top", additionalData = Model.Id })+ <validation-observer ref="ProductFormObserver">+ <div itemscope itemtype="http://schema.org/Product" data-productid="@Model.Id">+ <div class="product-essential">+ <b-col>+ <b-row>+ <vc:widget widget-zone="productdetails_before_pictures" additional-data="@Model.Id"></vc:widget>+ <!--product pictures-->+ <partial name="Partials/Pictures" model="Model"/>+ <vc:widget widget-zone="productdetails_after_pictures" additional-data="@Model.Id"></vc:widget>+ <b-col xl="5" lg="6" md="7" cols="12" class="overview pl-md-3 pl-0 pr-0">+ <partial name="Partials/Unavailable" model="Model"/>+ <div class="product-name">+ <h1 class="generalTitle mb-3" itemprop="name">+ @Model.Name+ </h1>+ </div>+ @if (!string.IsNullOrEmpty(Model.ShortDescription))+ {+ <div class="short-description mb-3">+ @Html.Raw(Model.ShortDescription)+ </div>+ }+ @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_overview_top", additionalData = Model.Id })+ <!--product reviews-->+ @if (Model.ProductReviewOverview.AllowCustomerReviews)+ {+ <partial name="Partials/ProductReviewOverview" model="Model.ProductReviewOverview"/>+ }+ <!--product collections-->+ @if (Model.ProductCollections.Any())+ {+ <partial name="Partials/Collections" model="Model.ProductCollections"/>+ }+ <!--warehouses-->+ @if (Model.AllowToSelectWarehouse)+ {+ <partial name="Partials/Warehouses" model="Model"/>+ }+ <!--compare, email a friend-->+ <b-btn-group class="mt-2 mb-3 w-100">+ @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_inside_overview_buttons_before", additionalData = Model.Id })+ <partial name="Partials/ProductsComparison" model="Model"/>+ <partial name="Partials/SendFriend" model="Model"/>+ @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_inside_overview_buttons_after", additionalData = Model.Id })+ </b-btn-group>+ <partial name="Partials/ShareButton" model="Model"/>+ @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_overview_bottom", additionalData = Model.Id })</b-col>- </div>+ </b-row>+ </b-col>+ </div>- <b-col cols="12" class="px-0 my-3">- <div>- <b-tabs content-class="mt-3" align="center">- <b-tab title="@Loc["Products.Description"]" active>- @Html.Raw(Model.FullDescription)- </b-tab>- @if (Model.ProductTags.Any())- {- <b-tab title="@Loc["Products.Tags"]">- <partial name="Partials/ProductTags" model="Model.ProductTags" />- </b-tab>- }- @if (Model.ProductSpecifications.Any())- {- <b-tab title="@Loc["Products.Specs"]">- <partial name="Partials/ProductSpecifications" model="Model.ProductSpecifications" />- </b-tab>- }- @if (Model.ProductReviewOverview.AllowCustomerReviews)- {- <b-tab id="review-tab" title="@Loc["Products.Reviews"]" :active="active ? true : false">- @await Component.InvokeAsync("ProductReviews", new { productId = Model.Id })- </b-tab>- }- @if (Model.AskQuestionOnProduct)- {- <b-tab title="@Loc["Products.ContactUs"]">- <partial name="Partials/AskQuestionOnProduct" model="Model.ProductAskQuestion" />- </b-tab>- }- </b-tabs>- </div>- </b-col>- @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_before_collateral", additionalData = Model.Id })- <div class="product-collateral">- <div>- <!--associated products-->- @foreach (var variant in Model.AssociatedProducts)- {- <form asp-route="Product" asp-route-sename="@Model.SeName" method="post" id=@($"product-details-form-{variant.Id}") ref="form" v-on:submit.prevent="formSubmitParam($event, vm.$refs.ProductFormObserver)">- <b-card no-body class="overflow-hidden associatedItem mb-3">- <b-row no-gutters>+ <b-col cols="12" class="px-0 my-3">+ <div>+ <b-tabs content-class="mt-3" align="center">+ <b-tab title="@Loc["Products.Description"]" active>+ @Html.Raw(Model.FullDescription)+ </b-tab>+ @if (Model.ProductTags.Any())+ {+ <b-tab title="@Loc["Products.Tags"]">+ <partial name="Partials/ProductTags" model="Model.ProductTags"/>+ </b-tab>+ }+ @if (Model.ProductSpecifications.Any())+ {+ <b-tab title="@Loc["Products.Specs"]">+ <partial name="Partials/ProductSpecifications" model="Model.ProductSpecifications"/>+ </b-tab>+ }+ @if (Model.ProductReviewOverview.AllowCustomerReviews)+ {+ <b-tab id="review-tab" title="@Loc["Products.Reviews"]" :active="active ? true : false">+ @await Component.InvokeAsync("ProductReviews", new { productId = Model.Id })+ </b-tab>+ }+ @if (Model.AskQuestionOnProduct)+ {+ <b-tab title="@Loc["Products.ContactUs"]">+ <partial name="Partials/AskQuestionOnProduct" model="Model.ProductAskQuestion"/>+ </b-tab>+ }+ </b-tabs>+ </div>+ </b-col>+ @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_before_collateral", additionalData = Model.Id })+ <div class="product-collateral">+ <div>+ <!--associated products-->+ @foreach (var variant in Model.AssociatedProducts)+ {+ <form asp-route="Product" asp-route-sename="@Model.SeName" method="post" id=@($"product-details-form-{variant.Id}") ref="form" v-on:submit.prevent="formSubmitParam($event, vm.$refs.ProductFormObserver)">+ <b-card no-body class="overflow-hidden associatedItem mb-3">+ <b-row no-gutters><b-col lg="3" md="4"><b-card-img id="[email protected]" alt="@variant.DefaultPictureModel.AlternateText" src="@variant.DefaultPictureModel.ImageUrl" class="rounded-0"></b-card-img></b-col>@@ -150,38 +154,38 @@@Html.Raw(variant.ShortDescription)</b-card-text><!--availability-->- <partial name="Partials/Availability" model="variant" />+ <partial name="Partials/Availability" model="variant"/><!--Code products - SKU, MAN, GTIN, Vendor info -->- <partial name="Partials/Codes" model="variant" />+ <partial name="Partials/Codes" model="variant"/><!--delivery-->@if ((variant.FreeShippingNotificationEnabled && Model.IsFreeShipping) || !string.IsNullOrWhiteSpace(variant.DeliveryDate)- || variant.NotReturnable || variant.AdditionalShippingCharge > 0)+ || variant.NotReturnable || variant.AdditionalShippingCharge > 0){- <partial name="Partials/DeliveryInfo" model="variant" />+ <partial name="Partials/DeliveryInfo" model="variant"/>}<!--sample download-->@if (variant.HasSampleDownload){- <partial name="Partials/DownloadSample" model="variant" />+ <partial name="Partials/DownloadSample" model="variant"/>}<!--attributes-->@{if (variant.ProductAttributes.Any()){- <partial name="Partials/ProductAttributes" model="variant" />+ <partial name="Partials/ProductAttributes" model="variant"/>}}<!--gift voucher-->@{if (variant.GiftVoucher.IsGiftVoucher){- <partial name="Partials/GiftVoucherInfo" model="variant.GiftVoucher" />+ <partial name="Partials/GiftVoucherInfo" model="variant.GiftVoucher"/>}}<!--price breaks-->@if (variant.TierPrices.Any()){- <partial name="Partials/TierPrices" model="variant.TierPrices" />+ <partial name="Partials/TierPrices" model="variant.TierPrices"/>}@{var dataDictAddToCart = new ViewDataDictionary(ViewData)@@ -197,29 +201,29 @@<partial name="Partials/AddToCart" model="variant.AddToCart"/><div class="mt-2"><partial name="Partials/AddToWishlist" model="variant.AddToCart"/>- </div>-+ </div>+</b-card-body></b-col></b-row>- </b-card>- </form>- }+ </b-card>+ </form>+ }- @if (Model.AssociatedProducts.Count == 0)- {- <div class="no-associated-products">- @Loc["Products.NoAssociatedProducts"]- </div>- }+ @if (Model.AssociatedProducts.Count == 0)+ {+ <div class="no-associated-products">+ @Loc["Products.NoAssociatedProducts"]</div>- </div>+ }</div>- @await Component.InvokeAsync("RelatedProducts", new { productId = Model.Id })- </validation-observer>- @if (Model.EmailAFriendEnabled)- {- @await Component.InvokeAsync("ProductEmailAFriend", new { productId = Model.Id })- }- @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_bottom", additionalData = Model.Id })- </div>+ </div>+ </div>+ @await Component.InvokeAsync("RelatedProducts", new { productId = Model.Id })+ </validation-observer>+ @if (Model.EmailAFriendEnabled)+ {+ @await Component.InvokeAsync("ProductEmailAFriend", new { productId = Model.Id })+ }+ @await Component.InvokeAsync("Widget", new { widgetZone = "productdetails_bottom", additionalData = Model.Id })+</div>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Product/ProductLayout.Simple.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Product/ProductLayout.Simple.cshtmlindex e994cf788..b69ada3ed 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Product/ProductLayout.Simple.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Product/ProductLayout.Simple.cshtml@@ -7,14 +7,14 @@Layout = "_SingleColumn";//title, meta- pagebuilder.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);+ pagebuilder.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);//canonical URLif (seoSettings.CanonicalUrlsEnabled){- var productUrl = Url.RouteUrl("Product", new { Model.SeName }, this.Url.ActionContext.HttpContext.Request.Scheme);+ var productUrl = Url.RouteUrl("Product", new { Model.SeName }, Url.ActionContext.HttpContext.Request.Scheme);pagebuilder.AddCanonicalUrlParts(productUrl);}}@@ -22,30 +22,31 @@@section meta {@if (seoSettings.OpenGraphMetaTags){- <meta property=og:type content=product />- <meta property="og:title" content="@Html.Encode(Model.Name)" />- <meta property="og:description" content="@Html.Encode(Model.MetaDescription)" />- <meta property="og:image" content="@Model.DefaultPictureModel.ImageUrl" />- <meta property="og:image:url" content="@Model.DefaultPictureModel.ImageUrl" />- <meta property="og:url" content="@this.Url.ActionContext.HttpContext.Request.GetEncodedUrl()" />- <meta property="og:site_name" content="@Html.Encode(Model.CurrentStoreName)" />+ <meta property=og:type content=product/>+ <meta property="og:title" content="@Html.Encode(Model.Name)"/>+ <meta property="og:description" content="@Html.Encode(Model.MetaDescription)"/>+ <meta property="og:image" content="@Model.DefaultPictureModel.ImageUrl"/>+ <meta property="og:image:url" content="@Model.DefaultPictureModel.ImageUrl"/>+ <meta property="og:url" content="@Url.ActionContext.HttpContext.Request.GetEncodedUrl()"/>+ <meta property="og:site_name" content="@Html.Encode(Model.CurrentStoreName)"/>}@if (seoSettings.TwitterMetaTags){- <meta property="twitter:card" content="summary" />- <meta property="twitter:site" content="@Html.Encode(Model.CurrentStoreName)" />- <meta property="twitter:title" content="@Html.Encode(Model.Name)" />- <meta property="twitter:description" content="@Html.Encode(Model.MetaDescription)" />- <meta property="twitter:image" content="@Model.DefaultPictureModel.ImageUrl" />- <meta property="twitter:url" content="@this.Url.ActionContext.HttpContext.Request.GetEncodedUrl()" />+ <meta property="twitter:card" content="summary"/>+ <meta property="twitter:site" content="@Html.Encode(Model.CurrentStoreName)"/>+ <meta property="twitter:title" content="@Html.Encode(Model.Name)"/>+ <meta property="twitter:description" content="@Html.Encode(Model.MetaDescription)"/>+ <meta property="twitter:image" content="@Model.DefaultPictureModel.ImageUrl"/>+ <meta property="twitter:url" content="@Url.ActionContext.HttpContext.Request.GetEncodedUrl()"/>}}<!--product breadcrumb-->+@section Breadcrumb{- <partial name="Partials/Breadcrumbs" model="Model.Breadcrumb" />+ <partial name="Partials/Breadcrumbs" model="Model.Breadcrumb"/>}<vc:widget widget-zone="productdetails_after_breadcrumb" additional-data="@Model.Id"></vc:widget>@@ -57,20 +58,20 @@<b-row><vc:widget widget-zone="productdetails_before_pictures" additional-data="@Model.Id"></vc:widget><!--product pictures-->- <partial name="Partials/Pictures" model="Model" />+ <partial name="Partials/Pictures" model="Model"/><vc:widget widget-zone="productdetails_after_pictures" additional-data="@Model.Id"></vc:widget><b-col xl="5" lg="6" md="7" cols="12" class="overview pl-md-3 pl-0 pr-0">- <partial name="Partials/Unavailable" model="Model" />+ <partial name="Partials/Unavailable" model="Model"/><h1 class="generalTitle" itemprop="name">@Model.Name</h1><!--product reviews-->@if (Model.ProductReviewOverview.AllowCustomerReviews){- <partial name="Partials/ProductReviewOverview" model="Model.ProductReviewOverview" />+ <partial name="Partials/ProductReviewOverview" model="Model.ProductReviewOverview"/>}<vc:widget widget-zone="productdetails_overview_top" additional-data="@Model.Id"></vc:widget>- @if (!String.IsNullOrEmpty(Model.ShortDescription))+ @if (!string.IsNullOrEmpty(Model.ShortDescription)){<div class="short-description generalMarginSupporter">@Html.Raw(Model.ShortDescription)@@ -79,40 +80,40 @@<!--collections-->@if (Model.ProductCollections.Any()){- <partial name="Partials/Collections" model="Model.ProductCollections" />+ <partial name="Partials/Collections" model="Model.ProductCollections"/>}<!--availability-->- @if (!String.IsNullOrWhiteSpace(Model.StockAvailability) || Model.DisplayOutOfStockSubscription)+ @if (!string.IsNullOrWhiteSpace(Model.StockAvailability) || Model.DisplayOutOfStockSubscription){- <partial name="Partials/Availability" model="Model" />+ <partial name="Partials/Availability" model="Model"/>}<!--Code products - SKU, MAN, GTIN, Vendor info -->- <partial name="Partials/Codes" model="Model" />+ <partial name="Partials/Codes" model="Model"/><!--delivery-->@if ((Model.FreeShippingNotificationEnabled && Model.IsFreeShipping) || !string.IsNullOrWhiteSpace(Model.DeliveryDate)- || Model.NotReturnable || Model.AdditionalShippingCharge > 0)+ || Model.NotReturnable || Model.AdditionalShippingCharge > 0){- <partial name="Partials/DeliveryInfo" model="Model" />+ <partial name="Partials/DeliveryInfo" model="Model"/>}<!--sample download-->@if (Model.HasSampleDownload){- <partial name="Partials/DownloadSample" model="Model" />+ <partial name="Partials/DownloadSample" model="Model"/>}<!--product bundles-->@if (Model.ProductBundleModels.Any()){- <partial name="Partials/ProductBundles" model="Model" />+ <partial name="Partials/ProductBundles" model="Model"/>}<!--attributes-->@if (Model.ProductAttributes.Any()){- <partial name="Partials/ProductAttributes" model="Model" />- }+ <partial name="Partials/ProductAttributes" model="Model"/>+ }<!--warehouses-->@if (Model.AllowToSelectWarehouse){- <partial name="Partials/Warehouses" model="Model" />+ <partial name="Partials/Warehouses" model="Model"/>}<!--gift voucher-->@{@@ -131,14 +132,14 @@HtmlFieldPrefix = $"reservation_{Model.Id}"}};- <partial name="Partials/ReservationInfo" model="Model" view-data="dataDictReservation" />+ <partial name="Partials/ReservationInfo" model="Model" view-data="dataDictReservation"/>}<!--price & add to cart--><div class="overview-buttons generalMarginSupporter">@if (Model.TierPrices.Any()){<div class="col-lg-12 px-0">- <partial name="Partials/TierPrices" model="Model.TierPrices" />+ <partial name="Partials/TierPrices" model="Model.TierPrices"/></div>}<div class="col-lg-12 px-0">@@ -150,7 +151,7 @@HtmlFieldPrefix = $"price_{Model.Id}"}};- <partial name="Partials/Prices" model="Model.ProductPrice" view-data="dataDictPrice" />+ <partial name="Partials/Prices" model="Model.ProductPrice" view-data="dataDictPrice"/>}</div><div class="generalMarginSupporter">@@ -164,7 +165,7 @@HtmlFieldPrefix = $"auction_{Model.Id}"}};- <partial name="Partials/AuctionInfo" model="Model" view-data="dataDictAuction" />+ <partial name="Partials/AuctionInfo" model="Model" view-data="dataDictAuction"/>}@{var dataDictAddToWishlist = new ViewDataDictionary(ViewData)@@ -182,24 +183,24 @@}};}- <partial name="Partials/AddToCart" model="Model.AddToCart" view-data="dataDictAddToCart" />+ <partial name="Partials/AddToCart" model="Model.AddToCart" view-data="dataDictAddToCart"/><b-btn-group class="mt-2 mb-3 w-100 flex-wrap">@if (Model.ProductType == ProductType.SimpleProduct || Model.ProductType == ProductType.BundledProduct){- <partial name="Partials/AddToWishlist" model="Model.AddToCart" view-data="dataDictAddToWishlist" />- <partial name="Partials/ProductsComparison" model="Model" />+ <partial name="Partials/AddToWishlist" model="Model.AddToCart" view-data="dataDictAddToWishlist"/>+ <partial name="Partials/ProductsComparison" model="Model"/>}@if (Model.EmailAFriendEnabled){- <partial name="Partials/SendFriend" model="Model" />+ <partial name="Partials/SendFriend" model="Model"/>}</b-btn-group></div></div>- @if (!String.IsNullOrWhiteSpace(Model.PageShareCode))+ @if (!string.IsNullOrWhiteSpace(Model.PageShareCode)){<div class="col-12 product-share px-0">- <partial name="Partials/ShareButton" model="Model" />+ <partial name="Partials/ShareButton" model="Model"/></div>}<vc:widget widget-zone="productdetails_overview_bottom" additional-data="@Model.Id"></vc:widget>@@ -216,13 +217,13 @@@if (Model.ProductTags.Any()){<b-tab title="@Loc["Products.Tags"]">- <partial name="Partials/ProductTags" model="Model.ProductTags" />+ <partial name="Partials/ProductTags" model="Model.ProductTags"/></b-tab>}@if (Model.ProductSpecifications.Any()){<b-tab title="@Loc["Products.Specs"]">- <partial name="Partials/ProductSpecifications" model="Model.ProductSpecifications" />+ <partial name="Partials/ProductSpecifications" model="Model.ProductSpecifications"/></b-tab>}@if (Model.ProductReviewOverview.AllowCustomerReviews)@@ -234,7 +235,7 @@@if (Model.AskQuestionOnProduct){<b-tab title="@Loc["Products.ContactUs"]">- <partial name="Partials/AskQuestionOnProduct" model="Model.ProductAskQuestion" />+ <partial name="Partials/AskQuestionOnProduct" model="Model.ProductAskQuestion"/></b-tab>}</b-tabs>@@ -248,7 +249,7 @@</validation-observer>@if (Model.EmailAFriendEnabled){- @await Component.InvokeAsync("ProductEmailAFriend", new { productId = Model.Id })+ @await Component.InvokeAsync("ProductEmailAFriend", new { productId = Model.Id })}<vc:widget widget-zone="productdetails_bottom" additional-data="@Model.Id"></vc:widget></div>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Product/RecentlyViewedProducts.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Product/RecentlyViewedProducts.cshtmlindex 50edde1e5..09994f294 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Product/RecentlyViewedProducts.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Product/RecentlyViewedProducts.cshtml@@ -7,7 +7,9 @@pagebuilder.AddTitleParts(Loc["Title.RecentlyViewedProducts"]);}<b-col cols="12" class="page recently-viewed-products-page px-0">- <h1 class="generalTitle h2 text-center"><div>@Loc["Products.RecentlyViewedProducts"]</div></h1>+ <h1 class="generalTitle h2 text-center">+ <div>@Loc["Products.RecentlyViewedProducts"]</div>+ </h1><div class="d-inline-flex align-items-center"><a class="left-side-toggler mx-0 mb-3" onclick="sideToggle()"><div class="inner">@@ -26,7 +28,7 @@@foreach (var product in Model){<b-col xl="3" lg="3" sm="6" cols="6" class="col-for-5-xl new-col-6 product-container mb-2">- <partial name="Partials/CatalogProductView" model="product" />+ <partial name="Partials/CatalogProductView" model="product"/></b-col>}</div>diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/BlogPostProducts/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/BlogPostProducts/Default.cshtmlindex 1d6e0e7f0..bceb66810 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/BlogPostProducts/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/BlogPostProducts/Default.cshtml@@ -1,15 +1,15 @@@model IList<ProductOverviewModel>- <div class="product-grid blogpost-product-grid col-12 px-0">- <h2 class="h3 generalTitle text-center">- @Loc["Blog.Products"]- </h2>- <div class=" form-row flex-grid">- @foreach (var product in Model)- {- <div class="col-lg-3 col-md-4 col-sm-6 col-6 mb-2">- <partial name="Partials/CatalogProductView" model="product" />- </div>- }- </div>+<div class="product-grid blogpost-product-grid col-12 px-0">+ <h2 class="h3 generalTitle text-center">+ @Loc["Blog.Products"]+ </h2>+ <div class=" form-row flex-grid">+ @foreach (var product in Model)+ {+ <div class="col-lg-3 col-md-4 col-sm-6 col-6 mb-2">+ <partial name="Partials/CatalogProductView" model="product"/>+ </div>+ }</div>+</div>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/CustomerNavigation/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/CustomerNavigation/Default.cshtmlindex 595f4a187..6b850d665 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/CustomerNavigation/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/CustomerNavigation/Default.cshtml@@ -3,144 +3,131 @@<link rel="stylesheet" type="text/css" asp-src="/Plugins/Theme.Modern/Content/css/customer/customer.css">}<div id="block-account-navigation" class="block block-account-navigation mt-2">- <h2 class="h5"><strong>@Loc["Account.Navigation"]</strong></h2>+ <h2 class="h5">+ <strong>@Loc["Account.Navigation"]</strong>+ </h2><ul class="list viewBox">@await Component.InvokeAsync("Widget", new { widgetZone = "account_navigation_before" })@if (!Model.HideInfo){<li class="customer-info">- <a href="@Url.RouteUrl("CustomerInfo")" class="@if (Model.SelectedTab == AccountNavigationEnum.Info)- {<text>active</text>}- else- {<text>inactive</text>}"><b-icon icon="person"></b-icon> <span>@Loc["Account.CustomerInfo"]</span></a>- </li>- }+ <a href="@Url.RouteUrl("CustomerInfo")" class="@if (Model.SelectedTab == AccountNavigationEnum.Info) { <text>active</text> }else { <text>inactive</text> }">+ <b-icon icon="person"></b-icon> <span>@Loc["Account.CustomerInfo"]</span>+ </a>+ </li>+ }@if (!Model.HideAddresses){<li class="customer-addresses">- <a href="@Url.RouteUrl("CustomerAddresses")" class="@if (Model.SelectedTab == AccountNavigationEnum.Addresses)- {<text>active</text>}- else- {<text>inactive</text>}"><b-icon icon="file-earmark-richtext"></b-icon> <span>@Loc["Account.CustomerAddresses"]</span></a>- </li>- }+ <a href="@Url.RouteUrl("CustomerAddresses")" class="@if (Model.SelectedTab == AccountNavigationEnum.Addresses) { <text>active</text> }else { <text>inactive</text> }">+ <b-icon icon="file-earmark-richtext"></b-icon> <span>@Loc["Account.CustomerAddresses"]</span>+ </a>+ </li>+ }@if (!Model.HideOrders){<li class="customer-orders">- <a href="@Url.RouteUrl("CustomerOrders")" class="@if (Model.SelectedTab == AccountNavigationEnum.Orders)- {<text>active</text>}- else- {<text>inactive</text>}"><b-icon icon="cart-check"></b-icon> <span>@Loc["Account.CustomerOrders"]</span></a>- </li>- }+ <a href="@Url.RouteUrl("CustomerOrders")" class="@if (Model.SelectedTab == AccountNavigationEnum.Orders) { <text>active</text> }else { <text>inactive</text> }">+ <b-icon icon="cart-check"></b-icon> <span>@Loc["Account.CustomerOrders"]</span>+ </a>+ </li>+ }@if (!Model.HideCourses){<li class="customer-auctions">- <a href="@Url.RouteUrl("CustomerCourses")" class="@if (Model.SelectedTab == AccountNavigationEnum.Courses)- {<text>active</text>}- else- {<text>inactive</text>}"><b-icon icon="file-earmark-easel"></b-icon> <span>@Loc["Account.CustomerCourses"]</span></a>- </li>- }+ <a href="@Url.RouteUrl("CustomerCourses")" class="@if (Model.SelectedTab == AccountNavigationEnum.Courses) { <text>active</text> }else { <text>inactive</text> }">+ <b-icon icon="file-earmark-easel"></b-icon> <span>@Loc["Account.CustomerCourses"]</span>+ </a>+ </li>+ }@if (!Model.HideAuctions){<li class="customer-auctions">- <a href="@Url.RouteUrl("CustomerAuctions")" class="@if (Model.SelectedTab == AccountNavigationEnum.Auctions)- {<text>active</text>}- else- {<text>inactive</text>}"><b-icon icon="hammer"></b-icon> <span>@Loc["Account.CustomerAuctions"]</span></a>- </li>- }+ <a href="@Url.RouteUrl("CustomerAuctions")" class="@if (Model.SelectedTab == AccountNavigationEnum.Auctions) { <text>active</text> }else { <text>inactive</text> }">+ <b-icon icon="hammer"></b-icon> <span>@Loc["Account.CustomerAuctions"]</span>+ </a>+ </li>+ }@if (!Model.HideNotes){<li class="customer-notes">- <a href="@Url.RouteUrl("CustomerNotes")" class="@if (Model.SelectedTab == AccountNavigationEnum.Notes)- {<text>active</text>}- else- {<text>inactive</text>}"><b-icon icon="file-earmark-font"></b-icon> <span>@Loc["Account.CustomerNotes"]</span></a>- </li>- }+ <a href="@Url.RouteUrl("CustomerNotes")" class="@if (Model.SelectedTab == AccountNavigationEnum.Notes) { <text>active</text> }else { <text>inactive</text> }">+ <b-icon icon="file-earmark-font"></b-icon> <span>@Loc["Account.CustomerNotes"]</span>+ </a>+ </li>+ }@if (!Model.HideDocuments){<li class="customer-notes">- <a href="@Url.RouteUrl("CustomerDocuments")" class="@if (Model.SelectedTab == AccountNavigationEnum.Documents)- {<text>active</text>}- else- {<text>inactive</text>}"><b-icon icon="file-earmark-check"></b-icon> <span>@Loc["Account.CustomerDocuments"]</span></a>- </li>- }+ <a href="@Url.RouteUrl("CustomerDocuments")" class="@if (Model.SelectedTab == AccountNavigationEnum.Documents) { <text>active</text> }else { <text>inactive</text> }">+ <b-icon icon="file-earmark-check"></b-icon> <span>@Loc["Account.CustomerDocuments"]</span>+ </a>+ </li>+ }@if (!Model.HideMerchandiseReturns){<li class="customer-returns">- <a href="@Url.RouteUrl("CustomerMerchandiseReturns")" class="@if (Model.SelectedTab == AccountNavigationEnum.MerchandiseReturns)- {<text>active</text>}- else- {<text>inactive</text>}"><b-icon icon="arrow-return-left"></b-icon> <span>@Loc["Account.CustomerMerchandiseReturns"]</span></a>- </li>- }+ <a href="@Url.RouteUrl("CustomerMerchandiseReturns")" class="@if (Model.SelectedTab == AccountNavigationEnum.MerchandiseReturns) { <text>active</text> }else { <text>inactive</text> }">+ <b-icon icon="arrow-return-left"></b-icon> <span>@Loc["Account.CustomerMerchandiseReturns"]</span>+ </a>+ </li>+ }@if (!Model.HideDownloadableProducts){<li class="customer-downloadable">- <a href="@Url.RouteUrl("CustomerDownloadableProducts")" class="@if (Model.SelectedTab == AccountNavigationEnum.DownloadableProducts)- {<text>active</text>}- else- {<text>inactive</text>}"><b-icon icon="cloud-download"></b-icon> <span>@Loc["Account.DownloadableProducts"]</span></a>- </li>- }+ <a href="@Url.RouteUrl("CustomerDownloadableProducts")" class="@if (Model.SelectedTab == AccountNavigationEnum.DownloadableProducts) { <text>active</text> }else { <text>inactive</text> }">+ <b-icon icon="cloud-download"></b-icon> <span>@Loc["Account.DownloadableProducts"]</span>+ </a>+ </li>+ }@if (!Model.HideOutOfStockSubscriptions){<li class="customer-back">- <a href="@Url.RouteUrl("CustomerOutOfStockSubscriptions")" class="@if (Model.SelectedTab == AccountNavigationEnum.OutOfStockSubscriptions)- {<text>active</text>}- else- {<text>inactive</text>}"><b-icon icon="skip-backward"></b-icon> <span>@Loc["Account.OutOfStockSubscriptions"]</span></a>- </li>- }+ <a href="@Url.RouteUrl("CustomerOutOfStockSubscriptions")" class="@if (Model.SelectedTab == AccountNavigationEnum.OutOfStockSubscriptions) { <text>active</text> }else { <text>inactive</text> }">+ <b-icon icon="skip-backward"></b-icon> <span>@Loc["Account.OutOfStockSubscriptions"]</span>+ </a>+ </li>+ }@if (!Model.HideLoyaltyPoints){<li class="loyalty-points">- <a href="@Url.RouteUrl("CustomerLoyaltyPoints")" class="@if (Model.SelectedTab == AccountNavigationEnum.LoyaltyPoints)- {<text>active</text>}- else- {<text>inactive</text>}"><b-icon icon="trophy"></b-icon> <span>@Loc["Account.LoyaltyPoints"]</span></a>- </li>- }+ <a href="@Url.RouteUrl("CustomerLoyaltyPoints")" class="@if (Model.SelectedTab == AccountNavigationEnum.LoyaltyPoints) { <text>active</text> }else { <text>inactive</text> }">+ <b-icon icon="trophy"></b-icon> <span>@Loc["Account.LoyaltyPoints"]</span>+ </a>+ </li>+ }@if (!Model.HideChangePassword){<li class="change-password">- <a href="@Url.RouteUrl("CustomerChangePassword")" class="@if (Model.SelectedTab == AccountNavigationEnum.ChangePassword)- {<text>active</text>}- else- {<text>inactive</text>}"><b-icon icon="file-earmark-lock2"></b-icon> <span>@Loc["Account.ChangePassword"]</span></a>- </li>- }+ <a href="@Url.RouteUrl("CustomerChangePassword")" class="@if (Model.SelectedTab == AccountNavigationEnum.ChangePassword) { <text>active</text> }else { <text>inactive</text> }">+ <b-icon icon="file-earmark-lock2"></b-icon> <span>@Loc["Account.ChangePassword"]</span>+ </a>+ </li>+ }@if (!Model.HideDeleteAccount){<li class="customer-delete">- <a href="@Url.RouteUrl("CustomerDeleteAccount")" class="@if (Model.SelectedTab == AccountNavigationEnum.DeleteAccount)- {<text>active</text>}- else- {<text>inactive</text>}"><b-icon icon="trash"></b-icon> <span>@Loc["Account.DeleteAccount"]</span></a>- </li>- }+ <a href="@Url.RouteUrl("CustomerDeleteAccount")" class="@if (Model.SelectedTab == AccountNavigationEnum.DeleteAccount) { <text>active</text> }else { <text>inactive</text> }">+ <b-icon icon="trash"></b-icon> <span>@Loc["Account.DeleteAccount"]</span>+ </a>+ </li>+ }@if (!Model.HideReviews){<li class="customer-notes">- <a href="@Url.RouteUrl("CustomerReviews")" class="@if(Model.SelectedTab == AccountNavigationEnum.Reviews)- {<text>active</text>}- else- {<text>inactive</text>}"><b-icon icon="star"></b-icon> <span>@Loc["Account.Reviews"]</span></a>- </li>- }+ <a href="@Url.RouteUrl("CustomerReviews")" class="@if (Model.SelectedTab == AccountNavigationEnum.Reviews) { <text>active</text> }else { <text>inactive</text> }">+ <b-icon icon="star"></b-icon> <span>@Loc["Account.Reviews"]</span>+ </a>+ </li>+ }@if (!Model.HideSubAccounts){<li class="customer-subaccounts">- <a href="@Url.RouteUrl("CustomerSubAccounts")" class="@if(Model.SelectedTab == AccountNavigationEnum.SubAccounts)- {<text>active</text>}- else- {<text>inactive</text>}"><b-icon icon="person-plus"></b-icon> <span>@Loc["Account.SubAccounts"]</span></a>- </li>- }+ <a href="@Url.RouteUrl("CustomerSubAccounts")" class="@if (Model.SelectedTab == AccountNavigationEnum.SubAccounts) { <text>active</text> }else { <text>inactive</text> }">+ <b-icon icon="person-plus"></b-icon> <span>@Loc["Account.SubAccounts"]</span>+ </a>+ </li>+ }@await Component.InvokeAsync("Widget", new { widgetZone = "account_navigation_after", additionalData = Model })</ul>-</div>+</div>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/CustomerRecommendedProducts/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/CustomerRecommendedProducts/Default.cshtmlindex 900efc13c..89572cfdc 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/CustomerRecommendedProducts/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/CustomerRecommendedProducts/Default.cshtml@@ -3,7 +3,9 @@<div class="home-page-section"><div id="CustomerRecommendedProducts" class="section"><div class="product-grid">- <h2 class="generalTitle text-center"><span>@Loc["HomePage.Recommended.Products"]</span></h2>+ <h2 class="generalTitle text-center">+ <span>@Loc["HomePage.Recommended.Products"]</span>+ </h2><div class="col-12 px-0"><div class="item-row"><div :key="Model.Id" v-for="Model in homePRecommended.Model" class="col-xl-3 col-lg-4 col-md-4 col-sm-6 col-6 col-for-5-xl product-container mb-2">diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/Footer/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/Footer/Default.cshtmlindex ee937cb52..a97f38ff7 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/Footer/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/Footer/Default.cshtml@@ -62,7 +62,7 @@</li>}</ul>- <partial name="Partials/NewsletterBox" />+ <partial name="Partials/NewsletterBox"/><h6 class="title">@Loc["Footer.AboutUs"]</h6><ul class="info"><li>@@ -194,4 +194,4 @@</b-container></div>@await Component.InvokeAsync("Widget", new { widgetZone = "footer" })-</footer>+</footer>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/HomePageBestSellers/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/HomePageBestSellers/Default.cshtmlindex 64ba1b013..ca74a5f03 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/HomePageBestSellers/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/HomePageBestSellers/Default.cshtml@@ -3,7 +3,9 @@<div class="home-page-section"><div id="HomePageBestSellers" class="section"><div class="product-grid">- <h2 class="generalTitle text-center"><span>@Loc["Bestsellers"]</span></h2>+ <h2 class="generalTitle text-center">+ <span>@Loc["Bestsellers"]</span>+ </h2><div class="col-12 px-0"><div class="item-row"><div :key="Model.Id" v-for="Model in homePBest.Model" class="col-xl-3 col-lg-3 col-md-3 col-sm-6 col-6 product-container mb-2">diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/HomePageBlog/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/HomePageBlog/Default.cshtmlindex 1c3c03fea..f48722dd1 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/HomePageBlog/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/HomePageBlog/Default.cshtml@@ -3,7 +3,9 @@<div id="HomePageBlog" class="home-page-section"><div class="section"><div class="col-12">- <h2 class="generalTitle text-center"><span>@Loc["Blog.Latest"]</span></h2>+ <h2 class="generalTitle text-center">+ <span>@Loc["Blog.Latest"]</span>+ </h2><div class="col-12 px-0"><div class="row"><template :key="Item.Id" v-for="Item in homePBlog.Model.Items">diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/HomePageNewProducts/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/HomePageNewProducts/Default.cshtmlindex d4b950c22..cb4dca036 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/HomePageNewProducts/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/HomePageNewProducts/Default.cshtml@@ -12,7 +12,7 @@<div class="swiper-scrollbar" slot="scrollbar"></div></swiper></div>-<partial name="Partials/ProductBoxSlideVue" />+<partial name="Partials/ProductBoxSlideVue"/><script asp-location="Footer" asp-order="118" type="module">Vue.component('product-box-slide-vue', {template: '#product-box-slide-vue',@@ -113,4 +113,4 @@}}});-</script>+</script>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/HomePageNews/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/HomePageNews/Default.cshtmlindex c461f8b76..b9dc2162b 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/HomePageNews/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/HomePageNews/Default.cshtml@@ -3,14 +3,16 @@<div class="home-page-section"><div id="HomePageNews" class="section mb-3"><div class="product-grid">- <h2 class="generalTitle text-center"><span>@Loc["News"]</span></h2>+ <h2 class="generalTitle text-center">+ <span>@Loc["News"]</span>+ </h2><div class="col-12 px-0"><div class="row"><div class="col-xl-4 col-lg-4 col-md-6 col-sm-6 col-12 post-container mb-2" :key="Item.Id" v-for="Item in homePNews.Model.NewsItems"><div class="card post-news"><div class="card-header"><a class="img-container" v-if="Item.PictureModel.ImageUrl !== null">- <b-img-lazy width="300" height="300" :src="Item.PictureModel.ImageUrl" :alt="Item.PictureModel.AlternateText" />+ <b-img-lazy width="300" height="300" :src="Item.PictureModel.ImageUrl" :alt="Item.PictureModel.AlternateText"/></a><h3 class="h5 title"><a :href="'/' + Item.SeName">diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/HomePageProducts/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/HomePageProducts/Default.cshtmlindex b3fceae29..a168855ee 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/HomePageProducts/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/HomePageProducts/Default.cshtml@@ -3,7 +3,9 @@<div class="home-page-section"><div id="HomePageProducts" class="section"><div class="product-grid">- <h2 class="generalTitle text-center"><span>@Loc["HomePage.Products"]</span></h2>+ <h2 class="generalTitle text-center">+ <span>@Loc["HomePage.Products"]</span>+ </h2><div class="col-12 px-0"><div class="item-row"><div :key="Model.Id" v-for="Model in homePProducts.Model" class="col-xl-3 col-lg-3 col-md-3 col-sm-6 col-6 product-container mb-2">diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/Menu/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/Menu/Default.cshtmlindex 99e76ad5e..48341c9c2 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/Menu/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/Menu/Default.cshtml@@ -9,11 +9,10 @@{Category = category};- <partial name="Partials/CategoryLine.Menu" model="categoryLineModel" />+ <partial name="Partials/CategoryLine.Menu" model="categoryLineModel"/>}@if (Model.Brands.Any()){-<li class="category -hasSubmenu" text="@Loc["Brands.Menu"]"><a href="@Url.RouteUrl("BrandList")"><span class="title">@Loc["Brands.Menu"]</span>@@ -124,11 +123,11 @@}</ul></li>- }- @await Component.InvokeAsync("Widget", new { widgetZone = "header_menu_after" })+}+@await Component.InvokeAsync("Widget", new { widgetZone = "header_menu_after" })- @{- var rootCategoriesResponsive = Model.Categories.ToList();- //name it "Categories" if we have only categories. Otherwise, "Menu"- var responsiveMenuTitle = rootCategoriesResponsive.Any() && Model.Pages.Any() ? Loc["Categories"] : Loc["Menu"];- }+@{+ var rootCategoriesResponsive = Model.Categories.ToList();+ //name it "Categories" if we have only categories. Otherwise, "Menu"+ var responsiveMenuTitle = rootCategoriesResponsive.Any() && Model.Pages.Any() ? Loc["Categories"] : Loc["Menu"];+}\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/PageBlock/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/PageBlock/Default.cshtmlindex 606e48f13..89565eab8 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/PageBlock/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/PageBlock/Default.cshtml@@ -41,7 +41,7 @@</script><div class="page-password" id="[email protected]"><form asp-route="PageAuthenticate" method="post">- <input asp-for="Id" type="hidden" />+ <input asp-for="Id" type="hidden"/><div class="enter-password-title">@Loc["Page.EnterPassword"]</div>@@ -69,9 +69,10 @@}else{- @if (!String.IsNullOrEmpty(Model.Title))+ @if (!string.IsNullOrEmpty(Model.Title)){<h1 class="generalTitle h2 text-sm-center">@Model.Title</h1>}+@Html.Raw(Model.Body)}\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/PersonalizedProducts/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/PersonalizedProducts/Default.cshtmlindex a4db1e930..b091a7f11 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/PersonalizedProducts/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/PersonalizedProducts/Default.cshtml@@ -3,7 +3,9 @@<div class="home-page-section"><div id="PersonalizedProducts" class="section"><div class="product-grid">- <h2 class="generalTitle text-center"><span>@Loc["HomePage.Personalized.Products"]</span></h2>+ <h2 class="generalTitle text-center">+ <span>@Loc["HomePage.Personalized.Products"]</span>+ </h2><div class="col-12 px-0"><div class="item-row"><div :key="Model.Id" v-for="Model in homePPersonalized.Model" class="col-xl-3 col-lg-4 col-md-4 col-sm-6 col-6 col-for-5-xl product-container mb-2">diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/ProductsAlsoPurchased/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/ProductsAlsoPurchased/Default.cshtmlindex 2bf7a34fb..2b1ed4abc 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/ProductsAlsoPurchased/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/ProductsAlsoPurchased/Default.cshtml@@ -2,15 +2,16 @@@if (Model.Any()){<b-col cols="12" class="also-purchased-products-grid product-grid my-3 px-0">- <h2 class="h3 generalTitle mb-3"><span>@Loc["Products.AlsoPurchased"]</span></h2>+ <h2 class="h3 generalTitle mb-3">+ <span>@Loc["Products.AlsoPurchased"]</span>+ </h2><b-form-row>@foreach (var item in Model){- <b-col xl="3" lg="4" md="4" sm="6" cols="6" class="product-container col-for-5-xl px-0 mb-2">- <partial name="Partials/CatalogProductView" model="item" />+ <b-col xl="3" lg="4" md="4" sm="6" cols="6" class="product-container col-for-5-xl px-0 mb-2">+ <partial name="Partials/CatalogProductView" model="item"/></b-col>}</b-form-row></b-col>-}-+}\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/RecentlyViewedProductsBlock/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/RecentlyViewedProductsBlock/Default.cshtmlindex c97b45f71..1698cd8ec 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/RecentlyViewedProductsBlock/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/RecentlyViewedProductsBlock/Default.cshtml@@ -1,25 +1,29 @@@model IList<ProductOverviewModel>@if (Model.Any()){-<div id="block-recently-viewed-products" class="block block-recently-viewed-products">- <h2 class="generalTitle"><span>@Loc["Products.RecentlyViewedProducts"]</span></h2>- <div class="col-12 px-0">- <div class="form-row">- @for (int i = 0; i < Model.Count; i++)- {- var product = Model[i];- <div class="col-xl-3 col-lg-3 col-md-3 col-sm-4 col-6 mb-2 col-for-5-xl">- <div class="card">- <a class="text-center picture" href="@Url.RouteUrl("Product", new { product.SeName })">- <b-img-lazy class="img-fluid" alt="@product.DefaultPictureModel.AlternateText" src="@product.DefaultPictureModel.ImageUrl" title="@product.DefaultPictureModel.Title"></b-img-lazy>- </a>- <div class="card-body">- <h5 class="h6"><a href="@Url.RouteUrl("Product", new { product.SeName })">@product.Name</a></h5>+ <div id="block-recently-viewed-products" class="block block-recently-viewed-products">+ <h2 class="generalTitle">+ <span>@Loc["Products.RecentlyViewedProducts"]</span>+ </h2>+ <div class="col-12 px-0">+ <div class="form-row">+ @for (var i = 0; i < Model.Count; i++)+ {+ var product = Model[i];+ <div class="col-xl-3 col-lg-3 col-md-3 col-sm-4 col-6 mb-2 col-for-5-xl">+ <div class="card">+ <a class="text-center picture" href="@Url.RouteUrl("Product", new { product.SeName })">+ <b-img-lazy class="img-fluid" alt="@product.DefaultPictureModel.AlternateText" src="@product.DefaultPictureModel.ImageUrl" title="@product.DefaultPictureModel.Title"></b-img-lazy>+ </a>+ <div class="card-body">+ <h5 class="h6">+ <a href="@Url.RouteUrl("Product", new { product.SeName })">@product.Name</a>+ </h5>+ </div></div></div>- </div>- }+ }+ </div></div></div>-</div>}\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/RecommendedProducts/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/RecommendedProducts/Default.cshtmlindex c7412b376..039049661 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/RecommendedProducts/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/RecommendedProducts/Default.cshtml@@ -7,10 +7,9 @@@foreach (var item in Model){<b-col xl="3" lg="4" md="4" sm="6" class="product-container mb-2">- <partial name="Partials/CatalogProductView" model="item" />+ <partial name="Partials/CatalogProductView" model="item"/></b-col>}</b-form-row></b-col>-}-+}\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/RelatedProducts/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/RelatedProducts/Default.cshtmlindex 9d59aacf1..96010059b 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/RelatedProducts/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/RelatedProducts/Default.cshtml@@ -2,15 +2,16 @@@if (Model.Any()){<b-col cols="12" class="related-products-grid product-grid my-3 px-0">- <h2 class="h3 generalTitle mb-3"><span>@Loc["Products.RelatedProducts"]</span></h2>+ <h2 class="h3 generalTitle mb-3">+ <span>@Loc["Products.RelatedProducts"]</span>+ </h2><b-form-row>@foreach (var item in Model){<b-col xl="3" lg="4" md="4" sm="3" cols="6" class="product-container px-0 mb-2">- <partial name="Partials/CatalogProductView" model="item" />+ <partial name="Partials/CatalogProductView" model="item"/></b-col>}</b-form-row></b-col>-}-+}\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/SearchBox/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/SearchBox/Default.cshtmlindex 55e6bfad7..15a4a221f 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/SearchBox/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/SearchBox/Default.cshtml@@ -1,5 +1,6 @@-@model SearchBoxModel-@inject Grand.Domain.Blogs.BlogSettings blogSettings+@using Grand.Domain.Blogs+@model SearchBoxModel+@inject BlogSettings blogSettings@inject IWorkContext workContext@{var lang = workContext.WorkingLanguage.LanguageCulture;@@ -10,12 +11,17 @@<validation-observer v-slot="{ handleSubmit }"><form asp-route="ProductSearch" method="get" id="small-search-box-form" ref="searchForm" v-on:submit.prevent="handleSubmit(searchbox.formSubmit)" class="searchBox w-100"><validation-provider tag="div" rules="required|min:@(Model.SearchTermMinimumLength)" name="q" v-slot="{ errors, classes }">- <input type="hidden" asp-for="Box" value="true" />+ <input type="hidden" asp-for="Box" value="true"/><label for="small-searchterms" class="sr-only">@Loc["Search.SearchBox.Tooltip"]</label><div class="input-group flex-row">- <input minlength="@(Model.SearchTermMinimumLength)" maxlength="20"- data-val-required="@string.Format(Loc["search.searchtermminimumlengthisncharacters"], Model.SearchTermMinimumLength)"- data-val-min="@string.Format(Loc["search.searchtermminimumlengthisncharacters"], Model.SearchTermMinimumLength)" @if (Model.AutoCompleteEnabled) { <text> @@input="searchbox.autocompleteVue()" </text> } v-model="searchbox.text" type="search" name="q" ref="searchBoxInput" class="form-control search-box-text" id="small-searchterms" :placeholder="searchbox.placeholder">+ <input minlength="@(Model.SearchTermMinimumLength)" maxlength="20"+ data-val-required="@string.Format(Loc["search.searchtermminimumlengthisncharacters"], Model.SearchTermMinimumLength)"+ data-val-min="@string.Format(Loc["search.searchtermminimumlengthisncharacters"], Model.SearchTermMinimumLength)"+ @if (Model.AutoCompleteEnabled)+ {+ <text> @@input="searchbox.autocompleteVue()" </text>+ }+ v-model="searchbox.text" type="search" name="q" ref="searchBoxInput" class="form-control search-box-text" id="small-searchterms" :placeholder="searchbox.placeholder">@if (Model.AvailableCategories.Any()){@@ -59,7 +65,9 @@<div v-if="searchbox.searchcategories.length"><ul class="list px-0"><li v-for="item in searchbox.searchcategories">- <h6 class="mb-0"><a :href="item.Url">{{item.Label}}</a></h6>+ <h6 class="mb-0">+ <a :href="item.Url">{{item.Label}}</a>+ </h6><p v-if="item.Desc">{{item.Desc}}</p></li></ul>@@ -71,7 +79,9 @@<div v-if="searchbox.searchbrands.length"><ul class="list px-0"><li v-for="item in searchbox.searchbrands">- <h6 class="mb-0"><a :href="item.Url">{{item.Label}}</a></h6>+ <h6 class="mb-0">+ <a :href="item.Url">{{item.Label}}</a>+ </h6><p v-if="item.Desc">{{item.Desc}}</p></li></ul>@@ -85,7 +95,9 @@<div v-if="searchbox.searchblog.length"><ul class="list px-0"><li v-for="item in searchbox.searchblog">- <h6 class="mb-0"><a :href="item.Url">{{item.Label}}</a></h6>+ <h6 class="mb-0">+ <a :href="item.Url">{{item.Label}}</a>+ </h6><p v-if="item.Desc">{{item.Desc}}</p></li></ul>@@ -101,10 +113,12 @@<ul class="list px-0"><li class="media" v-for="item in searchbox.searchproducts"><div class="media-aside" v-if="item.PictureUrl">- <img class="img-fluid" alt="placeholder" :src="item.PictureUrl" />+ <img class="img-fluid" alt="placeholder" :src="item.PictureUrl"/></div><div class="media-body">- <h6 class="mb-0"><a :href="item.Url">{{item.Label}}</a></h6>+ <h6 class="mb-0">+ <a :href="item.Url">{{item.Label}}</a>+ </h6><b-form-rating class="p-0" variant="warning" no-border size="sm" show-value precision="2" readonly inline :value="item.Rating / 20"></b-form-rating><div v-if="item.Price" class="price">{{item.Price}}</div><p v-html="item.Desc" class="mt-1 mb-0"></p>diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/SimilarProducts/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/SimilarProducts/Default.cshtmlindex e61774b9d..7a46455ee 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/SimilarProducts/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/SimilarProducts/Default.cshtml@@ -7,9 +7,9 @@@foreach (var item in Model){<b-col xl="3" lg="4" md="4" sm="6" cols="6" class="product-container col-for-5-xl px-0 mb-2">- <partial name="Partials/CatalogProductView" model="item" />+ <partial name="Partials/CatalogProductView" model="item"/></b-col>}</b-form-row></b-col>-}+}\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/SuggestedProducts/Default.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/SuggestedProducts/Default.cshtmlindex b18a4e83e..b30948cba 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/SuggestedProducts/Default.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Components/SuggestedProducts/Default.cshtml@@ -3,7 +3,9 @@<div class="home-page-section"><div id="SuggestedProducts" class="section"><div class="product-grid">- <h2 class="generalTitle text-center"><span>@Loc["HomePage.Suggested.Products"]</span></h2>+ <h2 class="generalTitle text-center">+ <span>@Loc["HomePage.Suggested.Products"]</span>+ </h2><div class="col-12 px-0"><div class="item-row"><div :key="Model.Id" v-for="Model in homePSuggested.Model" class="col-xl-3 col-lg-4 col-md-4 col-sm-6 col-6 col-for-5-xl product-container mb-2">diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Head.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Head.cshtmlindex 89978f3e6..0f3eec499 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Head.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Head.cshtml@@ -1,5 +1,4 @@--@{+@{<script asp-location="Head" src="/bundles/app.runtime.bundle.js"></script><script asp-location="Head" src="/bundles/chunk-vendors.runtime.bundle.js"></script><link asp-src="/bundles/libs.css" rel="stylesheet">@@ -9,7 +8,7 @@<link asp-src="/Plugins/Theme.Modern/Content/swiper/swiper.min.css" rel="stylesheet"><link asp-src="/Plugins/Theme.Modern/Content/css/fonts/simple-line-icons.min.css" rel="stylesheet">-+<link rel="stylesheet" type="text/css" asp-src="/Plugins/Theme.Modern/Content/css/common/common.css"><link rel="stylesheet" type="text/css" asp-src="/Plugins/Theme.Modern/Content/css/header/header.css"><link rel="stylesheet" type="text/css" asp-src="/Plugins/Theme.Modern/Content/css/catalog/catalog.css">@@ -17,7 +16,7 @@<link rel="stylesheet" type="text/css" asp-src="/Plugins/Theme.Modern/Content/css/customer/customer.css"><link rel="stylesheet" type="text/css" asp-src="/Plugins/Theme.Modern/Content/css/cart/cart.css"><link rel="stylesheet" type="text/css" asp-src="/Plugins/Theme.Modern/Content/css/blog-news/blog-news.css">-+<script asp-location="Footer" asp-src="/theme/script/public.common.js" asp-order="201"></script><script asp-location="Footer" asp-src="/theme/script/public.axios.js" asp-order="202"></script>@@ -28,5 +27,4 @@<script asp-location="Footer" asp-src="/Plugins/Theme.Modern/Content/script/app.js" asp-order="903"></script><script asp-location="Footer" asp-src="/assets/custom/script.js" asp-order="906"></script>--}+}\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/CatalogProductView.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/CatalogProductView.cshtmlindex 52e3c3347..886e84de6 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/CatalogProductView.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/CatalogProductView.cshtml@@ -2,9 +2,9 @@@model ProductOverviewModel@{//prepare "Add to cart" Axios link- string addtocartlink = "";- string addtowishlistlink = "";- string quickviewurl = Url.RouteUrl("QuickView-Product", new { productId = Model.Id });+ var addtocartlink = "";+ var addtowishlistlink = "";+ var quickviewurl = Url.RouteUrl("QuickView-Product", new { productId = Model.Id });var shoppingCartTypeId = (int)ShoppingCartType.ShoppingCart;var quantity = 1;@@ -18,6 +18,7 @@addtocartlink = Model.ProductPrice.ForceRedirectionAfterAddingToCart ? Url.RouteUrl("AddProductCatalog", new { productId = Model.Id, shoppingCartTypeId, forceredirection = Model.ProductPrice.ForceRedirectionAfterAddingToCart }) : Url.RouteUrl("AddProductCatalog", new { productId = Model.Id, shoppingCartTypeId });addtowishlistlink = Url.RouteUrl("AddProductCatalog", new { productId = Model.Id, shoppingCartTypeId = (int)ShoppingCartType.Wishlist });}+var addtocomparelink = Url.RouteUrl("AddProductToCompare", new { productId = Model.Id });}@@ -42,65 +43,65 @@<div class="attr-container"><table><tbody>- @foreach (var item in Model.ProductAttributeModels)- {- <tr class="attr">- <td>- @*<div class="attr-name">+ @foreach (var item in Model.ProductAttributeModels)+ {+ <tr class="attr">+ <td>+ @*<div class="attr-name">@item.Name</div>*@- </td>- <td>- <div class="attr-value">- @foreach (var spec in item.Values)+ </td>+ <td>+ <div class="attr-value">+ @foreach (var spec in item.Values)+ {+ switch (item.AttributeControlType){- switch (item.AttributeControlType)- {- case AttributeControlType.DropdownList:- case AttributeControlType.RadioList:- case AttributeControlType.Checkboxes:- case AttributeControlType.ReadonlyCheckboxes:- <b-button variant="light" size="sm" class="name" href="@Url.RouteUrl("Product", new { Model.SeName })[email protected][email protected](spec.Name)">- @Html.Raw(spec.Name)+ case AttributeControlType.DropdownList:+ case AttributeControlType.RadioList:+ case AttributeControlType.Checkboxes:+ case AttributeControlType.ReadonlyCheckboxes:+ <b-button variant="light" size="sm" class="name" href="@Url.RouteUrl("Product", new { Model.SeName })[email protected][email protected](spec.Name)">+ @Html.Raw(spec.Name)+ </b-button>+ break;+ case AttributeControlType.ColorSquares:+ if (spec.PictureModel.FullSizeImageUrl != null)+ {+ <b-button variant="light" size="sm" class="name color-container" title="@spec.Name" v-on:click='productImage' data-href="@spec.PictureModel.FullSizeImageUrl">+ <span class="color" style="background-color:@spec.ColorSquaresRgb;"> </span></b-button>- break;- case AttributeControlType.ColorSquares:- if (spec.PictureModel.FullSizeImageUrl != null)- {- <b-button variant="light" size="sm" class="name color-container" title="@spec.Name" v-on:click='productImage' data-href="@spec.PictureModel.FullSizeImageUrl">- <span class="color" style="background-color:@spec.ColorSquaresRgb;"> </span>- </b-button>- }- else- {- <b-button variant="light" size="sm" class="name color-container" title="@spec.Name" href="@Url.RouteUrl("Product", new { Model.SeName })[email protected][email protected](spec.Name)">- <span class="color" style="background-color:@spec.ColorSquaresRgb;"> </span>- </b-button>- }- break;- case AttributeControlType.ImageSquares:- if (spec.PictureModel.FullSizeImageUrl != null)- {- <b-button variant="light" size="sm" class="p-1 name image-container" v-on:click='productImage' data-href="@spec.PictureModel.FullSizeImageUrl">- <img src="@spec.ImageSquaresPictureModel?.ImageUrl" alt="@spec.Name" />- </b-button>- }- else- {- <b-button variant="light" size="sm" class="p-1 name image-container" href="@Url.RouteUrl("Product", new { Model.SeName })[email protected][email protected](spec.Name)">- <img src="@spec.ImageSquaresPictureModel?.ImageUrl" alt="@spec.Name" />- </b-button>- }- break;- default:- break;- }+ }+ else+ {+ <b-button variant="light" size="sm" class="name color-container" title="@spec.Name" href="@Url.RouteUrl("Product", new { Model.SeName })[email protected][email protected](spec.Name)">+ <span class="color" style="background-color:@spec.ColorSquaresRgb;"> </span>+ </b-button>+ }++ break;+ case AttributeControlType.ImageSquares:+ if (spec.PictureModel.FullSizeImageUrl != null)+ {+ <b-button variant="light" size="sm" class="p-1 name image-container" v-on:click='productImage' data-href="@spec.PictureModel.FullSizeImageUrl">+ <img src="@spec.ImageSquaresPictureModel?.ImageUrl" alt="@spec.Name"/>+ </b-button>+ }+ else+ {+ <b-button variant="light" size="sm" class="p-1 name image-container" href="@Url.RouteUrl("Product", new { Model.SeName })[email protected][email protected](spec.Name)">+ <img src="@spec.ImageSquaresPictureModel?.ImageUrl" alt="@spec.Name"/>+ </b-button>+ }++ break;}- </div>- </td>+ }+ </div>+ </td>- </tr>- }+ </tr>+ }</tbody></table></div>@@ -113,10 +114,12 @@{addToCartText = Loc["ShoppingCart.Reservation"];}+if (Model.ProductPrice.AvailableForPreOrder){addToCartText = Loc["ShoppingCart.PreOrder"];}+<b-button v-b-tooltip.hover.bottom title="@(addToCartText)" variant="outline-secondary" onclick="AxiosCart.addproducttocart_catalog('@addtocartlink', '@Model.ShowQty', '@Model.Id');return false;"><span class="icons icon-handbag"></span><span class="sr-only">AddToCart</span>@@ -126,7 +129,6 @@{if (Model.ProductType == ProductType.Auction){-var addToCartText = Loc["ShoppingCart.Bids"];<b-button v-b-tooltip.hover.bottom title="@(addToCartText)" variant="outline-secondary" class="add-to-cart-button" onclick="AxiosCart.addproducttocart_catalog('@addtocartlink', 'false', '@Model.Id');return false;"><span class="icons icon-bell"></span>@@ -174,6 +176,7 @@{ratingValue = Convert.ToDecimal(Model.ReviewOverviewModel.RatingSum * (double)100 / Model.ReviewOverviewModel.TotalReviews / 100);}+<template><div class="rating"><b-form-rating id="[email protected]" class="p-0" variant="warning" no-border size="sm" show-value precision="2" readonly inline value="@(ratingValue)"></b-form-rating>@@ -183,7 +186,6 @@}@if (Model.ProductType == ProductType.Auction){-@if (Model.EndTime.HasValue){<div class="countdown-box alert alert-info w-100 mb-1">@@ -225,7 +227,7 @@@(Model.ProductPrice.HighestBidValue > 0 ? Model.ProductPrice.HighestBid : Model.ProductPrice.StartPrice)</div>}- @if (!String.IsNullOrEmpty(Model.ProductPrice.OldPrice))+ @if (!string.IsNullOrEmpty(Model.ProductPrice.OldPrice)){<div class="old-price price">@Model.ProductPrice.OldPrice@@ -252,10 +254,12 @@{addToCartText = Loc["ShoppingCart.Reservation"];}+if (Model.ProductPrice.AvailableForPreOrder){addToCartText = Loc["ShoppingCart.PreOrder"];}+<b-button variant="outline-secondary" class="add-to-cart-button" onclick="AxiosCart.addproducttocart_catalog('@addtocartlink', '@Model.ShowQty', '@Model.Id');return false;"><span class="add-cart-text">@(addToCartText)</span><span class="sr-only">AddToCart</span>@@ -265,7 +269,6 @@{if (Model.ProductType == ProductType.Auction){-var addToCartText = Loc["ShoppingCart.Bids"];<b-button variant="outline-secondary" class="add-to-cart-button" onclick="AxiosCart.addproducttocart_catalog('@addtocartlink', 'false', '@Model.Id');return false;"><span class="add-cart-text">@Loc["ShoppingCart.Bids"]</span>@@ -276,4 +279,4 @@</div></div></div>-</b-card>\ No newline at end of file+</b-card>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/CategoryLine.Menu.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/CategoryLine.Menu.cshtmlindex fe0f0b465..72ef3b6d8 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/CategoryLine.Menu.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/CategoryLine.Menu.cshtml@@ -2,11 +2,10 @@@if (Model.Category.IncludeInMenu){-var galleryCheck = Model.Category.UserFields.FirstOrDefault(x => x.Key == "gallery")?.Value;-- <li class="@if (galleryCheck == "true") { <text>hasGallery</text> } @(Model.Category.SubCategories.Count == 0 ? "category": "category -hasSubmenu")">++ <li class="@if (galleryCheck == "true") { <text>hasGallery</text> } @(Model.Category.SubCategories.Count == 0 ? "category" : "category -hasSubmenu")"><a href="@Url.RouteUrl("Category", new { Model.Category.SeName })">@if (!string.IsNullOrEmpty(Model.Category.Icon))@@ -20,7 +19,7 @@if (imageCheck == "true"){<picture>- <source media="(max-width: 991px)" sizes="1px" srcset="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 1w" />+ <source media="(max-width: 991px)" sizes="1px" srcset="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 1w"/><b-img-lazy class="img-fluid" src="@Model.Category.ImageUrl"></b-img-lazy></picture>}@@ -50,24 +49,55 @@var opacityCheck = Model.Category.UserFields.FirstOrDefault(x => x.Key == "opacity")?.Value;var menuBg = Model.Category.UserFields.FirstOrDefault(x => x.Key == "menuBg")?.Value;- <ul class="@if (galleryCheck == "true") { <text> @gallery </text> @if (sizeCheck != "") { <text> size-@sizeCheck </text> } @if (colsCheck != "") { <text> columns-@colsCheck </text> }} @if (opacityCheck == "true") { <text>opacity</text> } ">- @if (!string.IsNullOrEmpty(Model.Category.FlagStyle))- {- <li class="menuBg" style="background-image:url('@menuBg')"></li>- }- @foreach (var subCategory in subCategories)+ <ul class="@if (galleryCheck == "true") { <text> @gallery </text> @if (sizeCheck != "")+ {+ <text> size-@sizeCheck </text>+ } @if (colsCheck != "")+ {+ <text> columns-@colsCheck </text>+ }+ }++++++++++++ @if (opacityCheck == "true")+ {+ <text>opacity</text>+ }++++ ">+ @if (!string.IsNullOrEmpty(Model.Category.FlagStyle))+ {+ <li class="menuBg" style="background-image:url('@menuBg')"></li>+ }+++++ @foreach (var subCategory in subCategories)+ {+ var categoryLineModel = new MenuModel.CategoryLineModel{- var categoryLineModel = new MenuModel.CategoryLineModel- {- Category = subCategory,- Level = Model.Level + 1,- ResponsiveMobileMenu = Model.ResponsiveMobileMenu- };- <partial name="Partials/CategoryLine.Menu" model="categoryLineModel" />- }+ Category = subCategory,+ Level = Model.Level + 1,+ ResponsiveMobileMenu = Model.ResponsiveMobileMenu+ };+ <partial name="Partials/CategoryLine.Menu" model="categoryLineModel"/>+ }</ul>}}+if (Model.Level >= 1 && subCategories.Any()){levelClass = "next-level";@@ -80,16 +110,18 @@Level = Model.Level + 1,ResponsiveMobileMenu = Model.ResponsiveMobileMenu};- <partial name="Partials/CategoryLine.Menu" model="categoryLineModel" />+ <partial name="Partials/CategoryLine.Menu" model="categoryLineModel"/>}</ul>}+@if (Model.Category.SubCategories.Any()){<span class="go-back"></span><span class="go-forward"></span>}++}</li>-}-+}\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/Logo.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/Logo.cshtmlindex 57f6628f1..403c2b2bf 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/Logo.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/Logo.cshtml@@ -1,10 +1,11 @@-@inject StoreInformationSettings storeInformation+@using Grand.Business.Core.Interfaces.Storage+@inject StoreInformationSettings storeInformation@inject IWorkContext workContext-@inject Grand.Business.Core.Interfaces.Storage.IPictureService pictureService+@inject IPictureService pictureService@{var urlLogo = await pictureService.GetPictureUrl(storeInformation.LogoPictureId);}<a class="navbar-brand store-logo" target="_self" href="@Url.RouteUrl("HomePage")">- <img width="236" height="53" src="@urlLogo" alt="@workContext.CurrentStore.Name" />+ <img width="236" height="53" src="@urlLogo" alt="@workContext.CurrentStore.Name"/><span class="sr-only">@Loc["Logo"]</span></a>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/NewsletterBox.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/NewsletterBox.cshtmlindex 17379d64f..7ede887af 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/NewsletterBox.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/NewsletterBox.cshtml@@ -11,7 +11,7 @@</div><div class="input-group" role="group"><input id="newsletter-email" class="input-group-text form-control newsletter-email"- placeholder="@Loc["Newsletter.Email.Placeholder"]" aria-label="@Loc["Newsletter.Email.Placeholder"]" />+ placeholder="@Loc["Newsletter.Email.Placeholder"]" aria-label="@Loc["Newsletter.Email.Placeholder"]"/><label for="newsletter-email" class="sr-only">newsletter</label><div class="input-group-append"><button class="btn btn-secondary newsletter-email-button" id="newsletter-subscribe-button" @@click="newsletterBox(@customerSettings.NewsletterBlockAllowToUnsubscribe.ToString().ToLower(), '@(Url.RouteUrl("SubscribeNewsletter"))')">@@ -42,6 +42,6 @@<div class="alert alert-info"></div></div>- <input type="hidden" id="newsletterbox" data-href="@(Url.RouteUrl("SubscribeNewsletter"))" data-allowtounsubscribe=@customerSettings.NewsletterBlockAllowToUnsubscribe />+ <input type="hidden" id="newsletterbox" data-href="@(Url.RouteUrl("SubscribeNewsletter"))" data-allowtounsubscribe=@customerSettings.NewsletterBlockAllowToUnsubscribe/></div>}\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/PopupAddToCart.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/PopupAddToCart.cshtmlindex 1b4866b29..63a19e1db 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/PopupAddToCart.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/PopupAddToCart.cshtml@@ -1,6 +1,8 @@<b-modal id="ModalAddToCart" ref="ModalAddToCart" content-class="border-0" :dark-theme="darkMode" body-class="p-0" size="lg" centered hide-footer hide-header><template v-if="PopupAddToCartVueModal !== null">- <button class="modal-close btn" @@click="$bvModal.hide('ModalAddToCart')"><b-icon icon="x"></b-icon></button>+ <button class="modal-close btn" @@click="$bvModal.hide('ModalAddToCart')">+ <b-icon icon="x"></b-icon>+ </button><div class="card rounded-0 border-0"><div class="card-header rounded-0 border-0"><h5 class="mb-0">@@ -19,27 +21,35 @@<div class="col-12 px-0"><div class="form-row"><div class="d-sm-block d-none p-2">- <img :src="PopupAddToCartVueModal.Picture.ImageUrl" :alt="PopupAddToCartVueModal.Picture.AlternateText" :title="PopupAddToCartVueModal.Picture.Title" />+ <img :src="PopupAddToCartVueModal.Picture.ImageUrl" :alt="PopupAddToCartVueModal.Picture.AlternateText" :title="PopupAddToCartVueModal.Picture.Title"/></div><div>- <a :href="'/' + PopupAddToCartVueModal.ProductSeName"><h4>{{PopupAddToCartVueModal.ProductName}}</h4></a>+ <a :href="'/' + PopupAddToCartVueModal.ProductSeName">+ <h4>{{PopupAddToCartVueModal.ProductName}}</h4>+ </a><template v-if="PopupAddToCartVueModal.AttributeDescription !== ''"><div class="form-group col-12 px-0 d-none d-md-block my-2">- <label class="w-100 mb-0"><strong>@Loc["AddToCart.Attributes"]</strong></label>+ <label class="w-100 mb-0">+ <strong>@Loc["AddToCart.Attributes"]</strong>+ </label><div class="attributes p-2" v-html="PopupAddToCartVueModal.AttributeDescription"></div></div></template><template v-if="PopupAddToCartVueModal.ReservationInfo !== null"><div class="form-group col-12 px-0 d-none d-md-block">- <label class="w-100"><strong>@Loc["AddToCart.ReservationInfo"]</strong></label>+ <label class="w-100">+ <strong>@Loc["AddToCart.ReservationInfo"]</strong>+ </label><div class="attributes p-2" v-html="PopupAddToCartVueModal.ReservationInfo"></div></div></template><template v-if="!PopupAddToCartVueModal.IsAuction"><div class="form-group col-12 pl-0 mb-0 d-flex">- <label class="mb-0"><strong>@Loc["AddToCart.Qty"]</strong></label>+ <label class="mb-0">+ <strong>@Loc["AddToCart.Qty"]</strong>+ </label><label class="pl-3 mb-0">{{PopupAddToCartVueModal.Quantity}}</label></div></template>@@ -71,11 +81,15 @@<div class="form-group col-12 pl-0 mb-1 d-flex"><template v-if="PopupAddToCartVueModal.IsAuction">- <label class=""><strong>@Loc["AddToCart.Yourbid"]:</strong></label>+ <label class="">+ <strong>@Loc["AddToCart.Yourbid"]:</strong>+ </label><label class="pl-3 mb-0">{{PopupAddToCartVueModal.HighestBid}}</label></template><template v-else>- <label class=""><strong>@Loc["AddToCart.Price"]</strong></label>+ <label class="">+ <strong>@Loc["AddToCart.Price"]</strong>+ </label><label class="pl-3 mb-0">{{PopupAddToCartVueModal.Price}}</label></template></div>diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/ProductBoxListVue.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/ProductBoxListVue.cshtmlindex dc1350567..55aef0c92 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/ProductBoxListVue.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/ProductBoxListVue.cshtml@@ -1,76 +1,88 @@<template id="product-box-list-vue" asp-footer="true">-<b-card no-body class="product-box show list product-provider mb-3">- <template v-if="Model.Flag !== null">- <div class="flag-label" v-html="Model.Flag"></div>- </template> <div class="picture-container">- <b-link class="img-container" :href="'/' + Model.SeName" :title="Model.DefaultPictureModel.Title">- <b-img-lazy width="150" height="200" :alt="Model.DefaultPictureModel.AlternateText" class="main-product-img" :src="Model.DefaultPictureModel.ImageUrl" :title="Model.DefaultPictureModel.Title"></b-img-lazy>- <template v-if="Model.SecondPictureModel.ImageUrl !== null">- <b-img-lazy width="150" height="200" class="hover-img" :alt="Model.SecondPictureModel.AlternateText" :src="Model.SecondPictureModel.ImageUrl"></b-img-lazy>- </template>- </b-link>- </div> <b-card-body>- <h5 class="card-title"> <a :href="'/' + Model.SeName"> {{Model.Name}} </a> </h5>- <template v-if="Model.ShowSku && Model.Sku !== null">- <span class="sku">{{Model.Sku}}</span>- </template> <div class="prices-rating">- <template v-if="Model.ReviewOverviewModel.AllowCustomerReviews">- <div class="rating">- <template v-if="Model.ReviewOverviewModel.TotalReviews > 0">- <b-form-rating :id="'rating-inline-grid-' + Model.Id" class="p-0" variant="gold" aria-label="Rating" no-border size="sm" show-value precision="2" readonly inline :value="Model.ReviewOverviewModel.RatingSum / Model.ReviewOverviewModel.TotalReviews"></b-form-rating>- </template>- <template v-else>- <b-form-rating :id="'rating-inline-grid-' + Model.Id" class="p-0" variant="gold" no-border size="sm" show-value precision="2" readonly inline :value="0"></b-form-rating>- </template> <b-link :href="'/' + Model.SeName">{{Model.ReviewOverviewModel.TotalReviews}} @Loc["Reviews.Overview.Reviews"]</b-link>- </div>- </template>- <template v-if="Model.ProductType == 25">- <template v-if="Model.EndTime !== null">- <div class="countdown-box alert alert-info w-100 mb-1">- <template v-if="new Date(Model.EndTime).getTime() > new Date().getTime()">- <countdown :end-time="new Date(Model.EndTime).getTime()">- <template v-slot:process="{ timeObj }">- <span class="col-form-label">@Loc["AddToCart.Timeleft"]:</span>- <span>{{ `${timeObj.d}` }} : </span>- <span>{{ `${timeObj.h}` }} : </span>- <span>{{ `${timeObj.m}` }} : </span>- <span>{{ `${timeObj.s}` }}</span>- </template>- <template v-slot:finish>- <span>@Loc["ShoppingCart.Auctionends"]</span>- </template>- </countdown>- </template>- <template v-else>- <div class="d-inline-flex flex-wrap justify-content-center"> <label class="ended-label">@Loc["ShoppingCart.Auctionends"]:</label> <div class="count-date">{{Model.EndTimeLocalTime.Value}}</div> </div>- </template>- </div>+ <b-card no-body class="product-box show list product-provider mb-3">+ <template v-if="Model.Flag !== null">+ <div class="flag-label" v-html="Model.Flag"></div>+ </template>+ <div class="picture-container">+ <b-link class="img-container" :href="'/' + Model.SeName" :title="Model.DefaultPictureModel.Title">+ <b-img-lazy width="150" height="200" :alt="Model.DefaultPictureModel.AlternateText" class="main-product-img" :src="Model.DefaultPictureModel.ImageUrl" :title="Model.DefaultPictureModel.Title"></b-img-lazy>+ <template v-if="Model.SecondPictureModel.ImageUrl !== null">+ <b-img-lazy width="150" height="200" class="hover-img" :alt="Model.SecondPictureModel.AlternateText" :src="Model.SecondPictureModel.ImageUrl"></b-img-lazy></template>- </template> <div class="prices" v-bind:class="{ 'reservation-price': Model.ProductType == 20 }">- <template v-if="Model.ProductType != 40">- <div class="actual-price price"> {{Model.ProductPrice.Price}} </div>- </template>- <template v-else>- <div class="actual-price price">- <template v-if="Model.ProductPrice.HighestBidValue > 0 ">- {{Model.ProductPrice.HighestBid}}+ </b-link>+ </div>+ <b-card-body>+ <h5 class="card-title">+ <a :href="'/' + Model.SeName"> {{Model.Name}} </a>+ </h5>+ <template v-if="Model.ShowSku && Model.Sku !== null">+ <span class="sku">{{Model.Sku}}</span>+ </template>+ <div class="prices-rating">+ <template v-if="Model.ReviewOverviewModel.AllowCustomerReviews">+ <div class="rating">+ <template v-if="Model.ReviewOverviewModel.TotalReviews > 0">+ <b-form-rating :id="'rating-inline-grid-' + Model.Id" class="p-0" variant="gold" aria-label="Rating" no-border size="sm" show-value precision="2" readonly inline :value="Model.ReviewOverviewModel.RatingSum / Model.ReviewOverviewModel.TotalReviews"></b-form-rating></template><template v-else>- {{Model.ProductPrice.StartPrice}}- </template>+ <b-form-rating :id="'rating-inline-grid-' + Model.Id" class="p-0" variant="gold" no-border size="sm" show-value precision="2" readonly inline :value="0"></b-form-rating>+ </template> <b-link :href="'/' + Model.SeName">{{Model.ReviewOverviewModel.TotalReviews}} @Loc["Reviews.Overview.Reviews"]</b-link></div></template>- <template v-if="Model.ProductPrice.OldPrice !== null">- <div class="old-price price"> {{Model.ProductPrice.OldPrice}} </div>+ <template v-if="Model.ProductType == 25">+ <template v-if="Model.EndTime !== null">+ <div class="countdown-box alert alert-info w-100 mb-1">+ <template v-if="new Date(Model.EndTime).getTime() > new Date().getTime()">+ <countdown :end-time="new Date(Model.EndTime).getTime()">+ <template v-slot:process="{ timeObj }">+ <span class="col-form-label">@Loc["AddToCart.Timeleft"]:</span>+ <span>{{ `${timeObj.d}` }} : </span>+ <span>{{ `${timeObj.h}` }} : </span>+ <span>{{ `${timeObj.m}` }} : </span>+ <span>{{ `${timeObj.s}` }}</span>+ </template>+ <template v-slot:finish>+ <span>@Loc["ShoppingCart.Auctionends"]</span>+ </template>+ </countdown>+ </template>+ <template v-else>+ <div class="d-inline-flex flex-wrap justify-content-center">+ <label class="ended-label">@Loc["ShoppingCart.Auctionends"]:</label>+ <div class="count-date">{{Model.EndTimeLocalTime.Value}}</div>+ </div>+ </template>+ </div>+ </template></template>+ <div class="prices" v-bind:class="{ 'reservation-price': Model.ProductType == 20 }">+ <template v-if="Model.ProductType != 40">+ <div class="actual-price price"> {{Model.ProductPrice.Price}} </div>+ </template>+ <template v-else>+ <div class="actual-price price">+ <template v-if="Model.ProductPrice.HighestBidValue > 0 ">+ {{Model.ProductPrice.HighestBid}}+ </template>+ <template v-else>+ {{Model.ProductPrice.StartPrice}}+ </template>+ </div>+ </template>+ <template v-if="Model.ProductPrice.OldPrice !== null">+ <div class="old-price price"> {{Model.ProductPrice.OldPrice}} </div>+ </template>+ </div></div>- </div> <div class="desc" v-html="Model.ShortDescription"></div>- <template v-if="Model.ProductAttributeModels.length > 0">- <div class="attr-container">- <table>- <tbody>+ <div class="desc" v-html="Model.ShortDescription"></div>+ <template v-if="Model.ProductAttributeModels.length > 0">+ <div class="attr-container">+ <table>+ <tbody><tr v-for="item in Model.ProductAttributeModels">- <td> <div v-if="item.AttributeControlType !== 40 && item.AttributeControlType !== 45" class="attr-name"> {{item.Name}} </div> </td>+ <td>+ <div v-if="item.AttributeControlType !== 40 && item.AttributeControlType !== 45" class="attr-name"> {{item.Name}} </div>+ </td><td><div class="attr-value"><template v-for="spec in item.Values">@@ -79,36 +91,61 @@</template><template v-if="item.AttributeControlType == 40"><template v-if="spec.ImageSquaresPictureModel.FullSizeImageUrl !== undefined">- <b-button variant="light" size="sm" class="standard name color-container" :title="spec.Name" @@click="if(spec.PictureModel.FullSizeImageUrl !== null){vm.productImage($event)}" :data-href="spec.PictureModel.FullSizeImageUrl"> <span class="color" :style="'background-color:' + spec.ColorSquaresRgb"> </span> </b-button>+ <b-button variant="light" size="sm" class="standard name color-container" :title="spec.Name" @@click="if(spec.PictureModel.FullSizeImageUrl !== null){vm.productImage($event)}" :data-href="spec.PictureModel.FullSizeImageUrl">+ <span class="color" :style="'background-color:' + spec.ColorSquaresRgb"> </span>+ </b-button></template><template v-else>- <b-button variant="light" size="sm" class="standard name color-container" :title="spec.Name" :href="'/'+ Model.SeName + '?' + item.Name + '=' + spec.Name"> <span class="color" :style="'background-color:' + spec.ColorSquaresRgb"> </span> </b-button>+ <b-button variant="light" size="sm" class="standard name color-container" :title="spec.Name" :href="'/'+ Model.SeName + '?' + item.Name + '=' + spec.Name">+ <span class="color" :style="'background-color:' + spec.ColorSquaresRgb"> </span>+ </b-button></template></template><template v-if="item.AttributeControlType == 45"><template v-if="spec.ImageSquaresPictureModel.FullSizeImageUrl !== undefined">- <b-button variant="light" size="sm" class="standard p-1 name image-container" v-on:click='if(spec.PictureModel.FullSizeImageUrl !== null){vm.productImage($event)}' :data-href="spec.PictureModel.FullSizeImageUrl"> <b-img-lazy :src="spec.ImageSquaresPictureModel.ImageUrl" :alt="spec.Name"></b-img-lazy> </b-button>+ <b-button variant="light" size="sm" class="standard p-1 name image-container" v-on:click="if(spec.PictureModel.FullSizeImageUrl !== null){vm.productImage($event)}" :data-href="spec.PictureModel.FullSizeImageUrl">+ <b-img-lazy :src="spec.ImageSquaresPictureModel.ImageUrl" :alt="spec.Name"></b-img-lazy>+ </b-button></template><template v-else>- <b-button variant="light" size="sm" class="standard p-1 name image-container" :href="'/'+ Model.SeName + '?' + item.Name + '=' + spec.Name"> <b-img-lazy :src="spec.ImageSquaresPictureModel.ImageUrl" alt="spec.Name"></b-img-lazy> </b-button>+ <b-button variant="light" size="sm" class="standard p-1 name image-container" :href="'/'+ Model.SeName + '?' + item.Name + '=' + spec.Name">+ <b-img-lazy :src="spec.ImageSquaresPictureModel.ImageUrl" alt="spec.Name"></b-img-lazy>+ </b-button></template></template></template></div></td></tr>- </tbody>- </table>- </div>- </template> <div class="mt-auto">- <div class="list-button-container">- <template v-if="Model.ShowQty">- <input class="form-control input-group-addon catalog-quantity" type="number" :id="'addtocart_' + Model.Id + '_EnteredQuantity'" :name="'addtocart_' + Model.Id + '_EnteredQuantity'" value="1">- </template>- <template v-if="!Model.ProductPrice.DisableBuyButton">- <template v-if="!Model.ShowQty">- <a class="add-to-cart-button btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocart_catalog(`@Url.RouteUrl("AddProductCatalog")/' + Model.Id +'/1?quantity=1`, `' + Model.ShowQty +'`,`' + Model.Id + '`);return false;'">- <span class="add-cart-text">+ </tbody>+ </table>+ </div>+ </template>+ <div class="mt-auto">+ <div class="list-button-container">+ <template v-if="Model.ShowQty">+ <input class="form-control input-group-addon catalog-quantity" type="number" :id="'addtocart_' + Model.Id + '_EnteredQuantity'" :name="'addtocart_' + Model.Id + '_EnteredQuantity'" value="1">+ </template>+ <template v-if="!Model.ProductPrice.DisableBuyButton">+ <template v-if="!Model.ShowQty">+ <a class="add-to-cart-button btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocart_catalog(`@Url.RouteUrl("AddProductCatalog")/' + Model.Id +'/1?quantity=1`, `' + Model.ShowQty +'`,`' + Model.Id + '`);return false;'">+ <span class="add-cart-text">+ <template v-if="Model.ProductType == 20">+ @Loc["ShoppingCart.Reservation"]+ </template>+ <template v-else>+ <template v-if="Model.ProductPrice.AvailableForPreOrder">+ @Loc["ShoppingCart.PreOrder"]+ </template>+ <template v-else>+ @Loc["ShoppingCart.AddToCart"]+ </template>+ </template>+ </span> <span class="sr-only">AddToCart</span>+ </a>+ </template>+ <template v-else>+ <a class="add-to-cart-button btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocart_catalog(`@Url.RouteUrl("AddProductCatalog")/' + Model.Id +'/2`, `' + Model.ShowQty +'`,`' + Model.Id + '`);return false;'"><template v-if="Model.ProductType == 20">@Loc["ShoppingCart.Reservation"]</template>@@ -119,48 +156,43 @@<template v-else>@Loc["ShoppingCart.AddToCart"]</template>- </template>- </span> <span class="sr-only">AddToCart</span>- </a>+ </template> <span class="sr-only">AddToCart</span>+ </a>+ </template></template><template v-else>- <a class="add-to-cart-button btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocart_catalog(`@Url.RouteUrl("AddProductCatalog")/' + Model.Id +'/2`, `' + Model.ShowQty +'`,`' + Model.Id + '`);return false;'">- <template v-if="Model.ProductType == 20">- @Loc["ShoppingCart.Reservation"]+ <template v-if="Model.ProductType == 40">+ <a variant="info" class="add-to-cart-button btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocart_catalog(`/addproducttocart/catalog/' + Model.Id +'/1?quantity=1`, `' + Model.ShowQty +'`,`' + Model.Id + '`);return false;'">+ <span class="add-cart-text">@Loc["ShoppingCart.Bids"]</span> <span class="sr-only">AddToCart</span>+ </a>+ </template>+ </template>+ <div class="other-buttons">+ <a title="@Loc["Products.QuickView"]" v-b-tooltip.hover.bottom class="quick-view-button btn btn-outline-secondary" data-target="ModalQuickView" :onclick="'AxiosCart.quickview_product(`@Url.RouteUrl("QuickView-Product")/' + Model.Id + '`);return false;'">+ <b-icon icon="search"></b-icon>+ </a>+ <template v-if="!Model.ProductPrice.DisableWishlistButton && Model.ProductType == 0">+ <template v-if="!Model.ShowQty">+ <a v-b-tooltip.hover.bottom title="@Loc["ShoppingCart.AddToWishlist"]" class="btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocart_catalog(`@Url.RouteUrl("AddProductCatalog")/' + Model.Id +'/2?quantity=1`, `' + Model.ShowQty +'`,`' + Model.Id + '`);return false;'">+ <b-icon icon="heart"></b-icon> <span class="sr-only">AddToWishlist</span>+ </a></template><template v-else>- <template v-if="Model.ProductPrice.AvailableForPreOrder">- @Loc["ShoppingCart.PreOrder"]- </template>- <template v-else>- @Loc["ShoppingCart.AddToCart"]- </template>- </template> <span class="sr-only">AddToCart</span>- </a>- </template>- </template>- <template v-else>- <template v-if="Model.ProductType == 40">- <a variant="info" class="add-to-cart-button btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocart_catalog(`/addproducttocart/catalog/' + Model.Id +'/1?quantity=1`, `' + Model.ShowQty +'`,`' + Model.Id + '`);return false;'"> <span class="add-cart-text">@Loc["ShoppingCart.Bids"]</span> <span class="sr-only">AddToCart</span> </a>- </template>- </template> <div class="other-buttons">- <a title="@Loc["Products.QuickView"]" v-b-tooltip.hover.bottom class="quick-view-button btn btn-outline-secondary" data-target="ModalQuickView" :onclick="'AxiosCart.quickview_product(`@Url.RouteUrl("QuickView-Product")/' + Model.Id + '`);return false;'"> <b-icon icon="search"></b-icon> </a>- <template v-if="!Model.ProductPrice.DisableWishlistButton && Model.ProductType == 0">- <template v-if="!Model.ShowQty">- <a v-b-tooltip.hover.bottom title="@Loc["ShoppingCart.AddToWishlist"]" class="btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocart_catalog(`@Url.RouteUrl("AddProductCatalog")/' + Model.Id +'/2?quantity=1`, `' + Model.ShowQty +'`,`' + Model.Id + '`);return false;'"> <b-icon icon="heart"></b-icon> <span class="sr-only">AddToWishlist</span> </a>+ <a v-b-tooltip.hover.bottom title="@Loc["ShoppingCart.AddToWishlist"]" class="btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocart_catalog(`@Url.RouteUrl("AddProductCatalog")/' + Model.Id +'/2`, `' + Model.ShowQty +'`,`' + Model.Id + '`);return false;'">+ <b-icon icon="heart"></b-icon> <span class="sr-only">AddToWishlist</span>+ </a>+ </template></template>- <template v-else>- <a v-b-tooltip.hover.bottom title="@Loc["ShoppingCart.AddToWishlist"]" class="btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocart_catalog(`@Url.RouteUrl("AddProductCatalog")/' + Model.Id +'/2`, `' + Model.ShowQty +'`,`' + Model.Id + '`);return false;'"> <b-icon icon="heart"></b-icon> <span class="sr-only">AddToWishlist</span> </a>+ <template v-if="!Model.ProductPrice.DisableAddToCompareListButton && Model.ProductType == 0">+ <a v-b-tooltip.hover.bottom title="@Loc["ShoppingCart.AddToCompareList"]" class="btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocomparelist(`'+ Model.Id +'`, `@Loc["Products.ProductHasBeenAddedToCompareList.Link"]`, `@Url.RouteUrl("CompareProducts")`)'">+ <span class="sr-only">AddToCompareList</span> <b-icon icon="shuffle"></b-icon>+ </a></template>- </template>- <template v-if="!Model.ProductPrice.DisableAddToCompareListButton && Model.ProductType == 0">- <a v-b-tooltip.hover.bottom title="@Loc["ShoppingCart.AddToCompareList"]" class="btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocomparelist(`'+ Model.Id +'`, `@Loc["Products.ProductHasBeenAddedToCompareList.Link"]`, `@Url.RouteUrl("CompareProducts")`)'"> <span class="sr-only">AddToCompareList</span> <b-icon icon="shuffle"></b-icon> </a>- </template>+ </div></div></div>- </div>- </b-card-body> <!--<template v-slot:footer> <template v-if="Model.SpecificationAttributeModels.length > 0"> <div class="spec-container"> <table> <tbody> <tr class="attr" v-for="item in Model.SpecificationAttributeModels" v-bind:id="item.SpecificationAttributeId"> <td> <div class="spec-name"> {{item.SpecificationAttributeName}} </div> </td> <td> <div class="spec-value"> <span v-html="item.ValueRaw"></span> </div> </td> </tr> </tbody> </table> </div> </template> <template v-if="Model.ProductAttributeModels.length > 0"> <div class="attr-container"> <table> <tbody> <tr v-for="item in Model.ProductAttributeModels" v-bind:id="item.ProductAttributeId"> <td> <div class="attr-name"> {{item.Name}} </div> </td> <td> <div class="attr-value"> <template v-for="spec in item.Values"> <template v-if="item.AttributeControlType == 1 || item.AttributeControlType == 2 || item.AttributeControlType == 3 || item.AttributeControlType == 50"> <b-button variant="light" size="sm" class="name" :href="'/'+ Model.SeName + '?' + item.Name + '=' + spec.Name"> {{spec.Name}} </b-button> </template> <template v-if="item.AttributeControlType == 40"> <template v-if="spec.PictureModel.FullSizeImageUrl.length > 0"> <b-button variant="light" size="sm" class="name color-container" :title="spec.Name" @@click="vm.productImage($event)" :data-href="spec.PictureModel.FullSizeImageUrl"> <span class="color" :style="'background-color:' + spec.ColorSquaresRgb"> </span> </b-button> </template> <template v-else> <b-button variant="light" size="sm" class="name color-container" :title="spec.Name" :href="'/'+ Model.SeName + '?' + item.Name + '=' + spec.Name"> <span class="color" :style="'background-color:' + spec.ColorSquaresRgb"> </span> </b-button> </template> </template> <template v-if="item.AttributeControlType == 45"> <template v-if="spec.PictureModel.FullSizeImageUrl.length > 0"> <b-button variant="light" size="sm" class="p-1 name image-container" v-on:click='productImage' :data-href="spec.PictureModel.FullSizeImageUrl"> <img :src="spec.ImageSquaresPictureModel?.ImageUrl" :alt="spec.Name" /> </b-button> </template> <template v-else> <b-button variant="light" size="sm" class="p-1 name image-container" :href="'/'+ Model.SeName + '?' + item.Name + '=' + spec.Name"> <img :src="spec.ImageSquaresPictureModel?.ImageUrl" alt="spec.Name" /> </b-button> </template> </template> </template> </div> </td> </tr> </tbody> </table> </div> </template>--> @*<div class="desc" v-html="Model.ShortDescription"></div>*@ <!--</template>-->-</b-card>+ </b-card-body> <!--<template v-slot:footer> <template v-if="Model.SpecificationAttributeModels.length > 0"> <div class="spec-container"> <table> <tbody> <tr class="attr" v-for="item in Model.SpecificationAttributeModels" v-bind:id="item.SpecificationAttributeId"> <td> <div class="spec-name"> {{item.SpecificationAttributeName}} </div> </td> <td> <div class="spec-value"> <span v-html="item.ValueRaw"></span> </div> </td> </tr> </tbody> </table> </div> </template> <template v-if="Model.ProductAttributeModels.length > 0"> <div class="attr-container"> <table> <tbody> <tr v-for="item in Model.ProductAttributeModels" v-bind:id="item.ProductAttributeId"> <td> <div class="attr-name"> {{item.Name}} </div> </td> <td> <div class="attr-value"> <template v-for="spec in item.Values"> <template v-if="item.AttributeControlType == 1 || item.AttributeControlType == 2 || item.AttributeControlType == 3 || item.AttributeControlType == 50"> <b-button variant="light" size="sm" class="name" :href="'/'+ Model.SeName + '?' + item.Name + '=' + spec.Name"> {{spec.Name}} </b-button> </template> <template v-if="item.AttributeControlType == 40"> <template v-if="spec.PictureModel.FullSizeImageUrl.length > 0"> <b-button variant="light" size="sm" class="name color-container" :title="spec.Name" @@click="vm.productImage($event)" :data-href="spec.PictureModel.FullSizeImageUrl"> <span class="color" :style="'background-color:' + spec.ColorSquaresRgb"> </span> </b-button> </template> <template v-else> <b-button variant="light" size="sm" class="name color-container" :title="spec.Name" :href="'/'+ Model.SeName + '?' + item.Name + '=' + spec.Name"> <span class="color" :style="'background-color:' + spec.ColorSquaresRgb"> </span> </b-button> </template> </template> <template v-if="item.AttributeControlType == 45"> <template v-if="spec.PictureModel.FullSizeImageUrl.length > 0"> <b-button variant="light" size="sm" class="p-1 name image-container" v-on:click='productImage' :data-href="spec.PictureModel.FullSizeImageUrl"> <img :src="spec.ImageSquaresPictureModel?.ImageUrl" :alt="spec.Name" /> </b-button> </template> <template v-else> <b-button variant="light" size="sm" class="p-1 name image-container" :href="'/'+ Model.SeName + '?' + item.Name + '=' + spec.Name"> <img :src="spec.ImageSquaresPictureModel?.ImageUrl" alt="spec.Name" /> </b-button> </template> </template> </template> </div> </td> </tr> </tbody> </table> </div> </template>--> @*<div class="desc" v-html="Model.ShortDescription"></div>*@ <!--</template>-->+ </b-card></template><script asp-location="Footer" asp-order="118" type="module">Vue.component('product-box-list-vue', {diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/ProductBoxVue.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/ProductBoxVue.cshtmlindex c7349e944..dfd551c5e 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/ProductBoxVue.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/ProductBoxVue.cshtml@@ -1,238 +1,240 @@<template id="product-box-vue" asp-footer="true">- <div class="card product-box show product-provider mb-2">- <template v-if="Model.Flag !== null">- <div class="flag-label">- <span v-html="Model.Flag"></span>- </div>+<div class="card product-box show product-provider mb-2">+<template v-if="Model.Flag !== null">+ <div class="flag-label">+ <span v-html="Model.Flag"></span>+ </div>+</template>+<div class="picture-container">+ <a class="img-container" :href="'/' + Model.SeName" :title="Model.DefaultPictureModel.Title">+ <b-img-lazy width="150" height="200" :alt="Model.DefaultPictureModel.AlternateText" class="main-product-img" :src="Model.DefaultPictureModel.ImageUrl" :title="Model.DefaultPictureModel.Title"></b-img-lazy>+ <template v-if="Model.SecondPictureModel.ImageUrl !== null">+ <b-img-lazy width="150" height="200" class="hover-img" :alt="Model.SecondPictureModel.AlternateText" :src="Model.SecondPictureModel.ImageUrl"></b-img-lazy></template>- <div class="picture-container">- <a class="img-container" :href="'/' + Model.SeName" :title="Model.DefaultPictureModel.Title">- <b-img-lazy width="150" height="200" :alt="Model.DefaultPictureModel.AlternateText" class="main-product-img" :src="Model.DefaultPictureModel.ImageUrl" :title="Model.DefaultPictureModel.Title"></b-img-lazy>- <template v-if="Model.SecondPictureModel.ImageUrl !== null">- <b-img-lazy width="150" height="200" class="hover-img" :alt="Model.SecondPictureModel.AlternateText" :src="Model.SecondPictureModel.ImageUrl"></b-img-lazy>- </template>- </a>- <template v-if="Model.ProductAttributeModels.length > 0">- <div class="attr-container">- <table>- <tbody>- <tr v-for="item in Model.ProductAttributeModels">- <td>- <div v-if="item.AttributeControlType !== 40 && item.AttributeControlType !== 45" class="attr-name">- {{item.Name}}- </div>- </td>- <td>- <div class="attr-value">- <template v-for="spec in item.Values">- <template v-if="item.AttributeControlType == 1 || item.AttributeControlType == 2 || item.AttributeControlType == 3 || item.AttributeControlType == 50">- <b-button variant="light" size="sm" class="name" :href="'/'+ Model.SeName + '?' + item.Name + '=' + spec.Name">- {{spec.Name}}- </b-button>- </template>- <template v-if="item.AttributeControlType == 40">- <template v-if="spec.ImageSquaresPictureModel.FullSizeImageUrl !== undefined">- <b-button variant="light" size="sm" class="standard name color-container" :title="spec.Name" @@click="if(spec.PictureModel.FullSizeImageUrl !== null){vm.productImage($event)}" :data-href="spec.PictureModel.FullSizeImageUrl">- <span class="color" :style="'background-color:' + spec.ColorSquaresRgb"> </span>- </b-button>- </template>- <template v-else>- <b-button variant="light" size="sm" class="standard name color-container" :title="spec.Name" :href="'/'+ Model.SeName + '?' + item.Name + '=' + spec.Name">- <span class="color" :style="'background-color:' + spec.ColorSquaresRgb"> </span>- </b-button>- </template>- </template>- <template v-if="item.AttributeControlType == 45">- <template v-if="spec.ImageSquaresPictureModel.FullSizeImageUrl !== undefined">- <b-button variant="light" size="sm" class="standard p-1 name image-container" v-on:click='if(spec.PictureModel.FullSizeImageUrl !== null){vm.productImage($event)}' :data-href="spec.PictureModel.FullSizeImageUrl">- <b-img-lazy :src="spec.ImageSquaresPictureModel.ImageUrl" :alt="spec.Name"></b-img-lazy>- </b-button>- </template>- <template v-else>- <b-button variant="light" size="sm" class="standard p-1 name image-container" :href="'/'+ Model.SeName + '?' + item.Name + '=' + spec.Name">- <b-img-lazy :src="spec.ImageSquaresPictureModel.ImageUrl" alt="spec.Name"></b-img-lazy>- </b-button>- </template>- </template>- </template>- </div>- </td>- </tr>- </tbody>- </table>- </div>- </template>- <div class="other-buttons">- <template v-if="!Model.ProductPrice.DisableWishlistButton && Model.ProductType == 0">- <template v-if="!Model.ShowQty">- <a v-b-tooltip.hover.bottom title="@Loc["ShoppingCart.AddToWishlist"]" class="btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocart_catalog(`@Url.RouteUrl("AddProductCatalog")/' + Model.Id +'/2?quantity=1`, `' + Model.ShowQty +'`,`' + Model.Id + '`);return false;'">- <span class="icons icon-heart"></span>- <span class="sr-only">AddToWishlist</span>- </a>- </template>- <template v-else>- <a v-b-tooltip.hover.bottom title="@Loc["ShoppingCart.AddToWishlist"]" class="btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocart_catalog(`@Url.RouteUrl("AddProductCatalog")/' + Model.Id +'/2`, `' + Model.ShowQty +'`,`' + Model.Id + '`);return false;'">- <span class="icons icon-heart"></span>- <span class="sr-only">AddToWishlist</span>- </a>- </template>- </template>- <template v-if="!Model.ProductPrice.DisableAddToCompareListButton && Model.ProductType == 0">- <a v-b-tooltip.hover.bottom title="@Loc["ShoppingCart.AddToCompareList"]" class="btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocomparelist(`'+ Model.Id +'`, `@Loc["Products.ProductHasBeenAddedToCompareList.Link"]`, `@Url.RouteUrl("CompareProducts")`)'">- <span class="sr-only">AddToCompareList</span>- <span class="icons icon-shuffle"></span>- </a>- </template>- </div>- <div class="qvb-container">- <a title="@Loc["Products.QuickView"]" class="quick-view-button w-100 btn btn-secondary" data-target="ModalQuickView" :onclick="'AxiosCart.quickview_product(`@Url.RouteUrl("QuickView-Product")/' + Model.Id + '`);return false;'">- <span class="icons icon-magnifier"></span>- <span>@Loc["Products.QuickView"]</span>- </a>- </div>- </div>- <div class="card-body">- <h5 class="card-title">- <a :href="'/' + Model.SeName">- {{Model.Name}}- </a>- </h5>- <template v-if="Model.ShowSku && Model.Sku !== null">- <span class="sku">{{Model.Sku}}</span>- </template>- <div class="prices-rating">- <template v-if="Model.ReviewOverviewModel.AllowCustomerReviews">- <div class="rating">- <template v-if="Model.ReviewOverviewModel.TotalReviews > 0">- <b-form-rating :id="'rating-inline-grid-' + Model.Id" icon-full="star-fill" icon-empty="star-fill" class="p-0" aria-label="Rating" no-border size="sm" show-value precision="2" readonly inline :value="Model.ReviewOverviewModel.RatingSum / Model.ReviewOverviewModel.TotalReviews"></b-form-rating>- </template>- <template v-else>- <b-form-rating :id="'rating-inline-grid-' + Model.Id" icon-empty="star-fill" class="p-0" no-border size="sm" show-value precision="2" readonly inline :value="0"></b-form-rating>- </template>- <b-link :href="'/' + Model.SeName">{{Model.ReviewOverviewModel.TotalReviews}} @Loc["Reviews.Overview.Reviews"]</b-link>- </div>- </template>- <template v-if="Model.ProductType == 40">- <template v-if="Model.EndTime !== null">- <div class="countdown-box alert alert-info w-100 mb-1">- <template v-if="new Date(Model.EndTime).getTime() > new Date().getTime()">- <countdown :end-time="new Date(Model.EndTime).getTime()">- <template v-slot:process="{ timeObj }">- <span class="col-form-label">@Loc["AddToCart.Timeleft"]:</span>- <span>{{ `${timeObj.d}` }} : </span>- <span>{{ `${timeObj.h}` }} : </span>- <span>{{ `${timeObj.m}` }} : </span>- <span>{{ `${timeObj.s}` }}</span>+ </a>+ <template v-if="Model.ProductAttributeModels.length > 0">+ <div class="attr-container">+ <table>+ <tbody>+ <tr v-for="item in Model.ProductAttributeModels">+ <td>+ <div v-if="item.AttributeControlType !== 40 && item.AttributeControlType !== 45" class="attr-name">+ {{item.Name}}+ </div>+ </td>+ <td>+ <div class="attr-value">+ <template v-for="spec in item.Values">+ <template v-if="item.AttributeControlType == 1 || item.AttributeControlType == 2 || item.AttributeControlType == 3 || item.AttributeControlType == 50">+ <b-button variant="light" size="sm" class="name" :href="'/'+ Model.SeName + '?' + item.Name + '=' + spec.Name">+ {{spec.Name}}+ </b-button>+ </template>+ <template v-if="item.AttributeControlType == 40">+ <template v-if="spec.ImageSquaresPictureModel.FullSizeImageUrl !== undefined">+ <b-button variant="light" size="sm" class="standard name color-container" :title="spec.Name" @@click="if(spec.PictureModel.FullSizeImageUrl !== null){vm.productImage($event)}" :data-href="spec.PictureModel.FullSizeImageUrl">+ <span class="color" :style="'background-color:' + spec.ColorSquaresRgb"> </span>+ </b-button></template>- <template v-slot:finish>- <span>@Loc["ShoppingCart.Auctionends"]</span>+ <template v-else>+ <b-button variant="light" size="sm" class="standard name color-container" :title="spec.Name" :href="'/'+ Model.SeName + '?' + item.Name + '=' + spec.Name">+ <span class="color" :style="'background-color:' + spec.ColorSquaresRgb"> </span>+ </b-button></template>- </countdown>- </template>- <template v-else>- <div class="d-inline-flex flex-wrap justify-content-center">- <label class="ended-label">@Loc["ShoppingCart.Auctionends"]:</label>- <div class="count-date">{{Model.EndTimeLocalTime.Value}}</div>- </div>+ </template>+ <template v-if="item.AttributeControlType == 45">+ <template v-if="spec.ImageSquaresPictureModel.FullSizeImageUrl !== undefined">+ <b-button variant="light" size="sm" class="standard p-1 name image-container" v-on:click="if(spec.PictureModel.FullSizeImageUrl !== null){vm.productImage($event)}" :data-href="spec.PictureModel.FullSizeImageUrl">+ <b-img-lazy :src="spec.ImageSquaresPictureModel.ImageUrl" :alt="spec.Name"></b-img-lazy>+ </b-button>+ </template>+ <template v-else>+ <b-button variant="light" size="sm" class="standard p-1 name image-container" :href="'/'+ Model.SeName + '?' + item.Name + '=' + spec.Name">+ <b-img-lazy :src="spec.ImageSquaresPictureModel.ImageUrl" alt="spec.Name"></b-img-lazy>+ </b-button>+ </template>+ </template></template></div>- </template>+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ </template>+ <div class="other-buttons">+ <template v-if="!Model.ProductPrice.DisableWishlistButton && Model.ProductType == 0">+ <template v-if="!Model.ShowQty">+ <a v-b-tooltip.hover.bottom title="@Loc["ShoppingCart.AddToWishlist"]" class="btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocart_catalog(`@Url.RouteUrl("AddProductCatalog")/' + Model.Id +'/2?quantity=1`, `' + Model.ShowQty +'`,`' + Model.Id + '`);return false;'">+ <span class="icons icon-heart"></span>+ <span class="sr-only">AddToWishlist</span>+ </a>+ </template>+ <template v-else>+ <a v-b-tooltip.hover.bottom title="@Loc["ShoppingCart.AddToWishlist"]" class="btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocart_catalog(`@Url.RouteUrl("AddProductCatalog")/' + Model.Id +'/2`, `' + Model.ShowQty +'`,`' + Model.Id + '`);return false;'">+ <span class="icons icon-heart"></span>+ <span class="sr-only">AddToWishlist</span>+ </a>+ </template>+ </template>+ <template v-if="!Model.ProductPrice.DisableAddToCompareListButton && Model.ProductType == 0">+ <a v-b-tooltip.hover.bottom title="@Loc["ShoppingCart.AddToCompareList"]" class="btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocomparelist(`'+ Model.Id +'`, `@Loc["Products.ProductHasBeenAddedToCompareList.Link"]`, `@Url.RouteUrl("CompareProducts")`)'">+ <span class="sr-only">AddToCompareList</span>+ <span class="icons icon-shuffle"></span>+ </a>+ </template>+ </div>+ <div class="qvb-container">+ <a title="@Loc["Products.QuickView"]" class="quick-view-button w-100 btn btn-secondary" data-target="ModalQuickView" :onclick="'AxiosCart.quickview_product(`@Url.RouteUrl("QuickView-Product")/' + Model.Id + '`);return false;'">+ <span class="icons icon-magnifier"></span>+ <span>@Loc["Products.QuickView"]</span>+ </a>+ </div>+</div>+<div class="card-body">+ <h5 class="card-title">+ <a :href="'/' + Model.SeName">+ {{Model.Name}}+ </a>+ </h5>+ <template v-if="Model.ShowSku && Model.Sku !== null">+ <span class="sku">{{Model.Sku}}</span>+ </template>+ <div class="prices-rating">+ <template v-if="Model.ReviewOverviewModel.AllowCustomerReviews">+ <div class="rating">+ <template v-if="Model.ReviewOverviewModel.TotalReviews > 0">+ <b-form-rating :id="'rating-inline-grid-' + Model.Id" icon-full="star-fill" icon-empty="star-fill" class="p-0" aria-label="Rating" no-border size="sm" show-value precision="2" readonly inline :value="Model.ReviewOverviewModel.RatingSum / Model.ReviewOverviewModel.TotalReviews"></b-form-rating></template>- <div class="prices" v-bind:class="{ 'reservation-price': Model.ProductType == 20 }">- <template v-if="Model.ProductType != 40">- <div class="actual-price price">- {{Model.ProductPrice.Price}}- </div>- </template>- <template v-else>- <div class="actual-price price">- <template v-if="Model.ProductPrice.HighestBidValue > 0 ">- {{Model.ProductPrice.HighestBid}}+ <template v-else>+ <b-form-rating :id="'rating-inline-grid-' + Model.Id" icon-empty="star-fill" class="p-0" no-border size="sm" show-value precision="2" readonly inline :value="0"></b-form-rating>+ </template>+ <b-link :href="'/' + Model.SeName">{{Model.ReviewOverviewModel.TotalReviews}} @Loc["Reviews.Overview.Reviews"]</b-link>+ </div>+ </template>+ <template v-if="Model.ProductType == 40">+ <template v-if="Model.EndTime !== null">+ <div class="countdown-box alert alert-info w-100 mb-1">+ <template v-if="new Date(Model.EndTime).getTime() > new Date().getTime()">+ <countdown :end-time="new Date(Model.EndTime).getTime()">+ <template v-slot:process="{ timeObj }">+ <span class="col-form-label">@Loc["AddToCart.Timeleft"]:</span>+ <span>{{ `${timeObj.d}` }} : </span>+ <span>{{ `${timeObj.h}` }} : </span>+ <span>{{ `${timeObj.m}` }} : </span>+ <span>{{ `${timeObj.s}` }}</span></template>- <template v-else>- {{Model.ProductPrice.StartPrice}}+ <template v-slot:finish>+ <span>@Loc["ShoppingCart.Auctionends"]</span></template>- </div>+ </countdown></template>- <template v-if="Model.ProductPrice.OldPrice !== null">- <div class="old-price price">- {{Model.ProductPrice.OldPrice}}+ <template v-else>+ <div class="d-inline-flex flex-wrap justify-content-center">+ <label class="ended-label">@Loc["ShoppingCart.Auctionends"]:</label>+ <div class="count-date">{{Model.EndTimeLocalTime.Value}}</div></div></template></div>- </div>- </div>- <div class="card-footer">- <template v-if="Model.SpecificationAttributeModels[0] !== null">- <div class="spec-container animate__animated" data-animation="animate__fadeIn" data-delay="animate__delay-1s">- <table>- <tbody>- <tr v-for="group in Model.SpecificationAttributeModels">- <template v-if="group[0] !== undefined">- <td>- {{group[0].SpecificationAttributeName}}- </td>- <td v-for="spec in group" v-bind:id="spec.SpecificationAttributeId">- <template v-if="spec.ColorSquaresRgb == null">- <div class="spec-value"> <span v-html="spec.ValueRaw"></span></div>- </template>- </td>- </template>- </tr>- </tbody>- </table>+ </template>+ </template>+ <div class="prices" v-bind:class="{ 'reservation-price': Model.ProductType == 20 }">+ <template v-if="Model.ProductType != 40">+ <div class="actual-price price">+ {{Model.ProductPrice.Price}}</div></template>- <div class="desc" v-html="Model.ShortDescription"></div>- <template v-if="Model.ShowQty">- <input class="form-control input-group-addon catalog-quantity" type="number" :id="'addtocart_' + Model.Id + '_EnteredQuantity'" :name="'addtocart_' + Model.Id + '_EnteredQuantity'" value="1">+ <template v-else>+ <div class="actual-price price">+ <template v-if="Model.ProductPrice.HighestBidValue > 0 ">+ {{Model.ProductPrice.HighestBid}}+ </template>+ <template v-else>+ {{Model.ProductPrice.StartPrice}}+ </template>+ </div></template>- <template v-if="!Model.ProductPrice.DisableBuyButton">- <template v-if="!Model.ShowQty">- <a class="add-to-cart-button btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocart_catalog(`@Url.RouteUrl("AddProductCatalog")/' + Model.Id +'/1?quantity=1`, `' + Model.ShowQty +'`,`' + Model.Id + '`);return false;'">- <span class="add-cart-text-view">- <template v-if="Model.ProductType == 20">- @Loc["ShoppingCart.Reservation"]- </template>- <template v-else>- <template v-if="Model.ProductPrice.AvailableForPreOrder">- @Loc["ShoppingCart.PreOrder"]- </template>- <template v-else>- @Loc["ShoppingCart.AddToCart"]- </template>+ <template v-if="Model.ProductPrice.OldPrice !== null">+ <div class="old-price price">+ {{Model.ProductPrice.OldPrice}}+ </div>+ </template>+ </div>+ </div>+</div>+<div class="card-footer">+ <template v-if="Model.SpecificationAttributeModels[0] !== null">+ <div class="spec-container animate__animated" data-animation="animate__fadeIn" data-delay="animate__delay-1s">+ <table>+ <tbody>+ <tr v-for="group in Model.SpecificationAttributeModels">+ <template v-if="group[0] !== undefined">+ <td>+ {{group[0].SpecificationAttributeName}}+ </td>+ <td v-for="spec in group" v-bind:id="spec.SpecificationAttributeId">+ <template v-if="spec.ColorSquaresRgb == null">+ <div class="spec-value">+ <span v-html="spec.ValueRaw"></span>+ </div></template>- </span>- <span class="sr-only">AddToCart</span>- </a>- </template>- <template v-else>- <a class="add-to-cart-button btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocart_catalog(`@Url.RouteUrl("AddProductCatalog")/' + Model.Id +'/2`, `' + Model.ShowQty +'`,`' + Model.Id + '`);return false;'">- <template v-if="Model.ProductType == 20">- @Loc["ShoppingCart.Reservation"]+ </td>+ </template>+ </tr>+ </tbody>+ </table>+ </div>+ </template>+ <div class="desc" v-html="Model.ShortDescription"></div>+ <template v-if="Model.ShowQty">+ <input class="form-control input-group-addon catalog-quantity" type="number" :id="'addtocart_' + Model.Id + '_EnteredQuantity'" :name="'addtocart_' + Model.Id + '_EnteredQuantity'" value="1">+ </template>+ <template v-if="!Model.ProductPrice.DisableBuyButton">+ <template v-if="!Model.ShowQty">+ <a class="add-to-cart-button btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocart_catalog(`@Url.RouteUrl("AddProductCatalog")/' + Model.Id +'/1?quantity=1`, `' + Model.ShowQty +'`,`' + Model.Id + '`);return false;'">+ <span class="add-cart-text-view">+ <template v-if="Model.ProductType == 20">+ @Loc["ShoppingCart.Reservation"]+ </template>+ <template v-else>+ <template v-if="Model.ProductPrice.AvailableForPreOrder">+ @Loc["ShoppingCart.PreOrder"]</template><template v-else>- <template v-if="Model.ProductPrice.AvailableForPreOrder">- @Loc["ShoppingCart.PreOrder"]- </template>- <template v-else>- @Loc["ShoppingCart.AddToCart"]- </template>+ @Loc["ShoppingCart.AddToCart"]</template>- <span class="sr-only">AddToCart</span>- </a>+ </template>+ </span>+ <span class="sr-only">AddToCart</span>+ </a>+ </template>+ <template v-else>+ <a class="add-to-cart-button btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocart_catalog(`@Url.RouteUrl("AddProductCatalog")/' + Model.Id +'/2`, `' + Model.ShowQty +'`,`' + Model.Id + '`);return false;'">+ <template v-if="Model.ProductType == 20">+ @Loc["ShoppingCart.Reservation"]</template>- </template>- <template v-else>- <template v-if="Model.ProductType == 40">- <a variant="info" class="add-to-cart-button btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocart_catalog(`@Url.RouteUrl("AddProductCatalog")/' + Model.Id +'/1?quantity=1`, `' + Model.ShowQty +'`,`' + Model.Id + '`);return false;'">- <span class="add-cart-text">@Loc["ShoppingCart.Bids"]</span>- <span class="sr-only">AddToCart</span>- </a>+ <template v-else>+ <template v-if="Model.ProductPrice.AvailableForPreOrder">+ @Loc["ShoppingCart.PreOrder"]+ </template>+ <template v-else>+ @Loc["ShoppingCart.AddToCart"]+ </template></template>- </template>- </div>- </div>+ <span class="sr-only">AddToCart</span>+ </a>+ </template>+ </template>+ <template v-else>+ <template v-if="Model.ProductType == 40">+ <a variant="info" class="add-to-cart-button btn btn-outline-secondary" :onclick="'AxiosCart.addproducttocart_catalog(`@Url.RouteUrl("AddProductCatalog")/' + Model.Id +'/1?quantity=1`, `' + Model.ShowQty +'`,`' + Model.Id + '`);return false;'">+ <span class="add-cart-text">@Loc["ShoppingCart.Bids"]</span>+ <span class="sr-only">AddToCart</span>+ </a>+ </template>+ </template>+</div>+</div></template><script asp-location="Footer" asp-order="118" type="module">Vue.component('product-box-vue', {diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/ProductQuickView.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/ProductQuickView.cshtmlindex 40389a69f..ce3e7badb 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/ProductQuickView.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/ProductQuickView.cshtml@@ -1,124 +1,124 @@@{-var categoryLink = Url.RouteUrl("Category");-var productLink = Url.RouteUrl("Product");+ var categoryLink = Url.RouteUrl("Category");+ var productLink = Url.RouteUrl("Product");}<b-modal id="ModalQuickView" ref="ModalQuickView" :dark-theme="darkMode" @@shown="initReservationQV(), QuickViewShown()" size="xl" centered hide-footer hide-header>- <template v-if="PopupQuickViewVueModal !== null">- <form method="post" id="product-details-form" :action="'/' + PopupQuickViewVueModal.SeName">- <div itemscope itemtype="http://schema.org/Product" :data-productid="PopupQuickViewVueModal.Id">- <div class="quick-view">- <div class="col-12 px-0">- <div class="form-row">- <div class="col-lg-5 col-12">- <div v-if="PopupQuickViewVueModal.PictureModels.length > 1" class="product-gallery">- <swiper ref="QuickViewSlider"- :options="QuickViewSlider.swiperOptions">- <swiper-slide class="slide-wide" v-for="picture in PopupQuickViewVueModal.PictureModels">- <img class="img-fluid" :src="picture.ImageUrl" :data-srcs="picture.ImageUrl" :alt="picture.AlternateText" :title="picture.Title"/>- </swiper-slide>- <div class="swiper-button-prev" slot="button-prev"></div>- <div class="swiper-button-next" slot="button-next"></div>- </swiper>- <swiper ref="QuickViewSliderThumbs"- :options="QuickViewSliderThumbs.swiperOptions"- class="thumbs">- <swiper-slide class="slide-wide" v-for="(picture, index) in PopupQuickViewVueModal.PictureModels">- <img @@click="vm.slideTo($event.target)" :data-index="index" class="img-thumb" :src="picture.ThumbImageUrl" :alt="picture.AlternateText" :title="picture.Title" :data-img="picture.ImageUrl"/>- </swiper-slide>- </swiper>- </div>- <div v-else class="product-picture">- <img :src="PopupQuickViewVueModal.DefaultPictureModel.ImageUrl" :alt="PopupQuickViewVueModal.DefaultPictureModel.AlternateText" :title="PopupQuickViewVueModal.DefaultPictureModel.Title" class="img-fluid" id="main_qv_img"/>- </div>- </div>- <div class="col-lg-7 col-12">- <div class="quick-view-overview">- <template v-if="PopupQuickViewVueModal.Breadcrumb.Enabled">- <div class="container px-0">- <ol class="breadcrumb pt-0 mb-3" itemscope="itemscope" itemtype="http://schema.org/BreadcrumbList">- <li class="breadcrumb-item" itemprop="itemListElement" itemscope="itemscope" itemtype="http://schema.org/ListItem">- <a href="@Url.RouteUrl("HomePage")" target="_self">- <b-icon icon="house-door" scale="1.25" shift-v="1.25" aria-hidden="true"></b-icon>- <span itemprop="name">@Loc["Products.Breadcrumb.Top"]</span>- <span itemprop="item" itemscope itemtype="http://schema.org/Thing"- id="@Url.RouteUrl("HomePage")">- </span>- <meta itemprop="position" content="1"/>- </a>- </li>- <template v-for="(category, index) in PopupQuickViewVueModal.Breadcrumb.CategoryBreadcrumb">- <li itemprop="itemListElement" itemscope="itemscope" itemtype="http://schema.org/ListItem" class="breadcrumb-item">- <a :href="category.SeName" target="_self">- <span itemprop="name">{{category.Name}}</span>- <span itemprop="item" itemscope itemtype="http://schema.org/Thing"- :id="category.SeName">- </span>- <meta itemprop="position" :content="index + 2"/>- </a>- </li>- </template>- <li itemprop="itemListElement" itemscope="itemscope" itemtype="http://schema.org/ListItem" class="breadcrumb-item active">- <strong class="current-item" itemprop="name">{{PopupQuickViewVueModal.Breadcrumb.ProductName}}</strong>- <span itemprop="item" itemscope itemtype="http://schema.org/Thing"- :id="'@productLink' + PopupQuickViewVueModal.SeName">- </span>- <meta itemprop="position" content="2"/>- </li>- </ol>- </div>- </template>- <h2 class="qv-title">- <a :href="'@productLink' + PopupQuickViewVueModal.SeName">- {{PopupQuickViewVueModal.Name}}- </a>- </h2>- <template v-if="PopupQuickViewVueModal.ProductReviewOverview.AllowCustomerReviews">- <div class="d-inline-flex align-items-center">- <b-form-rating :id="'rating-inline-overview-' + PopupQuickViewVueModal.Id" class="p-0" variant="warning" no-border size="sm" show-value precision="2" readonly inline :value="PopupQuickViewVueModal.ProductReviewOverview.RatingSum / PopupQuickViewVueModal.ProductReviewOverview.TotalReviews"></b-form-rating>- <span class="review-count">{{PopupQuickViewVueModal.ProductReviewOverview.TotalReviews}} @Loc["Reviews.Overview.Reviews"]</span>- </div>- </template>- <a class="modal-close" @@click="$bvModal.hide('ModalQuickView')">- <b-icon icon="x"></b-icon>- </a>- <template>- <div class="accordion" role="tablist">- <div role="tab">- <a v-b-toggle.accordion-qv-details class="btn btn-light collapse-button">- <span class="icons icon-info"></span>- <span>@Loc["products.details"]</span>- <b-icon icon="chevron-double-down"></b-icon>- </a>- </div>- <b-collapse class="collapse-panel" visible id="accordion-qv-details" accordion="accordion-qv-details" role="tabpanel">- <template v-if="PopupQuickViewVueModal.StockAvailability !== ''">- <div class="stock mb-3">- <label class="label col-form-label">@Loc["Products.Availability"]:</label>- <span class="value" :id="'stock-availability-value-' + PopupQuickViewVueModal.Id">- <link itemprop="availability" href="http://schema.org/InStock"/>- <template v-if="PopupQuickViewVueModal.StockAvailability !== ''">- {{PopupQuickViewVueModal.StockAvailability}}- </template>- <template v-else-if="PopupQuickViewVueModal.DisplayDiscontinuedMessage">- @Loc["Products.Discontinued"]- </template>- </span>- </div>- </template>- @* PRODUCT BUNDLES *@- <partial name="Partials/QuickView/ProductBundles"/>- @* ATTRIBUTES *@- <partial name="Partials/QuickView/Attributes"/>- <template v-if="PopupQuickViewVueModal.ProductAttributes.length > 0">- <div class="attributes">- <table class="table">- <template v-for="(attribute, index) in PopupQuickViewVueModal.ProductAttributes">- <product-attribute-quickview :ref="'QVattribute' + index" :attribute="attribute"></product-attribute-quickview>- </template>- </table>- </div>- </template>- <script asp-location="Footer" asp-order="302">+<template v-if="PopupQuickViewVueModal !== null">+<form method="post" id="product-details-form" :action="'/' + PopupQuickViewVueModal.SeName">+<div itemscope itemtype="http://schema.org/Product" :data-productid="PopupQuickViewVueModal.Id">+<div class="quick-view">+<div class="col-12 px-0">+<div class="form-row">+<div class="col-lg-5 col-12">+ <div v-if="PopupQuickViewVueModal.PictureModels.length > 1" class="product-gallery">+ <swiper ref="QuickViewSlider"+ :options="QuickViewSlider.swiperOptions">+ <swiper-slide class="slide-wide" v-for="picture in PopupQuickViewVueModal.PictureModels">+ <img class="img-fluid" :src="picture.ImageUrl" :data-srcs="picture.ImageUrl" :alt="picture.AlternateText" :title="picture.Title"/>+ </swiper-slide>+ <div class="swiper-button-prev" slot="button-prev"></div>+ <div class="swiper-button-next" slot="button-next"></div>+ </swiper>+ <swiper ref="QuickViewSliderThumbs"+ :options="QuickViewSliderThumbs.swiperOptions"+ class="thumbs">+ <swiper-slide class="slide-wide" v-for="(picture, index) in PopupQuickViewVueModal.PictureModels">+ <img @@click="vm.slideTo($event.target)" :data-index="index" class="img-thumb" :src="picture.ThumbImageUrl" :alt="picture.AlternateText" :title="picture.Title" :data-img="picture.ImageUrl"/>+ </swiper-slide>+ </swiper>+ </div>+ <div v-else class="product-picture">+ <img :src="PopupQuickViewVueModal.DefaultPictureModel.ImageUrl" :alt="PopupQuickViewVueModal.DefaultPictureModel.AlternateText" :title="PopupQuickViewVueModal.DefaultPictureModel.Title" class="img-fluid" id="main_qv_img"/>+ </div>+</div>+<div class="col-lg-7 col-12">+<div class="quick-view-overview">+<template v-if="PopupQuickViewVueModal.Breadcrumb.Enabled">+ <div class="container px-0">+ <ol class="breadcrumb pt-0 mb-3" itemscope="itemscope" itemtype="http://schema.org/BreadcrumbList">+ <li class="breadcrumb-item" itemprop="itemListElement" itemscope="itemscope" itemtype="http://schema.org/ListItem">+ <a href="@Url.RouteUrl("HomePage")" target="_self">+ <b-icon icon="house-door" scale="1.25" shift-v="1.25" aria-hidden="true"></b-icon>+ <span itemprop="name">@Loc["Products.Breadcrumb.Top"]</span>+ <span itemprop="item" itemscope itemtype="http://schema.org/Thing"+ id="@Url.RouteUrl("HomePage")">+ </span>+ <meta itemprop="position" content="1"/>+ </a>+ </li>+ <template v-for="(category, index) in PopupQuickViewVueModal.Breadcrumb.CategoryBreadcrumb">+ <li itemprop="itemListElement" itemscope="itemscope" itemtype="http://schema.org/ListItem" class="breadcrumb-item">+ <a :href="category.SeName" target="_self">+ <span itemprop="name">{{category.Name}}</span>+ <span itemprop="item" itemscope itemtype="http://schema.org/Thing"+ :id="category.SeName">+ </span>+ <meta itemprop="position" :content="index + 2"/>+ </a>+ </li>+ </template>+ <li itemprop="itemListElement" itemscope="itemscope" itemtype="http://schema.org/ListItem" class="breadcrumb-item active">+ <strong class="current-item" itemprop="name">{{PopupQuickViewVueModal.Breadcrumb.ProductName}}</strong>+ <span itemprop="item" itemscope itemtype="http://schema.org/Thing"+ :id="'@productLink' + PopupQuickViewVueModal.SeName">+ </span>+ <meta itemprop="position" content="2"/>+ </li>+ </ol>+ </div>+</template>+<h2 class="qv-title">+ <a :href="'@productLink' + PopupQuickViewVueModal.SeName">+ {{PopupQuickViewVueModal.Name}}+ </a>+</h2>+<template v-if="PopupQuickViewVueModal.ProductReviewOverview.AllowCustomerReviews">+ <div class="d-inline-flex align-items-center">+ <b-form-rating :id="'rating-inline-overview-' + PopupQuickViewVueModal.Id" class="p-0" variant="warning" no-border size="sm" show-value precision="2" readonly inline :value="PopupQuickViewVueModal.ProductReviewOverview.RatingSum / PopupQuickViewVueModal.ProductReviewOverview.TotalReviews"></b-form-rating>+ <span class="review-count">{{PopupQuickViewVueModal.ProductReviewOverview.TotalReviews}} @Loc["Reviews.Overview.Reviews"]</span>+ </div>+</template>+<a class="modal-close" @@click="$bvModal.hide('ModalQuickView')">+ <b-icon icon="x"></b-icon>+</a>+<template>+ <div class="accordion" role="tablist">+ <div role="tab">+ <a v-b-toggle.accordion-qv-details class="btn btn-light collapse-button">+ <span class="icons icon-info"></span>+ <span>@Loc["products.details"]</span>+ <b-icon icon="chevron-double-down"></b-icon>+ </a>+ </div>+ <b-collapse class="collapse-panel" visible id="accordion-qv-details" accordion="accordion-qv-details" role="tabpanel">+ <template v-if="PopupQuickViewVueModal.StockAvailability !== ''">+ <div class="stock mb-3">+ <label class="label col-form-label">@Loc["Products.Availability"]:</label>+ <span class="value" :id="'stock-availability-value-' + PopupQuickViewVueModal.Id">+ <link itemprop="availability" href="http://schema.org/InStock"/>+ <template v-if="PopupQuickViewVueModal.StockAvailability !== ''">+ {{PopupQuickViewVueModal.StockAvailability}}+ </template>+ <template v-else-if="PopupQuickViewVueModal.DisplayDiscontinuedMessage">+ @Loc["Products.Discontinued"]+ </template>+ </span>+ </div>+ </template>+ @* PRODUCT BUNDLES *@+ <partial name="Partials/QuickView/ProductBundles"/>+ @* ATTRIBUTES *@+ <partial name="Partials/QuickView/Attributes"/>+ <template v-if="PopupQuickViewVueModal.ProductAttributes.length > 0">+ <div class="attributes">+ <table class="table">+ <template v-for="(attribute, index) in PopupQuickViewVueModal.ProductAttributes">+ <product-attribute-quickview :ref="'QVattribute' + index" :attribute="attribute"></product-attribute-quickview>+ </template>+ </table>+ </div>+ </template>+ <script asp-location="Footer" asp-order="302">Vue.component('product-attribute-quickview', {template: '#product-attribute-quickview',props: {@@ -126,151 +126,151 @@ var productLink = Url.RouteUrl("Product");}});</script>- @* WAREHOUSES *@- <partial name="Partials/QuickView/Warehouses"/>- @* RESERVATIONS *@- <partial name="Partials/QuickView/ReservationInfo"/>- @* GIFT VOUCHERS *@- <partial name="Partials/QuickView/GiftVoucherInfo"/>- @* PRICES *@- <partial name="Partials/QuickView/Prices"/>- @* AUCTION *@- <partial name="Partials/QuickView/AuctionInfo"/>- @* ADD TO CART *@- <template v-if="PopupQuickViewVueModal.ProductType !== 10">- <partial name="Partials/QuickView/AddToCart"/>- <template v-if="(!PopupQuickViewVueModal.AddToCart.DisableWishlistButton || PopupQuickViewVueModal.CompareProductsEnabled || PopupQuickViewVueModal.EmailAFriendEnabled) && PopupQuickViewVueModal.AddToCart.UpdatedShoppingCartItemId == null">- <div class="btn-group mt-2 mb-3 w-100">- <partial name="Partials/QuickView/AddToWishlist"/>- <partial name="Partials/QuickView/ProductsComparison"/>- </div>- </template>- </template>- @* END OF ADD TO CART *@- </b-collapse>- <template v-if="PopupQuickViewVueModal.ProductSpecifications.length !== 0">- <div role="tab">- <a v-b-toggle.accordion-qv-spec class="btn btn-light collapse-button">- <span class="icons icon-speedometer"></span>- <span>@Loc["Products.Specs"]</span>- <b-icon icon="chevron-double-down"></b-icon>- </a>+ @* WAREHOUSES *@+ <partial name="Partials/QuickView/Warehouses"/>+ @* RESERVATIONS *@+ <partial name="Partials/QuickView/ReservationInfo"/>+ @* GIFT VOUCHERS *@+ <partial name="Partials/QuickView/GiftVoucherInfo"/>+ @* PRICES *@+ <partial name="Partials/QuickView/Prices"/>+ @* AUCTION *@+ <partial name="Partials/QuickView/AuctionInfo"/>+ @* ADD TO CART *@+ <template v-if="PopupQuickViewVueModal.ProductType !== 10">+ <partial name="Partials/QuickView/AddToCart"/>+ <template v-if="(!PopupQuickViewVueModal.AddToCart.DisableWishlistButton || PopupQuickViewVueModal.CompareProductsEnabled || PopupQuickViewVueModal.EmailAFriendEnabled) && PopupQuickViewVueModal.AddToCart.UpdatedShoppingCartItemId == null">+ <div class="btn-group mt-2 mb-3 w-100">+ <partial name="Partials/QuickView/AddToWishlist"/>+ <partial name="Partials/QuickView/ProductsComparison"/>+ </div>+ </template>+ </template>+ @* END OF ADD TO CART *@+ </b-collapse>+ <template v-if="PopupQuickViewVueModal.ProductSpecifications.length !== 0">+ <div role="tab">+ <a v-b-toggle.accordion-qv-spec class="btn btn-light collapse-button">+ <span class="icons icon-speedometer"></span>+ <span>@Loc["Products.Specs"]</span>+ <b-icon icon="chevron-double-down"></b-icon>+ </a>+ </div>+ <b-collapse class="collapse-panel" id="accordion-qv-spec" accordion="accordion-qv-spec" role="tabpanel">+ <div class="spec-container table-responsive">+ <table class="table data-table border-bottom-0">+ <colgroup>+ <col/>+ <col/>+ </colgroup>+ <tbody>+ <template v-for="item in PopupQuickViewVueModal.ProductSpecifications">+ <tr class="spec">+ <td class="border-bottom border-top-0">+ <div class="spec-name">+ {{item.SpecificationAttributeName}}</div>- <b-collapse class="collapse-panel" id="accordion-qv-spec" accordion="accordion-qv-spec" role="tabpanel">- <div class="spec-container table-responsive">- <table class="table data-table border-bottom-0">- <colgroup>- <col/>- <col/>- </colgroup>- <tbody>- <template v-for="item in PopupQuickViewVueModal.ProductSpecifications">- <tr class="spec">- <td class="border-bottom border-top-0">- <div class="spec-name">- {{item.SpecificationAttributeName}}- </div>- </td>- <td class="border-bottom border-top-0">- <div class="spec-value d-inline-flex w-100">- <template v-if="item.ColorSquaresRgb !== null">- <div class="color-squares mb-2 mr-2">- <span class="color-container" :title="item.ValueRaw">- <span class="color" v-bind:style="'background-color:' + item.ValueRaw"> </span>- </span>- </div>- </template>- <template v-else>- <div class="mb-2 mr-2" v-html="item.ValueRaw"></div>- </template>- </div>- </td>- </tr>- </template>- </tbody>- </table>- </div>- </b-collapse>- </template>- <template v-if="PopupQuickViewVueModal.ShortDescription !== null">- <div role="tab">- <a v-b-toggle.accordion-qv-desc class="btn btn-light collapse-button">- <span class="icons icon-book-open"></span>- <span>@Loc["Products.description"]</span>- <b-icon icon="chevron-double-down"></b-icon>- </a>+ </td>+ <td class="border-bottom border-top-0">+ <div class="spec-value d-inline-flex w-100">+ <template v-if="item.ColorSquaresRgb !== null">+ <div class="color-squares mb-2 mr-2">+ <span class="color-container" :title="item.ValueRaw">+ <span class="color" v-bind:style="'background-color:' + item.ValueRaw"> </span>+ </span>+ </div>+ </template>+ <template v-else>+ <div class="mb-2 mr-2" v-html="item.ValueRaw"></div>+ </template></div>- <b-collapse visible class="collapse-panel" id="accordion-qv-desc" accordion="accordion-qv-desc" role="tabpanel">- <div class="qv-description" v-html="PopupQuickViewVueModal.ShortDescription"></div>- </b-collapse>- </template>- @* ASSOCIATED PRODUCTS *@- <template v-if="PopupQuickViewVueModal.ProductType == 10">- <div role="tab">- <a v-b-toggle.accordion-qv-group class="btn btn-light collapse-button">- <span class="icons icon-list"></span>- <span>@Loc["admin.catalog.products.associatedproducts"]</span>- <b-icon icon="chevron-double-down"></b-icon>- </a>+ </td>+ </tr>+ </template>+ </tbody>+ </table>+ </div>+ </b-collapse>+ </template>+ <template v-if="PopupQuickViewVueModal.ShortDescription !== null">+ <div role="tab">+ <a v-b-toggle.accordion-qv-desc class="btn btn-light collapse-button">+ <span class="icons icon-book-open"></span>+ <span>@Loc["Products.description"]</span>+ <b-icon icon="chevron-double-down"></b-icon>+ </a>+ </div>+ <b-collapse visible class="collapse-panel" id="accordion-qv-desc" accordion="accordion-qv-desc" role="tabpanel">+ <div class="qv-description" v-html="PopupQuickViewVueModal.ShortDescription"></div>+ </b-collapse>+ </template>+ @* ASSOCIATED PRODUCTS *@+ <template v-if="PopupQuickViewVueModal.ProductType == 10">+ <div role="tab">+ <a v-b-toggle.accordion-qv-group class="btn btn-light collapse-button">+ <span class="icons icon-list"></span>+ <span>@Loc["admin.catalog.products.associatedproducts"]</span>+ <b-icon icon="chevron-double-down"></b-icon>+ </a>+ </div>+ <b-collapse visible class="collapse-panel" id="accordion-qv-group" accordion="accordion-qv-group" role="tabpanel">+ <template v-if="PopupQuickViewVueModal.AssociatedProducts.length > 0">+ <template v-for="variant in PopupQuickViewVueModal.AssociatedProducts">+ <div class="card overflow-hidden associatedItem mb-3">+ <div class="row" no-gutters>+ <div class="col-lg-3 col-md-4">+ <img :id="'main-product-img-' + variant.Id" :alt="variant.DefaultPictureModel.AlternateText" :src="variant.DefaultPictureModel.ImageUrl" class="rounded-0 img-fluid">+ </div>+ <div class="col-lg-9 col-md-8">+ <div class="card-body overview" :title="variant.Name">+ <!--short description-->+ <div v-if="variant.ShortDescription !== null" class="short-description mb-3" v-html="variant.ShortDescription"></div>+ <!--availability-->+ <template v-if="variant.StockAvailability !== null">+ <div class="stock">+ <label class="col-form-label">@Loc["Products.Availability"]:</label>+ <span class="value" :id="'stock-availability-value-' + variant.Id">+ <link itemprop="availability" href="http://schema.org/InStock"/>+ {{variant.StockAvailability}}+ </span>+ </div>+ </template>+ <!--attributes-->+ <template v-if="variant.ProductAttributes.length > 0">+ <div class="attributes">+ <table class="table">+ <template v-for="(attribute, index) in variant.ProductAttributes">+ <product-attribute-quickview :attribute="attribute"></product-attribute-quickview>+ </template>+ </table>+ </div>+ </template>+ <!--price & add to cart-->+ <partial name="Partials/QuickView/PricesGroup"/>+ <partial name="Partials/QuickView/AddToCartGroup"/></div>- <b-collapse visible class="collapse-panel" id="accordion-qv-group" accordion="accordion-qv-group" role="tabpanel">- <template v-if="PopupQuickViewVueModal.AssociatedProducts.length > 0">- <template v-for="variant in PopupQuickViewVueModal.AssociatedProducts">- <div class="card overflow-hidden associatedItem mb-3">- <div class="row" no-gutters>- <div class="col-lg-3 col-md-4">- <img :id="'main-product-img-' + variant.Id" :alt="variant.DefaultPictureModel.AlternateText" :src="variant.DefaultPictureModel.ImageUrl" class="rounded-0 img-fluid">- </div>- <div class="col-lg-9 col-md-8">- <div class="card-body overview" :title="variant.Name">- <!--short description-->- <div v-if="variant.ShortDescription !== null" class="short-description mb-3" v-html="variant.ShortDescription"></div>- <!--availability-->- <template v-if="variant.StockAvailability !== null">- <div class="stock">- <label class="col-form-label">@Loc["Products.Availability"]:</label>- <span class="value" :id="'stock-availability-value-' + variant.Id">- <link itemprop="availability" href="http://schema.org/InStock"/>- {{variant.StockAvailability}}- </span>- </div>- </template>- <!--attributes-->- <template v-if="variant.ProductAttributes.length > 0">- <div class="attributes">- <table class="table">- <template v-for="(attribute, index) in variant.ProductAttributes">- <product-attribute-quickview :attribute="attribute"></product-attribute-quickview>- </template>- </table>- </div>- </template>- <!--price & add to cart-->- <partial name="Partials/QuickView/PricesGroup"/>- <partial name="Partials/QuickView/AddToCartGroup"/>- </div>- </div>- </div>- </div>- </template>- </template>- <template v-else>- <div class="no-associated-products alert alert-info">- @Loc["Products.NoAssociatedProducts"]- </div>- </template>- </b-collapse>- </template>- @* END OF ASSOCIATED PRODUCTS *@- </div>- </template>+ </div>+ </div></div>- </div>- <partial name="Partials/QuickView/LinkedProducts"/>- </div>- </div>- </div>- </div>- </form>- </template>+ </template>+ </template>+ <template v-else>+ <div class="no-associated-products alert alert-info">+ @Loc["Products.NoAssociatedProducts"]+ </div>+ </template>+ </b-collapse>+ </template>+ @* END OF ASSOCIATED PRODUCTS *@+ </div>+</template>+</div>+</div>+<partial name="Partials/QuickView/LinkedProducts"/>+</div>+</div>+</div>+</div>+</form>+</template></b-modal>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/QuickView/AddToCart.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/QuickView/AddToCart.cshtmlindex 1a9ae0463..903afc332 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/QuickView/AddToCart.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/QuickView/AddToCart.cshtml@@ -3,13 +3,13 @@var updateitemcart = Url.RouteUrl("UpdateItemCart");}<template v-if="PopupQuickViewVueModal.AddToCart.UpdatedShoppingCartItemId !== null">- <input type="hidden" id="shoppingCartItemId" name="shoppingCartItemId" :value="UpdatedShoppingCartItemId" />+ <input type="hidden" id="shoppingCartItemId" name="shoppingCartItemId" :value="UpdatedShoppingCartItemId"/></template><template v-if="PopupQuickViewVueModal.AddToCart.EnteredPrice"><div class="customer-entered-price mb-3 d-flex w-100 flex-column"><div class="price-input"><label :for="'addtocart_' + PopupQuickViewVueModal.AddToCart.ProductId + '_CustomerEnteredPrice'" class="enter-price-label">@Loc["Products.EnterProductPrice"]</label>- <input :id="'addtocart_' + PopupQuickViewVueModal.AddToCart.ProductId + '_CustomerEnteredPrice'" :name="'CustomerEnteredPrice'" type="text" :value="PopupQuickViewVueModal.AddToCart.CustomerEnteredPrice" class="form-control enter-price-input" />+ <input :id="'addtocart_' + PopupQuickViewVueModal.AddToCart.ProductId + '_CustomerEnteredPrice'" :name="'CustomerEnteredPrice'" type="text" :value="PopupQuickViewVueModal.AddToCart.CustomerEnteredPrice" class="form-control enter-price-input"/></div><div class="price-range pt-1">{{PopupQuickViewVueModal.AddToCart.CustomerEnteredPriceRange}}@@ -36,7 +36,7 @@<div class="plus" @@click="vm.$refs.qtyqv.value ++"></div><div class="minus" @@click="vm.$refs.qtyqv.value --"></div></div>- <input ref="qtyqv" :value="PopupQuickViewVueModal.AddToCart.EnteredQuantity" :id="'addtocart_' + PopupQuickViewVueModal.AddToCart.ProductId + '_EnteredQuantity'" :name="'EnteredQuantity'" min="1" class="qty-input form-control text-center" type="number" inputmode="numeric" />+ <input ref="qtyqv" :value="PopupQuickViewVueModal.AddToCart.EnteredQuantity" :id="'addtocart_' + PopupQuickViewVueModal.AddToCart.ProductId + '_EnteredQuantity'" :name="'EnteredQuantity'" min="1" class="qty-input form-control text-center" type="number" inputmode="numeric"/><template v-if="PopupQuickViewVueModal.AddToCart.MeasureUnit !== ''"><span class="qty-unit d-flex align-items-center mr-2">{{PopupQuickViewVueModal.AddToCart.MeasureUnit}}diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/QuickView/Attributes.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/QuickView/Attributes.cshtmlindex 265640423..9e8c16376 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/QuickView/Attributes.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/QuickView/Attributes.cshtml@@ -15,7 +15,7 @@<td :id="'product_attribute_input_' + attribute.Id"><template v-if="attribute.AttributeControlType==4"><label :for="'product_attribute_' + attribute.Id" class="sr-only">product_attribute_{{attribute.Id}}</label>- <input :name="'attributes[' + attribute.Id+']'" type="text" class="form-control textbox" :id="'product_attribute_' + attribute.Id" :value="attribute.DefaultValue" @@change="vm.attrchange(attribute.ProductId, true)" />+ <input :name="'attributes[' + attribute.Id+']'" type="text" class="form-control textbox" :id="'product_attribute_' + attribute.Id" :value="attribute.DefaultValue" @@change="vm.attrchange(attribute.ProductId, true)"/></template><template v-if="attribute.AttributeControlType==1"><label :for="'product_attribute_' + attribute.Id" class="sr-only">product_attribute_{{attribute.Id}}</label>@@ -46,7 +46,7 @@:value="attributeValue.Id":checked="attributeValue.IsPreSelected":data-disable="attributeValue.Id"- @@change="vm.attrchange(attribute.ProductId, true)" />+ @@change="vm.attrchange(attribute.ProductId, true)"/><span class="custom-control-label"></span><span class="custom-control-description" :for="'product_attribute_' + attribute.Id + '_' + attributeValue.Id"><template v-if="attributeValue.PriceAdjustment==null">@@ -75,7 +75,7 @@:value="attributeValue.Id":checked="attributeValue.IsPreSelected"@@change="vm.attrchange(attribute.ProductId, true)"- disabled="disabled" />+ disabled="disabled"/><input v-elseclass="custom-control-input":id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id"@@ -84,7 +84,7 @@:value="attributeValue.Id":checked="attributeValue.IsPreSelected":data-disable="attributeValue.Id"- @@change="vm.attrchange(attribute.ProductId, true)" />+ @@change="vm.attrchange(attribute.ProductId, true)"/><span class="custom-control-label"></span><span class="custom-control-description" :for="'product_attribute_' + attribute.Id + '_' + attributeValue.Id"><template v-if="attributeValue.PriceAdjustment==null">@@ -110,7 +110,7 @@id="qqfile"name="qqfile":data-url="'@fileLink/' + attribute.Id + '?productId=' + attribute.ProductId"- @@change="vm.uploadFile($event.target)" />+ @@change="vm.uploadFile($event.target)"/></div></template><input class="hidden-upload-input"@@ -118,20 +118,26 @@:id="'product_attribute_' + attribute.Id":name="'attributes[' + attribute.Id+']'"v-model="attribute.DefaultValue"- :value="attribute.DefaultValue" />+ :value="attribute.DefaultValue"/><div id="download-message" class="alert my-2" style="display: none;"></div>- <div :id="'product_attribute_' + attribute.Id + 'downloadurl'" class="download-file" style="display: none;"><a class="btn btn-outline-info"> Download </a></div>+ <div :id="'product_attribute_' + attribute.Id + 'downloadurl'" class="download-file" style="display: none;">+ <a class="btn btn-outline-info"> Download </a>+ </div></template><template v-if="attribute.AttributeControlType==40"><ul class="option-list color-squares w-100 d-inline-flex flex-wrap px-0 mb-0" :id="'color-squares-' + attribute.Id"><li v-for="attributeValue in attribute.Values" class="mr-1 p-0"><label :for="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" class="mb-0">- <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :data-disable="attributeValue.Id" :checked="attributeValue.IsPreSelected" @@change="vm.attrchange(attribute.ProductId, true)" />+ <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :data-disable="attributeValue.Id" :checked="attributeValue.IsPreSelected" @@change="vm.attrchange(attribute.ProductId, true)"/><template v-if="attributeValue.PriceAdjustment==null">- <span class="color-container" :title="attributeValue.Name"> <span class="color" :style="'background-color:' + attributeValue.ColorSquaresRgb"></span> </span>+ <span class="color-container" :title="attributeValue.Name">+ <span class="color" :style="'background-color:' + attributeValue.ColorSquaresRgb"></span>+ </span></template><template v-else>- <span class="color-container" :title="attributeValue.Name + ' [' + attributeValue.PriceAdjustment + ']'"> <span class="color" :style="'background-color:' + attributeValue.ColorSquaresRgb"></span> </span>+ <span class="color-container" :title="attributeValue.Name + ' [' + attributeValue.PriceAdjustment + ']'">+ <span class="color" :style="'background-color:' + attributeValue.ColorSquaresRgb"></span>+ </span></template></label></li>@@ -142,20 +148,24 @@<li v-for="attributeValue in attribute.Values" class="mr-1 p-0"><label :for="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" class="mb-0"><template v-if="attributeValue.PriceAdjustment==null">- <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="vm.attrchange(attribute.ProductId, true)" />+ <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="vm.attrchange(attribute.ProductId, true)"/><span :id="'imgSqr_' + attributeValue.Id" class="color-container"><span class="color" :style="'background: url(' + attributeValue.ImageSquaresPictureModel.ImageUrl + ') 50% 50% no-repeat;'"></span></span><b-tooltip :target="'imgSqr_' + attributeValue.Id" placement="bottom">- <div class="image-square-tooltip"><img :src="attributeValue.ImageSquaresPictureModel.FullSizeImageUrl" :alt="attributeValue.Name" /> <span>{{attributeValue.Name}}</span></div>+ <div class="image-square-tooltip">+ <img :src="attributeValue.ImageSquaresPictureModel.FullSizeImageUrl" :alt="attributeValue.Name"/> <span>{{attributeValue.Name}}</span>+ </div></b-tooltip></template><template v-else>- <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="vm.attrchange(attribute.ProductId, true)" />- <span class="color-container"> <span class="color" :style="'background: url(' + attributeValue.ImageSquaresPictureModel.ImageUrl + ') 50% 50% no-repeat;'"></span> </span>+ <input :id="'product_attribute_' + attribute.Id + '_' + attributeValue.Id" type="radio" :name="'attributes[' + attribute.Id+']'" :value="attributeValue.Id" :checked="attributeValue.IsPreSelected" :data-disable="attributeValue.Id" @@change="vm.attrchange(attribute.ProductId, true)"/>+ <span class="color-container">+ <span class="color" :style="'background: url(' + attributeValue.ImageSquaresPictureModel.ImageUrl + ') 50% 50% no-repeat;'"></span>+ </span><b-tooltip :target="'imgSqr_' + attributeValue.Id" placement="bottom"><div class="image-square-tooltip">- <img :src="attributeValue.ImageSquaresPictureModel.FullSizeImageUrl" :alt="attributeValue.Name + ' [' + attributeValue.PriceAdjustment + ']'" />+ <img :src="attributeValue.ImageSquaresPictureModel.FullSizeImageUrl" :alt="attributeValue.Name + ' [' + attributeValue.PriceAdjustment + ']'"/><span>{{attributeValue.Name}}[{{attributeValue.PriceAdjustment}}]</span></div></b-tooltip>diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/QuickView/LinkedProducts.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/QuickView/LinkedProducts.cshtmlindex 869e9a65d..527a6e7fb 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/QuickView/LinkedProducts.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/QuickView/LinkedProducts.cshtml@@ -1,6 +1,8 @@<template v-if="RelatedProducts !== null"><div v-if="RelatedProducts.length > 0" class="related-products-grid linked-product-grid product-grid col-12 px-0">- <h2 class="h3 generalTitle text-center"><span>@Loc["Products.RelatedProducts"]</span></h2>+ <h2 class="h3 generalTitle text-center">+ <span>@Loc["Products.RelatedProducts"]</span>+ </h2><div class="item-row"><template :key="Model.Id" v-for="Model in RelatedProducts"><div class="col-xl-3 col-lg-4 col-md-4 col-sm-6 product-container mb-2">diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/QuickView/SendFriend.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/QuickView/SendFriend.cshtmlindex 67ba76e22..ebb0518dd 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/QuickView/SendFriend.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/QuickView/SendFriend.cshtml@@ -1,4 +1,4 @@-@{+@{var sendfriend = Url.RouteUrl("ProductEmailAFriend");}<template v-if="PopupQuickViewVueModal.EmailAFriendEnabled">@@ -6,4 +6,4 @@<span class="icons icon-envelope-letter"></span><span class="sr-only">@Loc["Products.EmailAFriend"]</span></a>-</template>+</template>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/ShoppingCartLinks.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/ShoppingCartLinks.cshtmlindex 645bcdeee..735c065f1 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/ShoppingCartLinks.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/ShoppingCartLinks.cshtml@@ -1,12 +1,13 @@-@inject IWorkContext workContext-@inject Grand.Business.Core.Interfaces.Common.Security.IPermissionService permissionService-@inject Grand.Business.Core.Interfaces.Checkout.Orders.IShoppingCartService shoppingCartService+@using Grand.Business.Core.Interfaces.Checkout.Orders+@using Grand.Business.Core.Interfaces.Common.Security+@using Grand.Business.Core.Utilities.Common.Security+@inject IWorkContext workContext+@inject IPermissionService permissionService+@inject IShoppingCartService shoppingCartService@inject ShoppingCartSettings shoppingCartSettings@inject CatalogSettings catalogSettings-@using Grand.Business.Core.Utilities.Common.Security@{-var shoppingCartTypes = new List<ShoppingCartType>();shoppingCartTypes.Add(ShoppingCartType.ShoppingCart);shoppingCartTypes.Add(ShoppingCartType.Auctions);@@ -17,18 +18,19 @@var wishlistEnabled = await permissionService.Authorize(StandardPermission.EnableWishlist);var miniShoppingCartEnabled = shoppingCartSettings.MiniShoppingCartEnabled;var shoppingCartItems =- workContext.CurrentCustomer.ShoppingCartItems.Any() ?- (await shoppingCartService.GetShoppingCart(workContext.CurrentStore.Id, shoppingCartTypes.ToArray()))- .Sum(x => x.Quantity) : 0;-- var wishlistItems = workContext.CurrentCustomer.ShoppingCartItems.Any() ?- (await shoppingCartService.GetShoppingCart(workContext.CurrentStore.Id, ShoppingCartType.Wishlist))- .Sum(x => x.Quantity) : 0;+ workContext.CurrentCustomer.ShoppingCartItems.Any()+ ? (await shoppingCartService.GetShoppingCart(workContext.CurrentStore.Id, shoppingCartTypes.ToArray()))+ .Sum(x => x.Quantity)+ : 0;+ var wishlistItems = workContext.CurrentCustomer.ShoppingCartItems.Any()+ ? (await shoppingCartService.GetShoppingCart(workContext.CurrentStore.Id, ShoppingCartType.Wishlist))+ .Sum(x => x.Quantity)+ : 0;}@if (catalogSettings.CompareProductsEnabled){- <partial name="Partials/SidebarCompareProducts" />+ <partial name="Partials/SidebarCompareProducts"/>}@if (wishlistEnabled || shoppingCartEnabled){@@ -36,9 +38,10 @@{if (wishlistEnabled){- <partial name="Partials/SidebarWishlist" model="wishlistItems" />+ <partial name="Partials/SidebarWishlist" model="wishlistItems"/>}- <partial name="Partials/SidebarShoppingCart" model="shoppingCartItems" />++ <partial name="Partials/SidebarShoppingCart" model="shoppingCartItems"/>}else{@@ -51,6 +54,7 @@</a></li>}+if (shoppingCartEnabled){<li class="nav-item">diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/SidebarCompareProducts.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/SidebarCompareProducts.cshtmlindex c8acb4bef..bc07297c4 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/SidebarCompareProducts.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/SidebarCompareProducts.cshtml@@ -23,7 +23,9 @@</a><div class="col"><a :href="product.Url">{{product.Name}}</a>- <div class="price"><span>@Loc["Wishlist.Mini.UnitPrice"]:</span> <strong>{{product.ProductPrice.Price}}</strong></div>+ <div class="price">+ <span>@Loc["Wishlist.Mini.UnitPrice"]:</span> <strong>{{product.ProductPrice.Price}}</strong>+ </div></div><div><a class="deleteitem" @@click="removeFromCompareList(product.Id); getCompareList('@Url.RouteUrl("CompareProducts")'); ">diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/SidebarShoppingCart.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/SidebarShoppingCart.cshtmlindex 90cfbbda9..b34a53b4b 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/SidebarShoppingCart.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/SidebarShoppingCart.cshtml@@ -36,8 +36,12 @@<div class="attributes p-2" v-if="item.AttributeInfo"><div v-html="item.AttributeInfo"></div></div>- <div class="price"><span>@Loc["ShoppingCart.Mini.UnitPrice"]:</span> <strong>{{item.UnitPrice}}</strong></div>- <div class="quantity"><span>@Loc["ShoppingCart.Mini.Quantity"]:</span> <strong>{{item.Quantity}}</strong></div>+ <div class="price">+ <span>@Loc["ShoppingCart.Mini.UnitPrice"]:</span> <strong>{{item.UnitPrice}}</strong>+ </div>+ <div class="quantity">+ <span>@Loc["ShoppingCart.Mini.Quantity"]:</span> <strong>{{item.Quantity}}</strong>+ </div></div><div><a class="deleteitem" @@click="deletecartitem('@Url.RouteUrl("DeleteCartItem")/'+ item.Id)">diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/SidebarWishlist.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/SidebarWishlist.cshtmlindex 2e651e7f5..cc9e49a1a 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/SidebarWishlist.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/Partials/SidebarWishlist.cshtml@@ -30,8 +30,12 @@<div class="attributes p-2" v-if="item.AttributeInfo"><div v-html="item.AttributeInfo"></div></div>- <div class="price"><span>@Loc["Wishlist.Mini.UnitPrice"]:</span> <strong>{{item.UnitPrice}}</strong></div>- <div class="quantity"><span>@Loc["Wishlist.Mini.Quantity"]:</span> <strong>{{item.Quantity}}</strong></div>+ <div class="price">+ <span>@Loc["Wishlist.Mini.UnitPrice"]:</span> <strong>{{item.UnitPrice}}</strong>+ </div>+ <div class="quantity">+ <span>@Loc["Wishlist.Mini.Quantity"]:</span> <strong>{{item.Quantity}}</strong>+ </div></b-col></div><template v-slot:footer v-if="wishindicator > 0">diff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/_Layout.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/_Layout.cshtmlindex 0316326f2..bbbc22238 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/_Layout.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/_Layout.cshtml@@ -4,93 +4,93 @@<title asp-default-title="true"></title><meta charset="utf-8"><meta-description>- <meta-keywords>- <meta name="generator" content="grandnode">- <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">- @await RenderSectionAsync("meta", required: false)- <head-custom>- <partial name="Head" />- <vc:widget widget-zone="head_html_tag" additional-data="null"></vc:widget>- <canonical-urls>- @*Favicon - upload favicon.ico file to the wwwroot directory*@- <partial name="Partials/Favicons" />- <resources asp-type="HeadLink" />- <resources asp-type="HeadScript" />- @await RenderSectionAsync("head", required: false)+ <meta-keywords>+ <meta name="generator" content="grandnode">+ <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">+ @await RenderSectionAsync("meta", false)+ <head-custom>+ <partial name="Head"/>+ <vc:widget widget-zone="head_html_tag" additional-data="null"></vc:widget>+ <canonical-urls>+ @*Favicon - upload favicon.ico file to the wwwroot directory*@+ <partial name="Partials/Favicons"/>+ <resources asp-type="HeadLink"/>+ <resources asp-type="HeadScript"/>+ @await RenderSectionAsync("head", false)</head><body>- <resources asp-type="ScriptHeader" />- @await Component.InvokeAsync("Widget", new { widgetZone = "body_start_html_tag_after" })+<resources asp-type="ScriptHeader"/>+@await Component.InvokeAsync("Widget", new { widgetZone = "body_start_html_tag_after" })- <div id="app" v-cloak>- <div class="page-loader-container">- <div class="page-loader"></div>- </div>- <partial name="Partials/Notifications" />- <vc:get-coordinate></vc:get-coordinate>- <b-container fluid class="main-container">- @await Component.InvokeAsync("Widget", new { widgetZone = "content_before" })- <div class="row">- <div class="left-side-container" v-bind:class="{ toggled : !menuToggled}">- <div class="container px-0">- <partial name="Header" />- <div class="header-nav-bottom">- <partial name="Partials/Logo" />- @await Component.InvokeAsync("SearchBox")- <ul class="navbar-nav top-header-items">- <template>- <li class="nav-item">- <a class="nav-link" v-b-toggle.sidebar-right>- <span class="icons icon-user"></span>- </a>- <template>- <b-sidebar id="sidebar-right" bg-variant="white" text-variant="standard" body-class="user-panel" title="@Loc["Account.MyAccount"]" right backdrop>- <partial name="Partials/HeaderLinks" />- </b-sidebar>- </template>- </li>- </template>- <partial name="Partials/ShoppingCartLinks" />- </ul>+<div id="app" v-cloak>+ <div class="page-loader-container">+ <div class="page-loader"></div>+ </div>+ <partial name="Partials/Notifications"/>+ <vc:get-coordinate></vc:get-coordinate>+ <b-container fluid class="main-container">+ @await Component.InvokeAsync("Widget", new { widgetZone = "content_before" })+ <div class="row">+ <div class="left-side-container" v-bind:class="{ toggled : !menuToggled}">+ <div class="container px-0">+ <partial name="Header"/>+ <div class="header-nav-bottom">+ <partial name="Partials/Logo"/>+ @await Component.InvokeAsync("SearchBox")+ <ul class="navbar-nav top-header-items">+ <template>+ <li class="nav-item">+ <a class="nav-link" v-b-toggle.sidebar-right>+ <span class="icons icon-user"></span>+ </a>+ <template>+ <b-sidebar id="sidebar-right" bg-variant="white" text-variant="standard" body-class="user-panel" title="@Loc["Account.MyAccount"]" right backdrop>+ <partial name="Partials/HeaderLinks"/>+ </b-sidebar>+ </template>+ </li>+ </template>+ <partial name="Partials/ShoppingCartLinks"/>+ </ul>+ </div>+ <div class="top-menu-container">+ <div id="menu-toggler" class="menu-toggler d-lg-none d-flex" @@click="openMenu($event.target, 'mainMenu')">+ <span></span>+ <span></span>+ <span></span></div>- <div class="top-menu-container">- <div id="menu-toggler" class="menu-toggler d-lg-none d-flex" @@click="openMenu($event.target, 'mainMenu')">+ <div id="menu-button" @@click="menuButton()" v-bind:class="{ show: menuToggled }" class="menu-button d-lg-flex d-none">+ <span class="icon"><span></span><span></span><span></span>- </div>- <div id="menu-button" @@click="menuButton()" v-bind:class="{ show: menuToggled }" class="menu-button d-lg-flex d-none">- <span class="icon">- <span></span>- <span></span>- <span></span>- </span>- <span class="title">@Loc["Categories"]</span>- </div>- <ul class="Menu -vertical" id="mainMenu">- @await Component.InvokeAsync("Menu")- </ul>- <ul id="links-container" class="p-0 mb-0"></ul>+ </span>+ <span class="title">@Loc["Categories"]</span></div>+ <ul class="Menu -vertical" id="mainMenu">+ @await Component.InvokeAsync("Menu")+ </ul>+ <ul id="links-container" class="p-0 mb-0"></ul></div></div>- <div class="container right-container">- @if (IsSectionDefined("Breadcrumb"))- {- @await RenderSectionAsync("Breadcrumb")- }- @RenderBody()- </div></div>- @await Component.InvokeAsync("Widget", new { widgetZone = "content_after" })- </b-container>- <div id="backdrop-menu" class="backdrop-menu"></div>- @await Component.InvokeAsync("Footer")- <partial name="Partials/Cookie" />- </div>- @await Component.InvokeAsync("Widget", new { widgetZone = "body_end_html_tag_before" })- <partial name="Partials/ProductBoxVue" />- <resources asp-type="ScriptFooter" />- <resources asp-type="TemplateFooter" />+ <div class="container right-container">+ @if (IsSectionDefined("Breadcrumb"))+ {+ @await RenderSectionAsync("Breadcrumb")+ }+ @RenderBody()+ </div>+ </div>+ @await Component.InvokeAsync("Widget", new { widgetZone = "content_after" })+ </b-container>+ <div id="backdrop-menu" class="backdrop-menu"></div>+ @await Component.InvokeAsync("Footer")+ <partial name="Partials/Cookie"/>+</div>+@await Component.InvokeAsync("Widget", new { widgetZone = "body_end_html_tag_before" })+<partial name="Partials/ProductBoxVue"/>+<resources asp-type="ScriptFooter"/>+<resources asp-type="TemplateFooter"/></body>-</html>+</html>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Shared/_TwoColumns.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Shared/_TwoColumns.cshtmlindex 1483e7a72..d53a58a1e 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Shared/_TwoColumns.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Shared/_TwoColumns.cshtml@@ -3,7 +3,7 @@<script asp-location="Footer" asp-order="300" asp-src="/Plugins/Theme.Modern/Content/script/parallax.min.js"></script>//current category ID- string currentCategoryId = "";+ var currentCategoryId = "";if (Url.ActionContext.RouteData.Values["controller"].ToString().Equals("catalog", StringComparison.OrdinalIgnoreCase) &&Url.ActionContext.RouteData.Values["action"].ToString().Equals("category", StringComparison.OrdinalIgnoreCase)){@@ -12,7 +12,7 @@//current collection ID- string currentCollectionId = "";+ var currentCollectionId = "";if (Url.ActionContext.RouteData.Values["controller"].ToString().Equals("catalog", StringComparison.OrdinalIgnoreCase) &&Url.ActionContext.RouteData.Values["action"].ToString().Equals("collection", StringComparison.OrdinalIgnoreCase)){@@ -21,7 +21,7 @@//current product ID- string currentProductId = "";+ var currentProductId = "";if (Url.ActionContext.RouteData.Values["controller"].ToString().Equals("product", StringComparison.OrdinalIgnoreCase) &&Url.ActionContext.RouteData.Values["action"].ToString().Equals("productdetails", StringComparison.OrdinalIgnoreCase)){@@ -34,13 +34,16 @@@await RenderSectionAsync("Breadcrumb")}}+@section meta {- @await RenderSectionAsync("meta", required: false)+ @await RenderSectionAsync("meta", false)}+@section head {- @await RenderSectionAsync("head", required: false)+ @await RenderSectionAsync("head", false)<script asp-location="Footer" asp-order="301" src="/Plugins/Theme.Modern/Content/script/catalog.js"></script>}+@if (!string.IsNullOrEmpty(currentCategoryId)){@await Component.InvokeAsync("Widget", new { widgetZone = "home_page_category", additionalData = Model.Id })@@ -51,7 +54,9 @@}<b-row id="TwoColumns" class="custom-container mt-3"><b-col xl="3" lg="4" md="6" sm="8" cols="9" class="generalLeftSide" onclick="StopPropagation(event)">- <div class="modal-close" onclick="closeLeftSide()"><b-icon icon="x"></b-icon></div>+ <div class="modal-close" onclick="closeLeftSide()">+ <b-icon icon="x"></b-icon>+ </div>@if (IsSectionDefined("left")){@await RenderSectionAsync("left")@@ -77,4 +82,4 @@@await Component.InvokeAsync("Widget", new { widgetZone = "main_column_after" })</b-col></b-row>-<partial name="Partials/ProductBoxListVue" />\ No newline at end of file+<partial name="Partials/ProductBoxListVue"/>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/ShoppingCart/Cart.cshtml b/src/Plugins/Theme.Modern/Views/Modern/ShoppingCart/Cart.cshtmlindex e6097c70a..25ad2b3d4 100644--- a/src/Plugins/Theme.Modern/Views/Modern/ShoppingCart/Cart.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/ShoppingCart/Cart.cshtml@@ -7,8 +7,10 @@pagebuilder.AddTitleParts(Loc["Title.ShoppingCart"]);}<div class="page shopping-cart-page">- <h2 class="generalTitle text-center mt-3"><div>@Loc["ShoppingCart"]</div></h2>+ <h2 class="generalTitle text-center mt-3">+ <div>@Loc["ShoppingCart"]</div>+ </h2><div class="page-body">- <partial name="Partials/CartSummary" model="Model" />+ <partial name="Partials/CartSummary" model="Model"/></div></div>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/Wishlist/Index.cshtml b/src/Plugins/Theme.Modern/Views/Modern/Wishlist/Index.cshtmlindex ee1bf9ef6..3c7c1e783 100644--- a/src/Plugins/Theme.Modern/Views/Modern/Wishlist/Index.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/Wishlist/Index.cshtml@@ -16,7 +16,7 @@}else{- @String.Format(Loc["Wishlist.WishlistOf"], Model.CustomerFullname)+ @string.Format(Loc["Wishlist.WishlistOf"], Model.CustomerFullname)}</div></h2>@@ -34,137 +34,142 @@<form asp-controller="Wishlist" asp-action="Index" method="post" id="wishlist-cart-form">@if (!Model.IsEditable && Model.Items.Any()){- <input type="hidden" asp-for="@Model.CustomerGuid" />+ <input type="hidden" asp-for="@Model.CustomerGuid"/>}<div class="shopping-cart-container"><div class="static-cart"><div id="wishlist-cart"><table id="cart-table" class="table b-table shopping-cart"><thead role="rowgroup">- <tr role="row">- <template v-if="vmwishlist.Model.ShowProductImages">+ <tr role="row">+ <template v-if="vmwishlist.Model.ShowProductImages">+ <th role="columnheader" scope="col" class="text-center">+ <div>@Loc["ShoppingCart.Image"]</div>+ </th>+ </template>+ <th role="columnheader" scope="col" class="text-center">+ <div>@Loc["ShoppingCart.Product(s)"]</div>+ </th>+ <th role="columnheader" scope="col" class="text-center">+ <div>@Loc["ShoppingCart.Quantity"]</div>+ </th>+ <th role="columnheader" scope="col" class="text-center">+ <div>@Loc["ShoppingCart.UnitPrice"]</div>+ </th>+ <th role="columnheader" scope="col" class="text-center">+ <div>@Loc["ShoppingCart.ItemTotal"]</div>+ </th>+ <template v-if="vmwishlist.Model.IsEditable || vmwishlist.Model.DisplayAddToCart">+ <template v-if="vmwishlist.Model.IsEditable"><th role="columnheader" scope="col" class="text-center">- <div>@Loc["ShoppingCart.Image"]</div>+ <div>@Loc["Remove"]</div></th></template>- <th role="columnheader" scope="col" class="text-center">- <div>@Loc["ShoppingCart.Product(s)"]</div>- </th>- <th role="columnheader" scope="col" class="text-center">- <div>@Loc["ShoppingCart.Quantity"]</div>- </th>- <th role="columnheader" scope="col" class="text-center">- <div>@Loc["ShoppingCart.UnitPrice"]</div>- </th>- <th role="columnheader" scope="col" class="text-center">- <div>@Loc["ShoppingCart.ItemTotal"]</div>- </th>- <template v-if="vmwishlist.Model.IsEditable || vmwishlist.Model.DisplayAddToCart">- <template v-if="vmwishlist.Model.IsEditable">- <th role="columnheader" scope="col" class="text-center">- <div>@Loc["Remove"]</div>- </th>- </template>- <template v-if="vmwishlist.Model.DisplayAddToCart">- <th role="columnheader" scope="col" class="text-center">- <div>@Loc["addToCart"]</div>- </th>- </template>+ <template v-if="vmwishlist.Model.DisplayAddToCart">+ <th role="columnheader" scope="col" class="text-center">+ <div>@Loc["addToCart"]</div>+ </th></template>- </tr>+ </template>+ </tr></thead><tbody role="rowgroup">- <template v-for="item in vmwishlist.Model.Items">- <tr role="row">- <template v-if="vmwishlist.Model.ShowProductImages">- <td role="cell" class="text-center">- <div>- <a :href="item.ProductUrl">- <img :alt="item.Picture.AlternateText" :src="item.Picture.ImageUrl" :title="item.Picture.Title" />- </a>- </div>- </td>- </template>+ <template v-for="item in vmwishlist.Model.Items">+ <tr role="row">+ <template v-if="vmwishlist.Model.ShowProductImages"><td role="cell" class="text-center">- <div class="d-inline-flex align-items-center">- <a :href="item.ProductUrl" class="product-name">- {{item.ProductName}}+ <div>+ <a :href="item.ProductUrl">+ <img :alt="item.Picture.AlternateText" :src="item.Picture.ImageUrl" :title="item.Picture.Title"/></a>- <div v-if="vmwishlist.Model.IsEditable && item.AllowItemEditing" class="edit-item">- <a class="btn btn-link" @@click="vmwishlist.getItemCart(item.Id)"><b-icon icon="pencil"></b-icon></a>- </div></div>- <template v-if="vmwishlist.Model.ShowSku && item.Sku !== null">- <span class="sku-number">{{item.Sku}}</span>- </template>- <template v-if="item.AttributeInfo !== ''">- <div class="attributes small" v-html="item.AttributeInfo"></div>- </template>- <template v-if="item.Warnings.length > 0">- <div class="warnings message-error small alert alert-danger mt-2 mb-0">- <ul class="mb-0 p-0">- <template v-for="warning in item.Warnings">- <li>{{warning}}</li>- </template>- </ul>- </div>- </template>- <template v-if="item.RecurringInfo !== null">- <div class="recurring-info" v-html="item.RecurringInfo"></div>- </template></td>- <template v-if="vmwishlist.Model.IsEditable">- <td role="cell" class="text-center">- <template v-if="item.AllowedQuantities[0]">- <select :id="'itemquantity' + item.Id" :name="'itemquantity' + item.Id" class="custom-select form-control qty-dropdown" v-on:change="vmwishlist.updateQuantity('itemquantity', item.Id)">- <template v-for="qty in item.AllowedQuantities">- <option :id="'itemqty' + item.Id" :selected="qty.Selected" :value="qty.Value">{{qty.Value}}</option>- </template>- </select>- </template>- <template v-else>- <input :id="'itemquantity' + item.Id" :name="'itemquantity' + item.Id" type="number" v-model="item.Quantity" min="1" v-on:change="vmwishlist.updateQuantity('itemquantity', item.Id)" class="qty-input form-control text-center" />- </template>- </td>+ </template>+ <td role="cell" class="text-center">+ <div class="d-inline-flex align-items-center">+ <a :href="item.ProductUrl" class="product-name">+ {{item.ProductName}}+ </a>+ <div v-if="vmwishlist.Model.IsEditable && item.AllowItemEditing" class="edit-item">+ <a class="btn btn-link" @@click="vmwishlist.getItemCart(item.Id)">+ <b-icon icon="pencil"></b-icon>+ </a>+ </div>+ </div>+ <template v-if="vmwishlist.Model.ShowSku && item.Sku !== null">+ <span class="sku-number">{{item.Sku}}</span></template>- <template v-else>- <td role="cell" class="text-center">- <input :id="'itemquantity' + item.Id" :name="'itemquantity' + item.Id" type="text" :value="item.Quantity" class="qty-input-ro form-control text-center" readonly />- </td>+ <template v-if="item.AttributeInfo !== ''">+ <div class="attributes small" v-html="item.AttributeInfo"></div>+ </template>+ <template v-if="item.Warnings.length > 0">+ <div class="warnings message-error small alert alert-danger mt-2 mb-0">+ <ul class="mb-0 p-0">+ <template v-for="warning in item.Warnings">+ <li>{{warning}}</li>+ </template>+ </ul>+ </div>+ </template>+ <template v-if="item.RecurringInfo !== null">+ <div class="recurring-info" v-html="item.RecurringInfo"></div></template>+ </td>+ <template v-if="vmwishlist.Model.IsEditable"><td role="cell" class="text-center">- <span class="product-unit-price price">{{item.UnitPrice}}</span>+ <template v-if="item.AllowedQuantities[0]">+ <select :id="'itemquantity' + item.Id" :name="'itemquantity' + item.Id" class="custom-select form-control qty-dropdown" v-on:change="vmwishlist.updateQuantity('itemquantity', item.Id)">+ <template v-for="qty in item.AllowedQuantities">+ <option :id="'itemqty' + item.Id" :selected="qty.Selected" :value="qty.Value">{{qty.Value}}</option>+ </template>+ </select>+ </template>+ <template v-else>+ <input :id="'itemquantity' + item.Id" :name="'itemquantity' + item.Id" type="number" v-model="item.Quantity" min="1" v-on:change="vmwishlist.updateQuantity('itemquantity', item.Id)" class="qty-input form-control text-center"/>+ </template>+ </td>+ </template>+ <template v-else>+ <td role="cell" class="text-center">+ <input :id="'itemquantity' + item.Id" :name="'itemquantity' + item.Id" type="text" :value="item.Quantity" class="qty-input-ro form-control text-center" readonly/></td>- <template v-if="item.Discount !== null">- <td role="cell" class="text-center">- <div class="d-flex flex-column">- <p class="mb-0 prod-total">{{item.SubTotal}}</p><div class="discount text-success text-center"><span>@Loc["ShoppingCart.ItemYouSave"]: </span><span>{{item.Discount}}</span></div>+ </template>+ <td role="cell" class="text-center">+ <span class="product-unit-price price">{{item.UnitPrice}}</span>+ </td>+ <template v-if="item.Discount !== null">+ <td role="cell" class="text-center">+ <div class="d-flex flex-column">+ <p class="mb-0 prod-total">{{item.SubTotal}}</p>+ <div class="discount text-success text-center">+ <span>@Loc["ShoppingCart.ItemYouSave"]: </span><span>{{item.Discount}}</span></div>+ </div>+ </td>+ </template>+ <template v-else>+ <td role="cell" class="text-center">+ <p class="mb-0 prod-total">{{item.SubTotal}}</p>+ </td>+ </template>+ <template v-if="vmwishlist.Model.IsEditable || vmwishlist.Model.DisplayAddToCart">+ <template v-if="vmwishlist.Model.IsEditable">+ <td>+ <b-button variant="link" @@click="vmwishlist.deleteFromWishlist(item.Id)">+ <b-icon icon="trash" font-scale="1.5" class="text-danger"></b-icon>+ </b-button></td></template>- <template v-else>- <td role="cell" class="text-center">- <p class="mb-0 prod-total">{{item.SubTotal}}</p>+ <template v-if="vmwishlist.Model.DisplayAddToCart">+ <td>+ <b-button variant="link" @@click="vmwishlist.addToCartFromWishlist(item.Id)">+ <b-icon icon="cart" font-scale="1.5" class="text-info"></b-icon>+ </b-button></td></template>- <template v-if="vmwishlist.Model.IsEditable || vmwishlist.Model.DisplayAddToCart">- <template v-if="vmwishlist.Model.IsEditable">- <td>- <b-button variant="link" @@click="vmwishlist.deleteFromWishlist(item.Id)">- <b-icon icon="trash" font-scale="1.5" class="text-danger"></b-icon>- </b-button>- </td>- </template>- <template v-if="vmwishlist.Model.DisplayAddToCart">- <td>- <b-button variant="link" @@click="vmwishlist.addToCartFromWishlist(item.Id)">- <b-icon icon="cart" font-scale="1.5" class="text-info"></b-icon>- </b-button>- </td>- </template>- </template>- </tr>- </template>+ </template>+ </tr>+ </template></tbody></table></div>@@ -195,6 +200,6 @@</div>@if (Model.IsEditable && Model.Items.Any()){- @await Component.InvokeAsync("EmailWishlist")+ @await Component.InvokeAsync("EmailWishlist")}-<partial name="Partials/ModelScript" model="Model" />\ No newline at end of file+<partial name="Partials/ModelScript" model="Model"/>\ No newline at end of filediff --git a/src/Plugins/Theme.Modern/Views/Modern/_ViewImports.cshtml b/src/Plugins/Theme.Modern/Views/Modern/_ViewImports.cshtmlindex 916813e59..f0d7501cb 100644--- a/src/Plugins/Theme.Modern/Views/Modern/_ViewImports.cshtml+++ b/src/Plugins/Theme.Modern/Views/Modern/_ViewImports.cshtml@@ -39,5 +39,6 @@@using Grand.Domain.Seo@using Grand.Domain.Stores@using Grand.Infrastructure+@using Grand.Web.Common.Localization-@inject Grand.Web.Common.Localization.LocService Loc+@inject LocService Loc\ No newline at end of filediff --git a/src/Plugins/Widgets.FacebookPixel/Areas/Admin/Controllers/WidgetsFacebookPixelController.cs b/src/Plugins/Widgets.FacebookPixel/Areas/Admin/Controllers/WidgetsFacebookPixelController.csindex a664eb168..6c2ca1a38 100644--- a/src/Plugins/Widgets.FacebookPixel/Areas/Admin/Controllers/WidgetsFacebookPixelController.cs+++ b/src/Plugins/Widgets.FacebookPixel/Areas/Admin/Controllers/WidgetsFacebookPixelController.cs@@ -11,80 +11,82 @@ using Grand.Web.Common.Security.Authorization;using Microsoft.AspNetCore.Mvc;using Widgets.FacebookPixel.Models;-namespace Widgets.FacebookPixel.Areas.Admin.Controllers+namespace Widgets.FacebookPixel.Areas.Admin.Controllers;++[PermissionAuthorize(PermissionSystemName.Widgets)]+public class WidgetsFacebookPixelController : BaseAdminPluginController{- [PermissionAuthorize(PermissionSystemName.Widgets)]- public class WidgetsFacebookPixelController : BaseAdminPluginController+ private readonly ISettingService _settingService;+ private readonly IStoreService _storeService;+ private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;++ public WidgetsFacebookPixelController(IWorkContext workContext,+ IStoreService storeService,+ ISettingService settingService,+ ITranslationService translationService){- private readonly IWorkContext _workContext;- private readonly IStoreService _storeService;- private readonly ISettingService _settingService;- private readonly ITranslationService _translationService;+ _workContext = workContext;+ _storeService = storeService;+ _settingService = settingService;+ _translationService = translationService;+ }- public WidgetsFacebookPixelController(IWorkContext workContext,- IStoreService storeService,- ISettingService settingService,- ITranslationService translationService)- {- _workContext = workContext;- _storeService = storeService;- _settingService = settingService;- _translationService = translationService;- }- protected virtual async Task<string> GetActiveStore(IStoreService storeService, IWorkContext workContext)- {- var stores = await storeService.GetAllStores();- if (stores.Count < 2)- return stores.FirstOrDefault()!.Id;+ protected virtual async Task<string> GetActiveStore(IStoreService storeService, IWorkContext workContext)+ {+ var stores = await storeService.GetAllStores();+ if (stores.Count < 2)+ return stores.FirstOrDefault()!.Id;- var storeId = workContext.CurrentCustomer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.AdminAreaStoreScopeConfiguration);- var store = await storeService.GetStoreById(storeId);+ var storeId =+ workContext.CurrentCustomer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames+ .AdminAreaStoreScopeConfiguration);+ var store = await storeService.GetStoreById(storeId);- return store != null ? store.Id : "";- }- [AuthorizeAdmin]- public async Task<IActionResult> Configure()- {- //load settings for a chosen store scope- var storeScope = await GetActiveStore(_storeService, _workContext);- var facebookPixelSettings = _settingService.LoadSetting<FacebookPixelSettings>(storeScope);- var model = new ConfigurationModel {- PixelId = facebookPixelSettings.PixelId,- PixelScript = facebookPixelSettings.PixelScript,- AddToCartScript = facebookPixelSettings.AddToCartScript,- DetailsOrderScript = facebookPixelSettings.DetailsOrderScript,- AllowToDisableConsentCookie = facebookPixelSettings.AllowToDisableConsentCookie,- ConsentName = facebookPixelSettings.ConsentName,- ConsentDescription = facebookPixelSettings.ConsentDescription,- ConsentDefaultState = facebookPixelSettings.ConsentDefaultState- };+ return store != null ? store.Id : "";+ }- return View(model);- }+ [AuthorizeAdmin]+ public async Task<IActionResult> Configure()+ {+ //load settings for a chosen store scope+ var storeScope = await GetActiveStore(_storeService, _workContext);+ var facebookPixelSettings = _settingService.LoadSetting<FacebookPixelSettings>(storeScope);+ var model = new ConfigurationModel {+ PixelId = facebookPixelSettings.PixelId,+ PixelScript = facebookPixelSettings.PixelScript,+ AddToCartScript = facebookPixelSettings.AddToCartScript,+ DetailsOrderScript = facebookPixelSettings.DetailsOrderScript,+ AllowToDisableConsentCookie = facebookPixelSettings.AllowToDisableConsentCookie,+ ConsentName = facebookPixelSettings.ConsentName,+ ConsentDescription = facebookPixelSettings.ConsentDescription,+ ConsentDefaultState = facebookPixelSettings.ConsentDefaultState+ };- [HttpPost]- [AuthorizeAdmin]- public async Task<IActionResult> Configure(ConfigurationModel model)- {- //load settings for a chosen store scope- var storeScope = await GetActiveStore(_storeService, _workContext);- var facebookPixelSettings = _settingService.LoadSetting<FacebookPixelSettings>(storeScope);- facebookPixelSettings.PixelId = model.PixelId;- facebookPixelSettings.PixelScript = model.PixelScript;- facebookPixelSettings.AddToCartScript = model.AddToCartScript;- facebookPixelSettings.DetailsOrderScript = model.DetailsOrderScript;- facebookPixelSettings.AllowToDisableConsentCookie = model.AllowToDisableConsentCookie;- facebookPixelSettings.ConsentName = model.ConsentName;- facebookPixelSettings.ConsentDescription = model.ConsentDescription;- facebookPixelSettings.ConsentDefaultState = model.ConsentDefaultState;+ return View(model);+ }- await _settingService.SaveSetting(facebookPixelSettings, storeScope);+ [HttpPost]+ [AuthorizeAdmin]+ public async Task<IActionResult> Configure(ConfigurationModel model)+ {+ //load settings for a chosen store scope+ var storeScope = await GetActiveStore(_storeService, _workContext);+ var facebookPixelSettings = _settingService.LoadSetting<FacebookPixelSettings>(storeScope);+ facebookPixelSettings.PixelId = model.PixelId;+ facebookPixelSettings.PixelScript = model.PixelScript;+ facebookPixelSettings.AddToCartScript = model.AddToCartScript;+ facebookPixelSettings.DetailsOrderScript = model.DetailsOrderScript;+ facebookPixelSettings.AllowToDisableConsentCookie = model.AllowToDisableConsentCookie;+ facebookPixelSettings.ConsentName = model.ConsentName;+ facebookPixelSettings.ConsentDescription = model.ConsentDescription;+ facebookPixelSettings.ConsentDefaultState = model.ConsentDefaultState;- //now clear settings cache- await _settingService.ClearCache();- Success(_translationService.GetResource("Admin.Plugins.Saved"));- return await Configure();- }+ await _settingService.SaveSetting(facebookPixelSettings, storeScope);+ //now clear settings cache+ await _settingService.ClearCache();+ Success(_translationService.GetResource("Admin.Plugins.Saved"));+ return await Configure();}}\ No newline at end of filediff --git a/src/Plugins/Widgets.FacebookPixel/Areas/Admin/Views/WidgetsFacebookPixel/Configure.cshtml b/src/Plugins/Widgets.FacebookPixel/Areas/Admin/Views/WidgetsFacebookPixel/Configure.cshtmlindex 1a25f5941..171eb5c96 100644--- a/src/Plugins/Widgets.FacebookPixel/Areas/Admin/Views/WidgetsFacebookPixel/Configure.cshtml+++ b/src/Plugins/Widgets.FacebookPixel/Areas/Admin/Views/WidgetsFacebookPixel/Configure.cshtml@@ -21,16 +21,16 @@</div><div class="form-group"><div class="col-md-4 col-sm-4 text-right">- <admin-label asp-for="PixelId" class="control-label" />+ <admin-label asp-for="PixelId" class="control-label"/></div><div class="col-md-8 col-sm-8">- <admin-input asp-for="PixelId" />+ <admin-input asp-for="PixelId"/><span asp-validation-for="PixelId"></span></div></div><div class="form-group"><div class="col-md-4 col-sm-4 text-right">- <admin-label asp-for="PixelScript" class="control-label" />+ <admin-label asp-for="PixelScript" class="control-label"/></div><div class="col-md-8 col-sm-8"><admin-textarea asp-for="PixelScript"></admin-textarea>@@ -39,7 +39,7 @@</div><div class="form-group"><div class="col-md-4 col-sm-4 text-right">- <admin-label asp-for="AddToCartScript" class="control-label" />+ <admin-label asp-for="AddToCartScript" class="control-label"/></div><div class="col-md-8 col-sm-8"><admin-textarea asp-for="AddToCartScript"></admin-textarea>@@ -48,7 +48,7 @@</div><div class="form-group"><div class="col-md-4 col-sm-4 text-right">- <admin-label asp-for="DetailsOrderScript" class="control-label" />+ <admin-label asp-for="DetailsOrderScript" class="control-label"/></div><div class="col-md-8 col-sm-8"><admin-textarea asp-for="DetailsOrderScript"></admin-textarea>@@ -57,11 +57,11 @@</div><div class="form-group"><div class="col-md-4 col-sm-4 text-right">- <admin-label asp-for="AllowToDisableConsentCookie" class="control-label" />+ <admin-label asp-for="AllowToDisableConsentCookie" class="control-label"/></div><div class="col-md-8 col-sm-8"><label class="mt-checkbox mt-checkbox-outline control control-checkbox">- <admin-input asp-for="AllowToDisableConsentCookie" />+ <admin-input asp-for="AllowToDisableConsentCookie"/><div class="control__indicator"></div></label><span asp-validation-for="AllowToDisableConsentCookie"></span>@@ -69,11 +69,11 @@</div><div class="form-group"><div class="col-md-4 col-sm-4 text-right">- <admin-label asp-for="ConsentDefaultState" class="control-label" />+ <admin-label asp-for="ConsentDefaultState" class="control-label"/></div><div class="col-md-8 col-sm-8"><label class="mt-checkbox mt-checkbox-outline control control-checkbox">- <admin-input asp-for="ConsentDefaultState" />+ <admin-input asp-for="ConsentDefaultState"/><div class="control__indicator"></div></label><span asp-validation-for="ConsentDefaultState"></span>@@ -81,7 +81,7 @@</div><div class="form-group"><div class="col-md-4 col-sm-4 text-right">- <admin-label asp-for="ConsentName" class="control-label" />+ <admin-label asp-for="ConsentName" class="control-label"/></div><div class="col-md-8 col-sm-8"><admin-textarea asp-for="ConsentName"></admin-textarea>@@ -90,7 +90,7 @@</div><div class="form-group"><div class="col-md-4 col-sm-4 text-right">- <admin-label asp-for="ConsentDescription" class="control-label" />+ <admin-label asp-for="ConsentDescription" class="control-label"/></div><div class="col-md-8 col-sm-8"><admin-textarea asp-for="ConsentDescription"></admin-textarea>@@ -100,8 +100,8 @@</div><div class="form-actions"><div class="offset-md-3 offset-sm-3 col-md-9 col-sm-9">- <input type="submit" name="save" class="btn green" value="@Loc["Admin.Common.Save"]" />+ <input type="submit" name="save" class="btn green" value="@Loc["Admin.Common.Save"]"/></div></div></div>-</form>+</form>\ No newline at end of filediff --git a/src/Plugins/Widgets.FacebookPixel/Areas/Admin/Views/_ViewImports.cshtml b/src/Plugins/Widgets.FacebookPixel/Areas/Admin/Views/_ViewImports.cshtmlindex 0a765b55a..52adbfe6d 100644--- a/src/Plugins/Widgets.FacebookPixel/Areas/Admin/Views/_ViewImports.cshtml+++ b/src/Plugins/Widgets.FacebookPixel/Areas/Admin/Views/_ViewImports.cshtml@@ -5,5 +5,6 @@@using Microsoft.AspNetCore.Mvc.ViewFeatures@using Grand.Infrastructure.Extensions@using Grand.Web.Common+@using Grand.Web.Common.Localization-@inject Grand.Web.Common.Localization.LocService Loc+@inject LocService Loc\ No newline at end of filediff --git a/src/Plugins/Widgets.FacebookPixel/Components/WidgetsFacebookPixelViewComponent.cs b/src/Plugins/Widgets.FacebookPixel/Components/WidgetsFacebookPixelViewComponent.csindex 59c7e6adc..322e382a2 100644--- a/src/Plugins/Widgets.FacebookPixel/Components/WidgetsFacebookPixelViewComponent.cs+++ b/src/Plugins/Widgets.FacebookPixel/Components/WidgetsFacebookPixelViewComponent.cs@@ -6,93 +6,90 @@ using System.Globalization;using System.Text.Json;using Widgets.FacebookPixel.Models;-namespace Widgets.FacebookPixel.Components+namespace Widgets.FacebookPixel.Components;++[ViewComponent(Name = "WidgetsFacebookPixel")]+public class WidgetsFacebookPixelViewComponent : ViewComponent{- [ViewComponent(Name = "WidgetsFacebookPixel")]- public class WidgetsFacebookPixelViewComponent : ViewComponent+ private readonly ICookiePreference _cookiePreference;+ private readonly FacebookPixelSettings _facebookPixelSettings;+ private readonly IOrderService _orderService;+ private readonly IWorkContext _workContext;++ public WidgetsFacebookPixelViewComponent(+ IWorkContext workContext,+ IOrderService orderService,+ ICookiePreference cookiePreference,+ FacebookPixelSettings facebookPixelSettings+ ){- private readonly IWorkContext _workContext;- private readonly IOrderService _orderService;- private readonly ICookiePreference _cookiePreference;- private readonly FacebookPixelSettings _facebookPixelSettings;+ _workContext = workContext;+ _orderService = orderService;+ _cookiePreference = cookiePreference;+ _facebookPixelSettings = facebookPixelSettings;+ }- public WidgetsFacebookPixelViewComponent(- IWorkContext workContext,- IOrderService orderService,- ICookiePreference cookiePreference,- FacebookPixelSettings facebookPixelSettings- )+ public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData = null)+ {+ if (_facebookPixelSettings.AllowToDisableConsentCookie){- _workContext = workContext;- _orderService = orderService;- _cookiePreference = cookiePreference;- _facebookPixelSettings = facebookPixelSettings;+ var enabled = await _cookiePreference.IsEnable(_workContext.CurrentCustomer, _workContext.CurrentStore,+ FacebookPixelDefaults.ConsentCookieSystemName);+ if ((enabled.HasValue && !enabled.Value) ||+ (!enabled.HasValue && !_facebookPixelSettings.ConsentDefaultState))+ return Content("");}- public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData = null)+ //page+ if (widgetZone == FacebookPixelDefaults.Page) return View("Default", GetTrackingScript());+ //add to cart+ if (widgetZone == FacebookPixelDefaults.AddToCart){-- if (_facebookPixelSettings.AllowToDisableConsentCookie)- {- var enabled = await _cookiePreference.IsEnable(_workContext.CurrentCustomer, _workContext.CurrentStore, FacebookPixelDefaults.ConsentCookieSystemName);- if ((enabled.HasValue && !enabled.Value) || (!enabled.HasValue && !_facebookPixelSettings.ConsentDefaultState))- return Content("");- }- //page- if (widgetZone == FacebookPixelDefaults.Page)- {- return View("Default", GetTrackingScript());- }- //add to cart- if (widgetZone == FacebookPixelDefaults.AddToCart)- {- var model = JsonSerializer.Deserialize<FacebookAddToCartModelModel>(JsonSerializer.Serialize(additionalData));- if (model != null)- {- return View("Default", GetAddToCartScript(model));- }- }- //order details- if (widgetZone == FacebookPixelDefaults.OrderDetails)- {- var orderId = additionalData as string;- if (!string.IsNullOrEmpty(orderId))- {- return View("Default", await GetOrderScript(orderId));- }-- }- return Content("");+ var model =+ JsonSerializer.Deserialize<FacebookAddToCartModelModel>(JsonSerializer.Serialize(additionalData));+ if (model != null) return View("Default", GetAddToCartScript(model));}- private string GetTrackingScript()+ //order details+ if (widgetZone == FacebookPixelDefaults.OrderDetails){- var trackingScript = _facebookPixelSettings.PixelScript + "\n";- trackingScript = trackingScript.Replace("{PIXELID}", _facebookPixelSettings.PixelId);- return trackingScript;+ var orderId = additionalData as string;+ if (!string.IsNullOrEmpty(orderId)) return View("Default", await GetOrderScript(orderId));}- private string GetAddToCartScript(FacebookAddToCartModelModel model)- {- var trackingScript = _facebookPixelSettings.AddToCartScript + "\n";- trackingScript = trackingScript.Replace("{PRODUCTID}", model.ProductId);- trackingScript = trackingScript.Replace("{PRODUCTNAME}", model.ProductName);- trackingScript = trackingScript.Replace("{QTY}", model.Quantity.ToString("N0"));- trackingScript = trackingScript.Replace("{AMOUNT}", model.DecimalPrice.ToString("F2", CultureInfo.InvariantCulture));- trackingScript = trackingScript.Replace("{CURRENCY}", _workContext.WorkingCurrency.CurrencyCode);- return trackingScript;- }+ return Content("");+ }- private async Task<string> GetOrderScript(string orderId)+ private string GetTrackingScript()+ {+ var trackingScript = _facebookPixelSettings.PixelScript + "\n";+ trackingScript = trackingScript.Replace("{PIXELID}", _facebookPixelSettings.PixelId);+ return trackingScript;+ }++ private string GetAddToCartScript(FacebookAddToCartModelModel model)+ {+ var trackingScript = _facebookPixelSettings.AddToCartScript + "\n";+ trackingScript = trackingScript.Replace("{PRODUCTID}", model.ProductId);+ trackingScript = trackingScript.Replace("{PRODUCTNAME}", model.ProductName);+ trackingScript = trackingScript.Replace("{QTY}", model.Quantity.ToString("N0"));+ trackingScript =+ trackingScript.Replace("{AMOUNT}", model.DecimalPrice.ToString("F2", CultureInfo.InvariantCulture));+ trackingScript = trackingScript.Replace("{CURRENCY}", _workContext.WorkingCurrency.CurrencyCode);+ return trackingScript;+ }++ private async Task<string> GetOrderScript(string orderId)+ {+ var trackingScript = _facebookPixelSettings.DetailsOrderScript + "\n";+ var order = await _orderService.GetOrderById(orderId);+ if (order != null){- var trackingScript = _facebookPixelSettings.DetailsOrderScript + "\n";- var order = await _orderService.GetOrderById(orderId);- if (order != null)- {- trackingScript = trackingScript.Replace("{AMOUNT}", order.OrderTotal.ToString("F2", CultureInfo.InvariantCulture));- trackingScript = trackingScript.Replace("{CURRENCY}", order.CustomerCurrencyCode);- }- return trackingScript;+ trackingScript =+ trackingScript.Replace("{AMOUNT}", order.OrderTotal.ToString("F2", CultureInfo.InvariantCulture));+ trackingScript = trackingScript.Replace("{CURRENCY}", order.CustomerCurrencyCode);}++ return trackingScript;}}\ No newline at end of filediff --git a/src/Plugins/Widgets.FacebookPixel/FacebookPixelConsentCookie.cs b/src/Plugins/Widgets.FacebookPixel/FacebookPixelConsentCookie.csindex 469a983bb..dff7e0bb2 100644--- a/src/Plugins/Widgets.FacebookPixel/FacebookPixelConsentCookie.cs+++ b/src/Plugins/Widgets.FacebookPixel/FacebookPixelConsentCookie.cs@@ -1,32 +1,31 @@using Grand.Business.Core.Interfaces.Cms;-namespace Widgets.FacebookPixel+namespace Widgets.FacebookPixel;++public class FacebookPixelConsentCookie : IConsentCookie{- public class FacebookPixelConsentCookie : IConsentCookie- {- private readonly FacebookPixelSettings _facebookPixelSettings;+ private readonly FacebookPixelSettings _facebookPixelSettings;- public FacebookPixelConsentCookie(FacebookPixelSettings facebookPixelSettings)- {- _facebookPixelSettings = facebookPixelSettings;- }+ public FacebookPixelConsentCookie(FacebookPixelSettings facebookPixelSettings)+ {+ _facebookPixelSettings = facebookPixelSettings;+ }- public string SystemName => FacebookPixelDefaults.ConsentCookieSystemName;+ public string SystemName => FacebookPixelDefaults.ConsentCookieSystemName;- public bool AllowToDisable => _facebookPixelSettings.AllowToDisableConsentCookie;+ public bool AllowToDisable => _facebookPixelSettings.AllowToDisableConsentCookie;- public bool? DefaultState => _facebookPixelSettings.ConsentDefaultState;+ public bool? DefaultState => _facebookPixelSettings.ConsentDefaultState;- public int DisplayOrder => 10;+ public int DisplayOrder => 10;- public Task<string> FullDescription()- {- return Task.FromResult(_facebookPixelSettings.ConsentDescription);- }+ public Task<string> FullDescription()+ {+ return Task.FromResult(_facebookPixelSettings.ConsentDescription);+ }- public Task<string> Name()- {- return Task.FromResult(_facebookPixelSettings.ConsentName);- }+ public Task<string> Name()+ {+ return Task.FromResult(_facebookPixelSettings.ConsentName);}-}+}\ No newline at end of filediff --git a/src/Plugins/Widgets.FacebookPixel/FacebookPixelDefaults.cs b/src/Plugins/Widgets.FacebookPixel/FacebookPixelDefaults.csindex 852b0b749..304659ade 100644--- a/src/Plugins/Widgets.FacebookPixel/FacebookPixelDefaults.cs+++ b/src/Plugins/Widgets.FacebookPixel/FacebookPixelDefaults.cs@@ -1,14 +1,13 @@-namespace Widgets.FacebookPixel+namespace Widgets.FacebookPixel;++public static class FacebookPixelDefaults{- public static class FacebookPixelDefaults- {- public static string ConsentCookieSystemName = "FacebookPixel";- public const string ProviderSystemName = "Widgets.FacebookPixel";- public const string FriendlyName = "Widgets.FacebookPixel.FriendlyName";- public const string ConfigurationUrl = "../WidgetsFacebookPixel/Configure";+ public const string ProviderSystemName = "Widgets.FacebookPixel";+ public const string FriendlyName = "Widgets.FacebookPixel.FriendlyName";+ public const string ConfigurationUrl = "../WidgetsFacebookPixel/Configure";+ public static string ConsentCookieSystemName = "FacebookPixel";- public static string Page => "head_html_tag";- public static string AddToCart => "popup_add_to_cart_content_before";- public static string OrderDetails => "checkout_completed_top";- }-}+ public static string Page => "head_html_tag";+ public static string AddToCart => "popup_add_to_cart_content_before";+ public static string OrderDetails => "checkout_completed_top";+}\ No newline at end of filediff --git a/src/Plugins/Widgets.FacebookPixel/FacebookPixelPlugin.cs b/src/Plugins/Widgets.FacebookPixel/FacebookPixelPlugin.csindex b199a2b1f..ae3367b68 100644--- a/src/Plugins/Widgets.FacebookPixel/FacebookPixelPlugin.cs+++ b/src/Plugins/Widgets.FacebookPixel/FacebookPixelPlugin.cs@@ -3,38 +3,37 @@ using Grand.Business.Core.Interfaces.Common.Configuration;using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Infrastructure.Plugins;-namespace Widgets.FacebookPixel+namespace Widgets.FacebookPixel;++public class FacebookPixelPlugin : BasePlugin, IPlugin{- public class FacebookPixelPlugin : BasePlugin, IPlugin- {- private readonly ISettingService _settingService;- private readonly ITranslationService _translationService;- private readonly ILanguageService _languageService;+ private readonly ILanguageService _languageService;+ private readonly ISettingService _settingService;+ private readonly ITranslationService _translationService;- public FacebookPixelPlugin(- ISettingService settingService,- ITranslationService translationService,- ILanguageService languageService)- {- _settingService = settingService;- _translationService = translationService;- _languageService = languageService;- }+ public FacebookPixelPlugin(+ ISettingService settingService,+ ITranslationService translationService,+ ILanguageService languageService)+ {+ _settingService = settingService;+ _translationService = translationService;+ _languageService = languageService;+ }- /// <summary>- /// Gets a configuration page URL- /// </summary>- public override string ConfigurationUrl()- {- return FacebookPixelDefaults.ConfigurationUrl;- }+ /// <summary>+ /// Gets a configuration page URL+ /// </summary>+ public override string ConfigurationUrl()+ {+ return FacebookPixelDefaults.ConfigurationUrl;+ }- public override async Task Install()- {- var settings = new FacebookPixelSettings- {- PixelId = "000000000000000",- PixelScript = @"<!-- Facebook Pixel Code -->+ public override async Task Install()+ {+ var settings = new FacebookPixelSettings {+ PixelId = "000000000000000",+ PixelScript = @"<!-- Facebook Pixel Code --><script>!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?@@ -52,63 +51,98 @@ namespace Widgets.FacebookPixelsrc='https://www.facebook.com/tr?id={PIXELID}&ev=PageView&noscript=1'/></noscript><!-- End Facebook Pixel Code -->",- AddToCartScript = "<script> fbq('track', 'AddToCart', {contents: [{ id: '{PRODUCTID}', quantity: {QTY} }], content_name: '{PRODUCTNAME}', content_type: 'product', value: {AMOUNT}, currency: '{CURRENCY}'}); </script>",- DetailsOrderScript = "<script> fbq('track', 'Purchase', {currency: '{CURRENCY}', value: {AMOUNT}}); </script>",- ConsentName = "Facebook pixel",- ConsentDescription = "Allows us to identifies visitors from Facebook"- };- await _settingService.SaveSetting(settings);-- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.FacebookPixel.FriendlyName", "Facebook Pixel");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.FacebookPixel.PixelId", "Pixel Id");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.FacebookPixel.PixelId.Hint", "Enter Facebook Pixel ID.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.FacebookPixel.PixelScript", "Facebook Pixel Code");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.FacebookPixel.PixelScript.Hint", "Paste the facebook pixel code generated by Facebook here. {PIXELID} will be dynamically replaced.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.FacebookPixel.AddToCartScript", "Facebook Event - Add to cart");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.FacebookPixel.AddToCartScript.Hint", "Paste the event add to cart pixel code. {PRODUCTNAME}, {PRODUCTID}, {QTY}, {AMOUNT}, {CURRENCY} will be dynamically replaced.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.FacebookPixel.DetailsOrderScript", "Facebook Event - Purchase");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.FacebookPixel.DetailsOrderScript.Hint", "Paste the event purchase pixel code. {AMOUNT} and {CURRENCY} will be dynamically replaced.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.FacebookPixel.AllowToDisableConsentCookie", "Allow disabling consent cookie");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.FacebookPixel.AllowToDisableConsentCookie.Hint", "Get or set the value to disable consent cookie");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.FacebookPixel.ConsentDefaultState", "Consent default state");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.FacebookPixel.ConsentDefaultState.Hint", "Get or set the value to consent default state");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.FacebookPixel.ConsentName", "Consent cookie name");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.FacebookPixel.ConsentName.Hint", "Get or set the value to consent cookie name");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.FacebookPixel.ConsentDescription", "Consent cookie description");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.FacebookPixel.ConsentDescription.Hint", "Get or set the value to consent cookie description");-- await base.Install();- }+ AddToCartScript =+ "<script> fbq('track', 'AddToCart', {contents: [{ id: '{PRODUCTID}', quantity: {QTY} }], content_name: '{PRODUCTNAME}', content_type: 'product', value: {AMOUNT}, currency: '{CURRENCY}'}); </script>",+ DetailsOrderScript =+ "<script> fbq('track', 'Purchase', {currency: '{CURRENCY}', value: {AMOUNT}}); </script>",+ ConsentName = "Facebook pixel",+ ConsentDescription = "Allows us to identifies visitors from Facebook"+ };+ await _settingService.SaveSetting(settings);- /// <summary>- /// Uninstall plugin- /// </summary>- public override async Task Uninstall()- {- //settings- await _settingService.DeleteSetting<FacebookPixelSettings>();+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.FacebookPixel.FriendlyName", "Facebook Pixel");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.FacebookPixel.PixelId", "Pixel Id");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.FacebookPixel.PixelId.Hint", "Enter Facebook Pixel ID.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.FacebookPixel.PixelScript", "Facebook Pixel Code");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.FacebookPixel.PixelScript.Hint",+ "Paste the facebook pixel code generated by Facebook here. {PIXELID} will be dynamically replaced.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.FacebookPixel.AddToCartScript", "Facebook Event - Add to cart");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.FacebookPixel.AddToCartScript.Hint",+ "Paste the event add to cart pixel code. {PRODUCTNAME}, {PRODUCTID}, {QTY}, {AMOUNT}, {CURRENCY} will be dynamically replaced.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.FacebookPixel.DetailsOrderScript", "Facebook Event - Purchase");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.FacebookPixel.DetailsOrderScript.Hint",+ "Paste the event purchase pixel code. {AMOUNT} and {CURRENCY} will be dynamically replaced.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.FacebookPixel.AllowToDisableConsentCookie", "Allow disabling consent cookie");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.FacebookPixel.AllowToDisableConsentCookie.Hint", "Get or set the value to disable consent cookie");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.FacebookPixel.ConsentDefaultState", "Consent default state");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.FacebookPixel.ConsentDefaultState.Hint", "Get or set the value to consent default state");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.FacebookPixel.ConsentName", "Consent cookie name");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.FacebookPixel.ConsentName.Hint", "Get or set the value to consent cookie name");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.FacebookPixel.ConsentDescription", "Consent cookie description");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.FacebookPixel.ConsentDescription.Hint", "Get or set the value to consent cookie description");- //locales- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.FacebookPixel.PixelId");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.FacebookPixel.PixelId.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.FacebookPixel.PixelScript");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.FacebookPixel.PixelScript.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.FacebookPixel.AddToCartScript");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.FacebookPixel.AddToCartScript.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.FacebookPixel.DetailsOrderScript");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.FacebookPixel.DetailsOrderScript.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.FacebookPixel.AllowToDisableConsentCookie");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.FacebookPixel.AllowToDisableConsentCookie.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.FacebookPixel.ConsentDefaultState");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.FacebookPixel.ConsentDefaultState.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.FacebookPixel.ConsentName");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.FacebookPixel.ConsentName.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.FacebookPixel.ConsentDescription");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.FacebookPixel.ConsentDescription.Hint");+ await base.Install();+ }- await base.Uninstall();- }+ /// <summary>+ /// Uninstall plugin+ /// </summary>+ public override async Task Uninstall()+ {+ //settings+ await _settingService.DeleteSetting<FacebookPixelSettings>();+ //locales+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.FacebookPixel.PixelId");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.FacebookPixel.PixelId.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.FacebookPixel.PixelScript");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.FacebookPixel.PixelScript.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.FacebookPixel.AddToCartScript");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.FacebookPixel.AddToCartScript.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.FacebookPixel.DetailsOrderScript");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.FacebookPixel.DetailsOrderScript.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.FacebookPixel.AllowToDisableConsentCookie");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.FacebookPixel.AllowToDisableConsentCookie.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.FacebookPixel.ConsentDefaultState");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.FacebookPixel.ConsentDefaultState.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.FacebookPixel.ConsentName");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.FacebookPixel.ConsentName.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.FacebookPixel.ConsentDescription");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.FacebookPixel.ConsentDescription.Hint");+ await base.Uninstall();}-}+}\ No newline at end of filediff --git a/src/Plugins/Widgets.FacebookPixel/FacebookPixelProvider.cs b/src/Plugins/Widgets.FacebookPixel/FacebookPixelProvider.csindex 2e63ec281..d132728a4 100644--- a/src/Plugins/Widgets.FacebookPixel/FacebookPixelProvider.cs+++ b/src/Plugins/Widgets.FacebookPixel/FacebookPixelProvider.cs@@ -1,49 +1,46 @@using Grand.Business.Core.Interfaces.Cms;using Grand.Business.Core.Interfaces.Common.Localization;-namespace Widgets.FacebookPixel-{- public class FacebookPixelProvider : IWidgetProvider- {- private readonly FacebookPixelSettings _facebookPixelSettings;- private readonly ITranslationService _translationService;+namespace Widgets.FacebookPixel;- public FacebookPixelProvider(- FacebookPixelSettings facebookPixelSettings,- ITranslationService translationService)- {- _facebookPixelSettings = facebookPixelSettings;- _translationService = translationService;- }+public class FacebookPixelProvider : IWidgetProvider+{+ private readonly FacebookPixelSettings _facebookPixelSettings;+ private readonly ITranslationService _translationService;- public string ConfigurationUrl => FacebookPixelDefaults.ConfigurationUrl;+ public FacebookPixelProvider(+ FacebookPixelSettings facebookPixelSettings,+ ITranslationService translationService)+ {+ _facebookPixelSettings = facebookPixelSettings;+ _translationService = translationService;+ }- public string SystemName => FacebookPixelDefaults.ProviderSystemName;+ public string ConfigurationUrl => FacebookPixelDefaults.ConfigurationUrl;- public string FriendlyName => _translationService.GetResource(FacebookPixelDefaults.FriendlyName);+ public string SystemName => FacebookPixelDefaults.ProviderSystemName;- public int Priority => _facebookPixelSettings.DisplayOrder;+ public string FriendlyName => _translationService.GetResource(FacebookPixelDefaults.FriendlyName);- public IList<string> LimitedToStores => new List<string>();+ public int Priority => _facebookPixelSettings.DisplayOrder;- public IList<string> LimitedToGroups => new List<string>();+ public IList<string> LimitedToStores => new List<string>();- /// <summary>- /// Gets widget zones where this widget should be rendered- /// </summary>- /// <returns>Widget zones</returns>- public async Task<IList<string>> GetWidgetZones()- {- return await Task.FromResult(new List<string>- {- FacebookPixelDefaults.Page, FacebookPixelDefaults.AddToCart, FacebookPixelDefaults.OrderDetails- });- }+ public IList<string> LimitedToGroups => new List<string>();- public Task<string> GetPublicViewComponentName(string widgetZone)- {- return Task.FromResult("WidgetsFacebookPixel");- }+ /// <summary>+ /// Gets widget zones where this widget should be rendered+ /// </summary>+ /// <returns>Widget zones</returns>+ public async Task<IList<string>> GetWidgetZones()+ {+ return await Task.FromResult(new List<string> {+ FacebookPixelDefaults.Page, FacebookPixelDefaults.AddToCart, FacebookPixelDefaults.OrderDetails+ });+ }+ public Task<string> GetPublicViewComponentName(string widgetZone)+ {+ return Task.FromResult("WidgetsFacebookPixel");}-}+}\ No newline at end of filediff --git a/src/Plugins/Widgets.FacebookPixel/FacebookPixelSettings.cs b/src/Plugins/Widgets.FacebookPixel/FacebookPixelSettings.csindex 6381522b9..b5595485d 100644--- a/src/Plugins/Widgets.FacebookPixel/FacebookPixelSettings.cs+++ b/src/Plugins/Widgets.FacebookPixel/FacebookPixelSettings.cs@@ -1,17 +1,16 @@using Grand.Domain.Configuration;-namespace Widgets.FacebookPixel+namespace Widgets.FacebookPixel;++public class FacebookPixelSettings : ISettings{- public class FacebookPixelSettings : ISettings- {- public string PixelId { get; set; }- public string PixelScript { get; set; }- public string AddToCartScript { get; set; }- public string DetailsOrderScript { get; set; }- public bool AllowToDisableConsentCookie { get; set; }- public bool ConsentDefaultState { get; set; }- public string ConsentName { get; set; }- public string ConsentDescription { get; set; }- public int DisplayOrder { get; set; }- }+ public string PixelId { get; set; }+ public string PixelScript { get; set; }+ public string AddToCartScript { get; set; }+ public string DetailsOrderScript { get; set; }+ public bool AllowToDisableConsentCookie { get; set; }+ public bool ConsentDefaultState { get; set; }+ public string ConsentName { get; set; }+ public string ConsentDescription { get; set; }+ public int DisplayOrder { get; set; }}\ No newline at end of filediff --git a/src/Plugins/Widgets.FacebookPixel/Models/ConfigurationModel.cs b/src/Plugins/Widgets.FacebookPixel/Models/ConfigurationModel.csindex eb93e4b4a..03fc76086 100644--- a/src/Plugins/Widgets.FacebookPixel/Models/ConfigurationModel.cs+++ b/src/Plugins/Widgets.FacebookPixel/Models/ConfigurationModel.cs@@ -1,35 +1,33 @@using Grand.Infrastructure.ModelBinding;using Grand.Infrastructure.Models;-namespace Widgets.FacebookPixel.Models-{- public class ConfigurationModel : BaseModel- {- public string StoreScope { get; set; }+namespace Widgets.FacebookPixel.Models;- [GrandResourceDisplayName("Widgets.FacebookPixel.PixelId")]- public string PixelId { get; set; }+public class ConfigurationModel : BaseModel+{+ public string StoreScope { get; set; }- [GrandResourceDisplayName("Widgets.FacebookPixel.PixelScript")]- public string PixelScript { get; set; }+ [GrandResourceDisplayName("Widgets.FacebookPixel.PixelId")]+ public string PixelId { get; set; }- [GrandResourceDisplayName("Widgets.FacebookPixel.AddToCartScript")]- public string AddToCartScript { get; set; }+ [GrandResourceDisplayName("Widgets.FacebookPixel.PixelScript")]+ public string PixelScript { get; set; }- [GrandResourceDisplayName("Widgets.FacebookPixel.DetailsOrderScript")]- public string DetailsOrderScript { get; set; }+ [GrandResourceDisplayName("Widgets.FacebookPixel.AddToCartScript")]+ public string AddToCartScript { get; set; }- [GrandResourceDisplayName("Widgets.FacebookPixel.AllowToDisableConsentCookie")]- public bool AllowToDisableConsentCookie { get; set; }+ [GrandResourceDisplayName("Widgets.FacebookPixel.DetailsOrderScript")]+ public string DetailsOrderScript { get; set; }- [GrandResourceDisplayName("Widgets.FacebookPixel.ConsentDefaultState")]- public bool ConsentDefaultState { get; set; }+ [GrandResourceDisplayName("Widgets.FacebookPixel.AllowToDisableConsentCookie")]+ public bool AllowToDisableConsentCookie { get; set; }- [GrandResourceDisplayName("Widgets.FacebookPixel.ConsentName")]- public string ConsentName { get; set; }+ [GrandResourceDisplayName("Widgets.FacebookPixel.ConsentDefaultState")]+ public bool ConsentDefaultState { get; set; }- [GrandResourceDisplayName("Widgets.FacebookPixel.ConsentDescription")]- public string ConsentDescription { get; set; }+ [GrandResourceDisplayName("Widgets.FacebookPixel.ConsentName")]+ public string ConsentName { get; set; }- }+ [GrandResourceDisplayName("Widgets.FacebookPixel.ConsentDescription")]+ public string ConsentDescription { get; set; }}\ No newline at end of filediff --git a/src/Plugins/Widgets.FacebookPixel/Models/FacebookAddToCartModelModel.cs b/src/Plugins/Widgets.FacebookPixel/Models/FacebookAddToCartModelModel.csindex 039282844..11eb4cab3 100644--- a/src/Plugins/Widgets.FacebookPixel/Models/FacebookAddToCartModelModel.cs+++ b/src/Plugins/Widgets.FacebookPixel/Models/FacebookAddToCartModelModel.cs@@ -1,17 +1,14 @@using Grand.Infrastructure.Models;-namespace Widgets.FacebookPixel.Models-{- public class FacebookAddToCartModelModel : BaseModel- {- public string ProductId { get; set; }- public string ProductName { get; set; }- public int Quantity { get; set; }- public int ItemQuantity { get; set; }- public string Price { get; set; }- public double DecimalPrice { get; set; }- public string TotalPrice { get; set; }-+namespace Widgets.FacebookPixel.Models;- }+public class FacebookAddToCartModelModel : BaseModel+{+ public string ProductId { get; set; }+ public string ProductName { get; set; }+ public int Quantity { get; set; }+ public int ItemQuantity { get; set; }+ public string Price { get; set; }+ public double DecimalPrice { get; set; }+ public string TotalPrice { get; set; }}\ No newline at end of filediff --git a/src/Plugins/Widgets.FacebookPixel/StartupApplication.cs b/src/Plugins/Widgets.FacebookPixel/StartupApplication.csindex b06075bb9..df381b5c0 100644--- a/src/Plugins/Widgets.FacebookPixel/StartupApplication.cs+++ b/src/Plugins/Widgets.FacebookPixel/StartupApplication.cs@@ -5,22 +5,21 @@ using Microsoft.AspNetCore.Hosting;using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;-namespace Widgets.FacebookPixel+namespace Widgets.FacebookPixel;++public class StartupApplication : IStartupApplication{- public class StartupApplication : IStartupApplication+ public void ConfigureServices(IServiceCollection services, IConfiguration configuration){- public void ConfigureServices(IServiceCollection services, IConfiguration configuration)- {- services.AddScoped<IWidgetProvider, FacebookPixelProvider>();- services.AddScoped<IConsentCookie, FacebookPixelConsentCookie>();- }+ services.AddScoped<IWidgetProvider, FacebookPixelProvider>();+ services.AddScoped<IConsentCookie, FacebookPixelConsentCookie>();+ }- public int Priority => 10;- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)- {+ public int Priority => 10;- }- public bool BeforeConfigure => false;+ public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)+ {}-}+ public bool BeforeConfigure => false;+}\ No newline at end of filediff --git a/src/Plugins/Widgets.GoogleAnalytics/Areas/Admin/Controllers/WidgetsGoogleAnalyticsController.cs b/src/Plugins/Widgets.GoogleAnalytics/Areas/Admin/Controllers/WidgetsGoogleAnalyticsController.csindex c795149af..1e688d3b0 100644--- a/src/Plugins/Widgets.GoogleAnalytics/Areas/Admin/Controllers/WidgetsGoogleAnalyticsController.cs+++ b/src/Plugins/Widgets.GoogleAnalytics/Areas/Admin/Controllers/WidgetsGoogleAnalyticsController.cs@@ -10,83 +10,85 @@ using Grand.Web.Common.Security.Authorization;using Microsoft.AspNetCore.Mvc;using Widgets.GoogleAnalytics.Models;-namespace Widgets.GoogleAnalytics.Areas.Admin.Controllers+namespace Widgets.GoogleAnalytics.Areas.Admin.Controllers;++[PermissionAuthorize(PermissionSystemName.Widgets)]+public class WidgetsGoogleAnalyticsController : BaseAdminPluginController{- [PermissionAuthorize(PermissionSystemName.Widgets)]- public class WidgetsGoogleAnalyticsController : BaseAdminPluginController+ private readonly ISettingService _settingService;+ private readonly IStoreService _storeService;+ private readonly ITranslationService _translationService;+ private readonly IWorkContext _workContext;++ public WidgetsGoogleAnalyticsController(IWorkContext workContext,+ IStoreService storeService,+ ISettingService settingService,+ ITranslationService translationService){- private readonly IWorkContext _workContext;- private readonly IStoreService _storeService;- private readonly ISettingService _settingService;- private readonly ITranslationService _translationService;+ _workContext = workContext;+ _storeService = storeService;+ _settingService = settingService;+ _translationService = translationService;+ }- public WidgetsGoogleAnalyticsController(IWorkContext workContext,- IStoreService storeService,- ISettingService settingService,- ITranslationService translationService)- {- _workContext = workContext;- _storeService = storeService;- _settingService = settingService;- _translationService = translationService;- }- protected virtual async Task<string> GetActiveStore(IStoreService storeService, IWorkContext workContext)- {- var stores = await storeService.GetAllStores();- if (stores.Count < 2)- return stores.FirstOrDefault()!.Id;+ protected virtual async Task<string> GetActiveStore(IStoreService storeService, IWorkContext workContext)+ {+ var stores = await storeService.GetAllStores();+ if (stores.Count < 2)+ return stores.FirstOrDefault()!.Id;- var storeId = workContext.CurrentCustomer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames.AdminAreaStoreScopeConfiguration);- var store = await storeService.GetStoreById(storeId);+ var storeId =+ workContext.CurrentCustomer.GetUserFieldFromEntity<string>(SystemCustomerFieldNames+ .AdminAreaStoreScopeConfiguration);+ var store = await storeService.GetStoreById(storeId);- return store != null ? store.Id : "";- }+ return store != null ? store.Id : "";+ }- public async Task<IActionResult> Configure()- {- //load settings for a chosen store scope- var storeScope = await GetActiveStore(_storeService, _workContext);- var googleAnalyticsSettings = _settingService.LoadSetting<GoogleAnalyticsEcommerceSettings>(storeScope);- var model = new ConfigurationModel {- GoogleId = googleAnalyticsSettings.GoogleId,- TrackingScript = googleAnalyticsSettings.TrackingScript,- EcommerceScript = googleAnalyticsSettings.EcommerceScript,- EcommerceDetailScript = googleAnalyticsSettings.EcommerceDetailScript,- IncludingTax = googleAnalyticsSettings.IncludingTax,- AllowToDisableConsentCookie = googleAnalyticsSettings.AllowToDisableConsentCookie,- ConsentDefaultState = googleAnalyticsSettings.ConsentDefaultState,- ConsentName = googleAnalyticsSettings.ConsentName,- ConsentDescription = googleAnalyticsSettings.ConsentDescription,- StoreScope = storeScope- };+ public async Task<IActionResult> Configure()+ {+ //load settings for a chosen store scope+ var storeScope = await GetActiveStore(_storeService, _workContext);+ var googleAnalyticsSettings = _settingService.LoadSetting<GoogleAnalyticsEcommerceSettings>(storeScope);+ var model = new ConfigurationModel {+ GoogleId = googleAnalyticsSettings.GoogleId,+ TrackingScript = googleAnalyticsSettings.TrackingScript,+ EcommerceScript = googleAnalyticsSettings.EcommerceScript,+ EcommerceDetailScript = googleAnalyticsSettings.EcommerceDetailScript,+ IncludingTax = googleAnalyticsSettings.IncludingTax,+ AllowToDisableConsentCookie = googleAnalyticsSettings.AllowToDisableConsentCookie,+ ConsentDefaultState = googleAnalyticsSettings.ConsentDefaultState,+ ConsentName = googleAnalyticsSettings.ConsentName,+ ConsentDescription = googleAnalyticsSettings.ConsentDescription,+ StoreScope = storeScope+ };- return View(model);- }+ return View(model);+ }- [HttpPost]- public async Task<IActionResult> Configure(ConfigurationModel model)- {- //load settings for a chosen store scope- var storeScope = await GetActiveStore(_storeService, _workContext);- var googleAnalyticsSettings = _settingService.LoadSetting<GoogleAnalyticsEcommerceSettings>(storeScope);- googleAnalyticsSettings.GoogleId = model.GoogleId;- googleAnalyticsSettings.TrackingScript = model.TrackingScript;- googleAnalyticsSettings.EcommerceScript = model.EcommerceScript;- googleAnalyticsSettings.EcommerceDetailScript = model.EcommerceDetailScript;- googleAnalyticsSettings.IncludingTax = model.IncludingTax;- googleAnalyticsSettings.AllowToDisableConsentCookie = model.AllowToDisableConsentCookie;- googleAnalyticsSettings.ConsentDefaultState = model.ConsentDefaultState;- googleAnalyticsSettings.ConsentName = model.ConsentName;- googleAnalyticsSettings.ConsentDescription = model.ConsentDescription;+ [HttpPost]+ public async Task<IActionResult> Configure(ConfigurationModel model)+ {+ //load settings for a chosen store scope+ var storeScope = await GetActiveStore(_storeService, _workContext);+ var googleAnalyticsSettings = _settingService.LoadSetting<GoogleAnalyticsEcommerceSettings>(storeScope);+ googleAnalyticsSettings.GoogleId = model.GoogleId;+ googleAnalyticsSettings.TrackingScript = model.TrackingScript;+ googleAnalyticsSettings.EcommerceScript = model.EcommerceScript;+ googleAnalyticsSettings.EcommerceDetailScript = model.EcommerceDetailScript;+ googleAnalyticsSettings.IncludingTax = model.IncludingTax;+ googleAnalyticsSettings.AllowToDisableConsentCookie = model.AllowToDisableConsentCookie;+ googleAnalyticsSettings.ConsentDefaultState = model.ConsentDefaultState;+ googleAnalyticsSettings.ConsentName = model.ConsentName;+ googleAnalyticsSettings.ConsentDescription = model.ConsentDescription;- await _settingService.SaveSetting(googleAnalyticsSettings, storeScope);+ await _settingService.SaveSetting(googleAnalyticsSettings, storeScope);- //now clear settings cache- await _settingService.ClearCache();+ //now clear settings cache+ await _settingService.ClearCache();- Success(_translationService.GetResource("Admin.Plugins.Saved"));+ Success(_translationService.GetResource("Admin.Plugins.Saved"));- return await Configure();- }+ return await Configure();}}\ No newline at end of filediff --git a/src/Plugins/Widgets.GoogleAnalytics/Areas/Admin/Views/WidgetsGoogleAnalytics/Configure.cshtml b/src/Plugins/Widgets.GoogleAnalytics/Areas/Admin/Views/WidgetsGoogleAnalytics/Configure.cshtmlindex a302d77b1..6696d2457 100644--- a/src/Plugins/Widgets.GoogleAnalytics/Areas/Admin/Views/WidgetsGoogleAnalytics/Configure.cshtml+++ b/src/Plugins/Widgets.GoogleAnalytics/Areas/Admin/Views/WidgetsGoogleAnalytics/Configure.cshtml@@ -1,12 +1,13 @@@{Layout = "_ConfigurePlugin";}+@using System.Text.Encodings.Web@model Widgets.GoogleAnalytics.Models.ConfigurationModel@await Component.InvokeAsync("StoreScope")@{//default values- var googleAnalytics_trackingScript = Html.Raw(System.Text.Encodings.Web.JavaScriptEncoder.Default.Encode(@"<!-- Google tag (gtag.js) -->+ var googleAnalytics_trackingScript = Html.Raw(JavaScriptEncoder.Default.Encode(@"<!-- Google tag (gtag.js) --><script async src='https://www.googletagmanager.com/gtag/js?id={GOOGLEID}'></script><script>window.dataLayer = window.dataLayer || [];@@ -16,9 +17,8 @@{ECOMMERCE}</script>"));- var googleAnalytics_EcommerceScript = Html.Raw(System.Text.Encodings.Web.JavaScriptEncoder.Default.Encode("gtag('event', 'purchase', {transaction_id: '{ORDERID}', value: {TOTAL}, tax: {TAX}, shipping: {SHIP}, currency: '{CURRENCY}', city: '{CITY}', state: '{STATEPROVINCE}', country: '{COUNTRY}', items: [{DETAILS}]});"));- var googleAnalytics_EcommerceDetailScript = Html.Raw(System.Text.Encodings.Web.JavaScriptEncoder.Default.Encode("{ item_id: '{PRODUCTID}', item_name: '{PRODUCTNAME}', item_category: '{CATEGORYNAME}', price: {UNITPRICE}, quantity: {QUANTITY} }, "));-+ var googleAnalytics_EcommerceScript = Html.Raw(JavaScriptEncoder.Default.Encode("gtag('event', 'purchase', {transaction_id: '{ORDERID}', value: {TOTAL}, tax: {TAX}, shipping: {SHIP}, currency: '{CURRENCY}', city: '{CITY}', state: '{STATEPROVINCE}', country: '{COUNTRY}', items: [{DETAILS}]});"));+ var googleAnalytics_EcommerceDetailScript = Html.Raw(JavaScriptEncoder.Default.Encode("{ item_id: '{PRODUCTID}', item_name: '{PRODUCTNAME}', item_category: '{CATEGORYNAME}', price: {UNITPRICE}, quantity: {QUANTITY} }, "));}<script>$(document).ready(function () {@@ -33,7 +33,7 @@</script><form asp-controller="WidgetsGoogleAnalytics" asp-action="Configure" method="post">-+<div class="form-horizonal"><div class="form-body"><div class="form-group">@@ -55,21 +55,21 @@<li>Copy the Tracking ID into the 'ID' box below</li><li>Click the 'Save' button below and Google Analytics will be integrated into your store</li></ul>- <input type="button" id="pre-configure-google-analytics" class="k-button" value="Pre-configure Google Analytics" />+ <input type="button" id="pre-configure-google-analytics" class="k-button" value="Pre-configure Google Analytics"/></div></div><div class="form-group"><div class="col-md-4 col-sm-4 text-right">- <admin-label asp-for="GoogleId" class="control-label" />+ <admin-label asp-for="GoogleId" class="control-label"/></div><div class="col-md-8 col-sm-8">- <admin-input asp-for="GoogleId" />+ <admin-input asp-for="GoogleId"/><span asp-validation-for="GoogleId"></span></div></div><div class="form-group"><div class="col-md-4 col-sm-4 text-right">- <admin-label asp-for="TrackingScript" class="control-label" />+ <admin-label asp-for="TrackingScript" class="control-label"/></div><div class="col-md-8 col-sm-8"><admin-textarea asp-for="TrackingScript"></admin-textarea>@@ -78,7 +78,7 @@</div><div class="form-group"><div class="col-md-4 col-sm-4 text-right">- <admin-label asp-for="EcommerceScript" class="control-label" />+ <admin-label asp-for="EcommerceScript" class="control-label"/></div><div class="col-md-8 col-sm-8"><admin-textarea asp-for="EcommerceScript"></admin-textarea>@@ -87,7 +87,7 @@</div><div class="form-group"><div class="col-md-4 col-sm-4 text-right">- <admin-label asp-for="EcommerceDetailScript" class="control-label" />+ <admin-label asp-for="EcommerceDetailScript" class="control-label"/></div><div class="col-md-8 col-sm-8"><admin-textarea asp-for="EcommerceDetailScript"></admin-textarea>@@ -96,11 +96,11 @@</div><div class="form-group"><div class="col-md-4 col-sm-4 text-right">- <admin-label asp-for="IncludingTax" class="control-label" />+ <admin-label asp-for="IncludingTax" class="control-label"/></div><div class="col-md-8 col-sm-8"><label class="mt-checkbox mt-checkbox-outline control control-checkbox">- <admin-input asp-for="IncludingTax" />+ <admin-input asp-for="IncludingTax"/><div class="control__indicator"></div></label><span asp-validation-for="IncludingTax"></span>@@ -108,11 +108,11 @@</div><div class="form-group"><div class="col-md-4 col-sm-4 text-right">- <admin-label asp-for="AllowToDisableConsentCookie" class="control-label" />+ <admin-label asp-for="AllowToDisableConsentCookie" class="control-label"/></div><div class="col-md-8 col-sm-8"><label class="mt-checkbox mt-checkbox-outline control control-checkbox">- <admin-input asp-for="AllowToDisableConsentCookie" />+ <admin-input asp-for="AllowToDisableConsentCookie"/><div class="control__indicator"></div></label><span asp-validation-for="AllowToDisableConsentCookie"></span>@@ -120,11 +120,11 @@</div><div class="form-group"><div class="col-md-4 col-sm-4 text-right">- <admin-label asp-for="ConsentDefaultState" class="control-label" />+ <admin-label asp-for="ConsentDefaultState" class="control-label"/></div><div class="col-md-8 col-sm-8"><label class="mt-checkbox mt-checkbox-outline control control-checkbox">- <admin-input asp-for="ConsentDefaultState" />+ <admin-input asp-for="ConsentDefaultState"/><div class="control__indicator"></div></label><span asp-validation-for="ConsentDefaultState"></span>@@ -132,7 +132,7 @@</div><div class="form-group"><div class="col-md-4 col-sm-4 text-right">- <admin-label asp-for="ConsentName" class="control-label" />+ <admin-label asp-for="ConsentName" class="control-label"/></div><div class="col-md-8 col-sm-8"><admin-textarea asp-for="ConsentName"></admin-textarea>@@ -141,7 +141,7 @@</div><div class="form-group"><div class="col-md-4 col-sm-4 text-right">- <admin-label asp-for="ConsentDescription" class="control-label" />+ <admin-label asp-for="ConsentDescription" class="control-label"/></div><div class="col-md-8 col-sm-8"><admin-textarea asp-for="ConsentDescription"></admin-textarea>@@ -158,8 +158,8 @@</div><div class="form-actions"><div class="offset-md-3 offset-sm-3 col-md-9 col-sm-9">- <input type="submit" name="save" class="btn green" value="@Loc["Admin.Common.Save"]" />+ <input type="submit" name="save" class="btn green" value="@Loc["Admin.Common.Save"]"/></div></div></div>-</form>+</form>\ No newline at end of filediff --git a/src/Plugins/Widgets.GoogleAnalytics/Areas/Admin/Views/_ViewImports.cshtml b/src/Plugins/Widgets.GoogleAnalytics/Areas/Admin/Views/_ViewImports.cshtmlindex 0a765b55a..52adbfe6d 100644--- a/src/Plugins/Widgets.GoogleAnalytics/Areas/Admin/Views/_ViewImports.cshtml+++ b/src/Plugins/Widgets.GoogleAnalytics/Areas/Admin/Views/_ViewImports.cshtml@@ -5,5 +5,6 @@@using Microsoft.AspNetCore.Mvc.ViewFeatures@using Grand.Infrastructure.Extensions@using Grand.Web.Common+@using Grand.Web.Common.Localization-@inject Grand.Web.Common.Localization.LocService Loc+@inject LocService Loc\ No newline at end of filediff --git a/src/Plugins/Widgets.GoogleAnalytics/Components/WidgetsGoogleAnalyticsViewComponent.cs b/src/Plugins/Widgets.GoogleAnalytics/Components/WidgetsGoogleAnalyticsViewComponent.csindex 7c0479869..1fff52f61 100644--- a/src/Plugins/Widgets.GoogleAnalytics/Components/WidgetsGoogleAnalyticsViewComponent.cs+++ b/src/Plugins/Widgets.GoogleAnalytics/Components/WidgetsGoogleAnalyticsViewComponent.cs@@ -11,155 +11,185 @@ using Microsoft.Extensions.DependencyInjection;using Microsoft.Extensions.Logging;using System.Globalization;-namespace Widgets.GoogleAnalytics.Components+namespace Widgets.GoogleAnalytics.Components;++[ViewComponent(Name = "WidgetsGoogleAnalytics")]+public class WidgetsGoogleAnalyticsViewComponent : ViewComponent{- [ViewComponent(Name = "WidgetsGoogleAnalytics")]- public class WidgetsGoogleAnalyticsViewComponent : ViewComponent+ private readonly ICookiePreference _cookiePreference;+ private readonly GoogleAnalyticsEcommerceSettings _googleAnalyticsEcommerceSettings;+ private readonly IHttpContextAccessor _httpContextAccessor;+ private readonly ILogger<WidgetsGoogleAnalyticsViewComponent> _logger;+ private readonly IWorkContext _workContext;++ public WidgetsGoogleAnalyticsViewComponent(IWorkContext workContext,+ ILogger<WidgetsGoogleAnalyticsViewComponent> logger,+ GoogleAnalyticsEcommerceSettings googleAnalyticsEcommerceSettings,+ ICookiePreference cookiePreference,+ IHttpContextAccessor httpContextAccessor){- private readonly IWorkContext _workContext;- private readonly ILogger<WidgetsGoogleAnalyticsViewComponent> _logger;- private readonly GoogleAnalyticsEcommerceSettings _googleAnalyticsEcommerceSettings;- private readonly ICookiePreference _cookiePreference;- private readonly IHttpContextAccessor _httpContextAccessor;-- public WidgetsGoogleAnalyticsViewComponent(IWorkContext workContext,- ILogger<WidgetsGoogleAnalyticsViewComponent> logger,- GoogleAnalyticsEcommerceSettings googleAnalyticsEcommerceSettings,- ICookiePreference cookiePreference,- IHttpContextAccessor httpContextAccessor)+ _workContext = workContext;+ _logger = logger;+ _googleAnalyticsEcommerceSettings = googleAnalyticsEcommerceSettings;+ _cookiePreference = cookiePreference;+ _httpContextAccessor = httpContextAccessor;+ }++ public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData = null)+ {+ var globalScript = "";++ if (_googleAnalyticsEcommerceSettings.AllowToDisableConsentCookie){- _workContext = workContext;- _logger = logger;- _googleAnalyticsEcommerceSettings = googleAnalyticsEcommerceSettings;- _cookiePreference = cookiePreference;- _httpContextAccessor = httpContextAccessor;+ var enabled = await _cookiePreference.IsEnable(_workContext.CurrentCustomer, _workContext.CurrentStore,+ GoogleAnalyticDefaults.ConsentCookieSystemName);+ if ((enabled.HasValue && !enabled.Value) ||+ (!enabled.HasValue && !_googleAnalyticsEcommerceSettings.ConsentDefaultState))+ return Content("");}- public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData = null)+ var routeData = Url.ActionContext.RouteData;+ try{- var globalScript = "";+ var controller = routeData.Values["controller"];+ var action = routeData.Values["action"];- if (_googleAnalyticsEcommerceSettings.AllowToDisableConsentCookie)- {- var enabled = await _cookiePreference.IsEnable(_workContext.CurrentCustomer, _workContext.CurrentStore, GoogleAnalyticDefaults.ConsentCookieSystemName);- if ((enabled.HasValue && !enabled.Value) || (!enabled.HasValue && !_googleAnalyticsEcommerceSettings.ConsentDefaultState))- return Content("");- }+ if (controller == null || action == null)+ return Content("");- var routeData = Url.ActionContext.RouteData;- try+ //Special case, if we are in last step of checkout, we can use order total for conversion value+ if (controller.ToString()!.Equals("checkout", StringComparison.OrdinalIgnoreCase) &&+ action.ToString()!.Equals("completed", StringComparison.OrdinalIgnoreCase)){- var controller = routeData.Values["controller"];- var action = routeData.Values["action"];-- if (controller == null || action == null)- return Content("");-- //Special case, if we are in last step of checkout, we can use order total for conversion value- if (controller.ToString()!.Equals("checkout", StringComparison.OrdinalIgnoreCase) &&- action.ToString()!.Equals("completed", StringComparison.OrdinalIgnoreCase))- {- var lastOrder = await GetLastOrder();- globalScript += await GetEcommerceScript(lastOrder);- }- else- {- globalScript += GetTrackingScript();- }+ var lastOrder = await GetLastOrder();+ globalScript += await GetEcommerceScript(lastOrder);}- catch (Exception ex)+ else{- _logger.LogError(ex, "Error creating scripts for google ecommerce tracking");+ globalScript += GetTrackingScript();}- return View("Default", globalScript);}-- private async Task<Order> GetLastOrder()+ catch (Exception ex){- var orderService = _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<IOrderService>();- var order = (await orderService.SearchOrders(storeId: _workContext.CurrentStore.Id,- customerId: _workContext.CurrentCustomer.Id, pageSize: 1)).FirstOrDefault();- return order;+ _logger.LogError(ex, "Error creating scripts for google ecommerce tracking");}- private string GetTrackingScript()- {- var analyticsTrackingScript = _googleAnalyticsEcommerceSettings.TrackingScript + "\n";- analyticsTrackingScript = analyticsTrackingScript.Replace("{GOOGLEID}", _googleAnalyticsEcommerceSettings.GoogleId);- analyticsTrackingScript = analyticsTrackingScript.Replace("{ECOMMERCE}", "");- return analyticsTrackingScript;- }+ return View("Default", globalScript);+ }- private async Task<string> GetEcommerceScript(Order order)- {- var usCulture = new CultureInfo("en-US");- var analyticsTrackingScript = _googleAnalyticsEcommerceSettings.TrackingScript + "\n";- analyticsTrackingScript = analyticsTrackingScript.Replace("{GOOGLEID}", _googleAnalyticsEcommerceSettings.GoogleId);+ private async Task<Order> GetLastOrder()+ {+ var orderService = _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<IOrderService>();+ var order = (await orderService.SearchOrders(_workContext.CurrentStore.Id,+ customerId: _workContext.CurrentCustomer.Id, pageSize: 1)).FirstOrDefault();+ return order;+ }- if (order != null)+ private string GetTrackingScript()+ {+ var analyticsTrackingScript = _googleAnalyticsEcommerceSettings.TrackingScript + "\n";+ analyticsTrackingScript =+ analyticsTrackingScript.Replace("{GOOGLEID}", _googleAnalyticsEcommerceSettings.GoogleId);+ analyticsTrackingScript = analyticsTrackingScript.Replace("{ECOMMERCE}", "");+ return analyticsTrackingScript;+ }++ private async Task<string> GetEcommerceScript(Order order)+ {+ var usCulture = new CultureInfo("en-US");+ var analyticsTrackingScript = _googleAnalyticsEcommerceSettings.TrackingScript + "\n";+ analyticsTrackingScript =+ analyticsTrackingScript.Replace("{GOOGLEID}", _googleAnalyticsEcommerceSettings.GoogleId);++ if (order != null)+ {+ var countryService =+ _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<ICountryService>();+ var country = await countryService.GetCountryById(order.BillingAddress?.CountryId);+ var state = country?.StateProvinces.FirstOrDefault(x => x.Id == order.BillingAddress?.StateProvinceId);++ var analyticsEcommerceScript = _googleAnalyticsEcommerceSettings.EcommerceScript + "\n";+ analyticsEcommerceScript =+ analyticsEcommerceScript.Replace("{GOOGLEID}", _googleAnalyticsEcommerceSettings.GoogleId);+ analyticsEcommerceScript = analyticsEcommerceScript.Replace("{ORDERID}", order.Id);+ analyticsEcommerceScript =+ analyticsEcommerceScript.Replace("{TOTAL}", order.OrderTotal.ToString("0.00", usCulture));+ analyticsEcommerceScript = analyticsEcommerceScript.Replace("{CURRENCY}", order.CustomerCurrencyCode);+ analyticsEcommerceScript =+ analyticsEcommerceScript.Replace("{TAX}", order.OrderTax.ToString("0.00", usCulture));+ var orderShipping = _googleAnalyticsEcommerceSettings.IncludingTax+ ? order.OrderShippingInclTax+ : order.OrderShippingExclTax;+ analyticsEcommerceScript =+ analyticsEcommerceScript.Replace("{SHIP}", orderShipping.ToString("0.00", usCulture));+ analyticsEcommerceScript = analyticsEcommerceScript.Replace("{CITY}",+ order.BillingAddress == null ? "" : FixIllegalJavaScriptChars(order.BillingAddress.City));+ analyticsEcommerceScript = analyticsEcommerceScript.Replace("{STATEPROVINCE}",+ order.BillingAddress == null || string.IsNullOrEmpty(order.BillingAddress.StateProvinceId)+ ? ""+ : FixIllegalJavaScriptChars(state?.Name));+ analyticsEcommerceScript = analyticsEcommerceScript.Replace("{COUNTRY}",+ order.BillingAddress == null || string.IsNullOrEmpty(order.BillingAddress.CountryId)+ ? ""+ : FixIllegalJavaScriptChars(country?.Name));++ var sb = new StringBuilder();++ var productService =+ _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<IProductService>();+ var categoryService =+ _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<ICategoryService>();++ foreach (var item in order.OrderItems){- var countryService = _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<ICountryService>();- var country = await countryService.GetCountryById(order.BillingAddress?.CountryId);- var state = country?.StateProvinces.FirstOrDefault(x => x.Id == order.BillingAddress?.StateProvinceId);-- var analyticsEcommerceScript = _googleAnalyticsEcommerceSettings.EcommerceScript + "\n";- analyticsEcommerceScript = analyticsEcommerceScript.Replace("{GOOGLEID}", _googleAnalyticsEcommerceSettings.GoogleId);- analyticsEcommerceScript = analyticsEcommerceScript.Replace("{ORDERID}", order.Id);- analyticsEcommerceScript = analyticsEcommerceScript.Replace("{TOTAL}", order.OrderTotal.ToString("0.00", usCulture));- analyticsEcommerceScript = analyticsEcommerceScript.Replace("{CURRENCY}", order.CustomerCurrencyCode);- analyticsEcommerceScript = analyticsEcommerceScript.Replace("{TAX}", order.OrderTax.ToString("0.00", usCulture));- var orderShipping = _googleAnalyticsEcommerceSettings.IncludingTax ? order.OrderShippingInclTax : order.OrderShippingExclTax;- analyticsEcommerceScript = analyticsEcommerceScript.Replace("{SHIP}", orderShipping.ToString("0.00", usCulture));- analyticsEcommerceScript = analyticsEcommerceScript.Replace("{CITY}", order.BillingAddress == null ? "" : FixIllegalJavaScriptChars(order.BillingAddress.City));- analyticsEcommerceScript = analyticsEcommerceScript.Replace("{STATEPROVINCE}", order.BillingAddress == null || string.IsNullOrEmpty(order.BillingAddress.StateProvinceId) ? "" : FixIllegalJavaScriptChars(state?.Name));- analyticsEcommerceScript = analyticsEcommerceScript.Replace("{COUNTRY}", order.BillingAddress == null || string.IsNullOrEmpty(order.BillingAddress.CountryId) ? "" : FixIllegalJavaScriptChars(country?.Name));-- var sb = new StringBuilder();-- var productService = _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<IProductService>();- var categoryService = _httpContextAccessor.HttpContext!.RequestServices.GetRequiredService<ICategoryService>();-- foreach (var item in order.OrderItems)+ var product = await productService.GetProductById(item.ProductId);+ var analyticsEcommerceDetailScript = _googleAnalyticsEcommerceSettings.EcommerceDetailScript;+ //get category+ var category = "";+ if (product.ProductCategories.Any()){- var product = await productService.GetProductById(item.ProductId);- var analyticsEcommerceDetailScript = _googleAnalyticsEcommerceSettings.EcommerceDetailScript;- //get category- var category = "";- if (product.ProductCategories.Any())- {- var defaultProductCategory = await categoryService.GetCategoryById(product.ProductCategories.MinBy(x => x.DisplayOrder).CategoryId);- if (defaultProductCategory != null)- category = defaultProductCategory.Name;- }- analyticsEcommerceDetailScript = analyticsEcommerceDetailScript.Replace("{ORDERID}", order.Id);- //The SKU code is a required parameter for every item that is added to the transaction- analyticsEcommerceDetailScript = analyticsEcommerceDetailScript.Replace("{PRODUCTSKU}", FixIllegalJavaScriptChars(item.Sku));- analyticsEcommerceDetailScript = analyticsEcommerceDetailScript.Replace("{PRODUCTID}", FixIllegalJavaScriptChars(item.ProductId));- analyticsEcommerceDetailScript = analyticsEcommerceDetailScript.Replace("{PRODUCTNAME}", FixIllegalJavaScriptChars(product.Name));- analyticsEcommerceDetailScript = analyticsEcommerceDetailScript.Replace("{CATEGORYNAME}", FixIllegalJavaScriptChars(category));- var unitPrice = _googleAnalyticsEcommerceSettings.IncludingTax ? item.UnitPriceInclTax : item.UnitPriceExclTax;- analyticsEcommerceDetailScript = analyticsEcommerceDetailScript.Replace("{UNITPRICE}", unitPrice.ToString("0.00", usCulture));- analyticsEcommerceDetailScript = analyticsEcommerceDetailScript.Replace("{QUANTITY}", item.Quantity.ToString());- sb.AppendLine(analyticsEcommerceDetailScript);+ var defaultProductCategory =+ await categoryService.GetCategoryById(product.ProductCategories.MinBy(x => x.DisplayOrder)+ .CategoryId);+ if (defaultProductCategory != null)+ category = defaultProductCategory.Name;}- analyticsEcommerceScript = analyticsEcommerceScript.Replace("{DETAILS}", sb.ToString());-- analyticsTrackingScript = analyticsTrackingScript.Replace("{ECOMMERCE}", analyticsEcommerceScript);-+ analyticsEcommerceDetailScript = analyticsEcommerceDetailScript.Replace("{ORDERID}", order.Id);+ //The SKU code is a required parameter for every item that is added to the transaction+ analyticsEcommerceDetailScript =+ analyticsEcommerceDetailScript.Replace("{PRODUCTSKU}", FixIllegalJavaScriptChars(item.Sku));+ analyticsEcommerceDetailScript =+ analyticsEcommerceDetailScript.Replace("{PRODUCTID}", FixIllegalJavaScriptChars(item.ProductId));+ analyticsEcommerceDetailScript =+ analyticsEcommerceDetailScript.Replace("{PRODUCTNAME}", FixIllegalJavaScriptChars(product.Name));+ analyticsEcommerceDetailScript =+ analyticsEcommerceDetailScript.Replace("{CATEGORYNAME}", FixIllegalJavaScriptChars(category));+ var unitPrice = _googleAnalyticsEcommerceSettings.IncludingTax+ ? item.UnitPriceInclTax+ : item.UnitPriceExclTax;+ analyticsEcommerceDetailScript =+ analyticsEcommerceDetailScript.Replace("{UNITPRICE}", unitPrice.ToString("0.00", usCulture));+ analyticsEcommerceDetailScript =+ analyticsEcommerceDetailScript.Replace("{QUANTITY}", item.Quantity.ToString());+ sb.AppendLine(analyticsEcommerceDetailScript);}- return analyticsTrackingScript;+ analyticsEcommerceScript = analyticsEcommerceScript.Replace("{DETAILS}", sb.ToString());++ analyticsTrackingScript = analyticsTrackingScript.Replace("{ECOMMERCE}", analyticsEcommerceScript);}- private string FixIllegalJavaScriptChars(string text)- {- if (string.IsNullOrEmpty(text))- return text;+ return analyticsTrackingScript;+ }- //replace ' with \' (http://stackoverflow.com/questions/4292761/need-to-url-encode-labels-when-tracking-events-with-google-analytics)- text = text.Replace("'", "\\'");+ private string FixIllegalJavaScriptChars(string text)+ {+ if (string.IsNullOrEmpty(text))return text;- }++ //replace ' with \' (http://stackoverflow.com/questions/4292761/need-to-url-encode-labels-when-tracking-events-with-google-analytics)+ text = text.Replace("'", "\\'");+ return text;}}\ No newline at end of filediff --git a/src/Plugins/Widgets.GoogleAnalytics/GoogleAnalyticDefaults.cs b/src/Plugins/Widgets.GoogleAnalytics/GoogleAnalyticDefaults.csindex 39d707abd..2586aa0e1 100644--- a/src/Plugins/Widgets.GoogleAnalytics/GoogleAnalyticDefaults.cs+++ b/src/Plugins/Widgets.GoogleAnalytics/GoogleAnalyticDefaults.cs@@ -1,10 +1,9 @@-namespace Widgets.GoogleAnalytics+namespace Widgets.GoogleAnalytics;++public static class GoogleAnalyticDefaults{- public static class GoogleAnalyticDefaults- {- public static string ConsentCookieSystemName = "GoogleAnalytics";- public const string ProviderSystemName = "Widgets.GoogleAnalytics";- public const string FriendlyName = "Widgets.GoogleAnalytics.FriendlyName";- public const string ConfigurationUrl = "../WidgetsGoogleAnalytics/Configure";- }-}+ public const string ProviderSystemName = "Widgets.GoogleAnalytics";+ public const string FriendlyName = "Widgets.GoogleAnalytics.FriendlyName";+ public const string ConfigurationUrl = "../WidgetsGoogleAnalytics/Configure";+ public static string ConsentCookieSystemName = "GoogleAnalytics";+}\ No newline at end of filediff --git a/src/Plugins/Widgets.GoogleAnalytics/GoogleAnalyticPlugin.cs b/src/Plugins/Widgets.GoogleAnalytics/GoogleAnalyticPlugin.csindex 197034f72..c4f7284d4 100644--- a/src/Plugins/Widgets.GoogleAnalytics/GoogleAnalyticPlugin.cs+++ b/src/Plugins/Widgets.GoogleAnalytics/GoogleAnalyticPlugin.cs@@ -3,41 +3,41 @@ using Grand.Business.Core.Interfaces.Common.Configuration;using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Infrastructure.Plugins;-namespace Widgets.GoogleAnalytics+namespace Widgets.GoogleAnalytics;++/// <summary>+/// Live person provider+/// </summary>+public class GoogleAnalyticPlugin : BasePlugin, IPlugin{+ private readonly ILanguageService _languageService;+ private readonly ISettingService _settingService;+ private readonly ITranslationService _translationService;++ public GoogleAnalyticPlugin(ITranslationService translationService, ILanguageService languageService,+ ISettingService settingService)+ {+ _translationService = translationService;+ _settingService = settingService;+ _languageService = languageService;+ }+/// <summary>- /// Live person provider+ /// Gets a configuration page URL/// </summary>- public class GoogleAnalyticPlugin : BasePlugin, IPlugin+ public override string ConfigurationUrl(){- private readonly ITranslationService _translationService;- private readonly ILanguageService _languageService;- private readonly ISettingService _settingService;-- public GoogleAnalyticPlugin(ITranslationService translationService, ILanguageService languageService, ISettingService settingService)- {- _translationService = translationService;- _settingService = settingService;- _languageService = languageService;- }-- /// <summary>- /// Gets a configuration page URL- /// </summary>- public override string ConfigurationUrl()- {- return GoogleAnalyticDefaults.ConfigurationUrl;- }+ return GoogleAnalyticDefaults.ConfigurationUrl;+ }- /// <summary>- /// Install plugin- /// </summary>- public override async Task Install()- {- var settings = new GoogleAnalyticsEcommerceSettings- {- GoogleId = "000000000",- TrackingScript = @"<!-- Google tag (gtag.js) -->+ /// <summary>+ /// Install plugin+ /// </summary>+ public override async Task Install()+ {+ var settings = new GoogleAnalyticsEcommerceSettings {+ GoogleId = "000000000",+ TrackingScript = @"<!-- Google tag (gtag.js) --><script async src='https://www.googletagmanager.com/gtag/js?id={GOOGLEID}'></script><script>window.dataLayer = window.dataLayer || [];@@ -47,66 +47,108 @@ namespace Widgets.GoogleAnalytics{ECOMMERCE}</script>",- EcommerceScript = "gtag('event', 'purchase', {transaction_id: '{ORDERID}', value: {TOTAL}, tax: {TAX}, shipping: {SHIP}, currency: '{CURRENCY}', city: '{CITY}', state: '{STATEPROVINCE}', country: '{COUNTRY}', items: [{DETAILS}]});",- EcommerceDetailScript = "{ item_id: '{PRODUCTID}', item_name: '{PRODUCTNAME}', item_category: '{CATEGORYNAME}', price: {UNITPRICE}, quantity: {QUANTITY} }, ",- ConsentName = "Google Analytics",- ConsentDescription = "Allows us to analyse the statistics of visits to our website."- };- await _settingService.SaveSetting(settings);-- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.GoogleAnalytics.FriendlyName", "Google Analytics");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.GoogleAnalytics.GoogleId", "ID");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.GoogleAnalytics.GoogleId.Hint", "Enter Google Analytics ID.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.GoogleAnalytics.TrackingScript", "Tracking code with {ECOMMERCE} line");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.GoogleAnalytics.TrackingScript.Hint", "Paste the tracking code generated by Google Analytics here. {GOOGLEID} and {ECOMMERCE} will be dynamically replaced.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.GoogleAnalytics.EcommerceScript", "Tracking code for {ECOMMERCE} part, with {DETAILS} line");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.GoogleAnalytics.EcommerceScript.Hint", "Paste the tracking code generated by Google analytics here. {ORDERID}, {SITE}, {TOTAL}, {TAX}, {SHIP}, {CITY}, {STATEPROVINCE}, {COUNTRY}, {DETAILS} will be dynamically replaced.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.GoogleAnalytics.EcommerceDetailScript", "Tracking code for {DETAILS} part");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.GoogleAnalytics.EcommerceDetailScript.Hint", "Paste the tracking code generated by Google analytics here. {ORDERID}, {PRODUCTSKU}, {PRODUCTNAME}, {CATEGORYNAME}, {UNITPRICE}, {QUANTITY} will be dynamically replaced.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.GoogleAnalytics.IncludingTax", "Include tax");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.GoogleAnalytics.IncludingTax.Hint", "Check to include tax when generating tracking code for {ECOMMERCE} part.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.GoogleAnalytics.AllowToDisableConsentCookie", "Allow disabling consent cookie");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.GoogleAnalytics.AllowToDisableConsentCookie.Hint", "Get or set the value to disable consent cookie");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.GoogleAnalytics.ConsentDefaultState", "Consent default state");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.GoogleAnalytics.ConsentDefaultState.Hint", "Get or set the value to consent default state");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.GoogleAnalytics.ConsentName", "Consent cookie name");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.GoogleAnalytics.ConsentName.Hint", "Get or set the value to consent cookie name");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.GoogleAnalytics.ConsentDescription", "Consent cookie description");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.GoogleAnalytics.ConsentDescription.Hint", "Get or set the value to consent cookie description");+ EcommerceScript =+ "gtag('event', 'purchase', {transaction_id: '{ORDERID}', value: {TOTAL}, tax: {TAX}, shipping: {SHIP}, currency: '{CURRENCY}', city: '{CITY}', state: '{STATEPROVINCE}', country: '{COUNTRY}', items: [{DETAILS}]});",+ EcommerceDetailScript =+ "{ item_id: '{PRODUCTID}', item_name: '{PRODUCTNAME}', item_category: '{CATEGORYNAME}', price: {UNITPRICE}, quantity: {QUANTITY} }, ",+ ConsentName = "Google Analytics",+ ConsentDescription = "Allows us to analyse the statistics of visits to our website."+ };+ await _settingService.SaveSetting(settings);- await base.Install();- }+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.FriendlyName", "Google Analytics");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.GoogleId", "ID");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.GoogleId.Hint", "Enter Google Analytics ID.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.TrackingScript", "Tracking code with {ECOMMERCE} line");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.TrackingScript.Hint",+ "Paste the tracking code generated by Google Analytics here. {GOOGLEID} and {ECOMMERCE} will be dynamically replaced.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.EcommerceScript", "Tracking code for {ECOMMERCE} part, with {DETAILS} line");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.EcommerceScript.Hint",+ "Paste the tracking code generated by Google analytics here. {ORDERID}, {SITE}, {TOTAL}, {TAX}, {SHIP}, {CITY}, {STATEPROVINCE}, {COUNTRY}, {DETAILS} will be dynamically replaced.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.EcommerceDetailScript", "Tracking code for {DETAILS} part");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.EcommerceDetailScript.Hint",+ "Paste the tracking code generated by Google analytics here. {ORDERID}, {PRODUCTSKU}, {PRODUCTNAME}, {CATEGORYNAME}, {UNITPRICE}, {QUANTITY} will be dynamically replaced.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.IncludingTax", "Include tax");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.IncludingTax.Hint",+ "Check to include tax when generating tracking code for {ECOMMERCE} part.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.AllowToDisableConsentCookie", "Allow disabling consent cookie");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.AllowToDisableConsentCookie.Hint",+ "Get or set the value to disable consent cookie");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.ConsentDefaultState", "Consent default state");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.ConsentDefaultState.Hint", "Get or set the value to consent default state");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.ConsentName", "Consent cookie name");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.ConsentName.Hint", "Get or set the value to consent cookie name");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.ConsentDescription", "Consent cookie description");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.ConsentDescription.Hint", "Get or set the value to consent cookie description");- /// <summary>- /// Uninstall plugin- /// </summary>- public override async Task Uninstall()- {- //settings- await _settingService.DeleteSetting<GoogleAnalyticsEcommerceSettings>();+ await base.Install();+ }- //locales- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.GoogleAnalytics.GoogleId");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.GoogleAnalytics.GoogleId.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.GoogleAnalytics.TrackingScript");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.GoogleAnalytics.TrackingScript.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.GoogleAnalytics.EcommerceScript");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.GoogleAnalytics.EcommerceScript.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.GoogleAnalytics.EcommerceDetailScript");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.GoogleAnalytics.EcommerceDetailScript.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.GoogleAnalytics.IncludingTax");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.GoogleAnalytics.IncludingTax.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.GoogleAnalytics.AllowToDisableConsentCookie");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.GoogleAnalytics.AllowToDisableConsentCookie.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.GoogleAnalytics.ConsentDefaultState");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.GoogleAnalytics.ConsentDefaultState.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.GoogleAnalytics.ConsentName");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.GoogleAnalytics.ConsentName.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.GoogleAnalytics.ConsentDescription");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.GoogleAnalytics.ConsentDescription.Hint");+ /// <summary>+ /// Uninstall plugin+ /// </summary>+ public override async Task Uninstall()+ {+ //settings+ await _settingService.DeleteSetting<GoogleAnalyticsEcommerceSettings>();- await base.Uninstall();- }+ //locales+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.GoogleId");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.GoogleId.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.TrackingScript");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.TrackingScript.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.EcommerceScript");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.EcommerceScript.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.EcommerceDetailScript");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.EcommerceDetailScript.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.IncludingTax");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.IncludingTax.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.AllowToDisableConsentCookie");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.AllowToDisableConsentCookie.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.ConsentDefaultState");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.ConsentDefaultState.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.ConsentName");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.ConsentName.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.ConsentDescription");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.GoogleAnalytics.ConsentDescription.Hint");+ await base.Uninstall();}-}+}\ No newline at end of filediff --git a/src/Plugins/Widgets.GoogleAnalytics/GoogleAnalyticProvider.cs b/src/Plugins/Widgets.GoogleAnalytics/GoogleAnalyticProvider.csindex 12e2faa38..a8a1bef97 100644--- a/src/Plugins/Widgets.GoogleAnalytics/GoogleAnalyticProvider.cs+++ b/src/Plugins/Widgets.GoogleAnalytics/GoogleAnalyticProvider.cs@@ -1,51 +1,49 @@using Grand.Business.Core.Interfaces.Cms;using Grand.Business.Core.Interfaces.Common.Localization;-namespace Widgets.GoogleAnalytics+namespace Widgets.GoogleAnalytics;++/// <summary>+/// Live person provider+/// </summary>+public class GoogleAnalyticProvider : IWidgetProvider{- /// <summary>- /// Live person provider- /// </summary>- public class GoogleAnalyticProvider : IWidgetProvider- {- private readonly ITranslationService _translationService;- private readonly GoogleAnalyticsEcommerceSettings _googleAnalyticsEcommerceSettings;+ private readonly GoogleAnalyticsEcommerceSettings _googleAnalyticsEcommerceSettings;+ private readonly ITranslationService _translationService;- public GoogleAnalyticProvider(- ITranslationService translationService,- GoogleAnalyticsEcommerceSettings googleAnalyticsEcommerceSettings)- {- _translationService = translationService;- _googleAnalyticsEcommerceSettings = googleAnalyticsEcommerceSettings;- }+ public GoogleAnalyticProvider(+ ITranslationService translationService,+ GoogleAnalyticsEcommerceSettings googleAnalyticsEcommerceSettings)+ {+ _translationService = translationService;+ _googleAnalyticsEcommerceSettings = googleAnalyticsEcommerceSettings;+ }- public string ConfigurationUrl => GoogleAnalyticDefaults.ConfigurationUrl;+ public string ConfigurationUrl => GoogleAnalyticDefaults.ConfigurationUrl;- public string SystemName => GoogleAnalyticDefaults.ProviderSystemName;+ public string SystemName => GoogleAnalyticDefaults.ProviderSystemName;- public string FriendlyName => _translationService.GetResource(GoogleAnalyticDefaults.FriendlyName);+ public string FriendlyName => _translationService.GetResource(GoogleAnalyticDefaults.FriendlyName);- public int Priority => _googleAnalyticsEcommerceSettings.DisplayOrder;+ public int Priority => _googleAnalyticsEcommerceSettings.DisplayOrder;- public IList<string> LimitedToStores => new List<string>();+ public IList<string> LimitedToStores => new List<string>();- public IList<string> LimitedToGroups => new List<string>();+ public IList<string> LimitedToGroups => new List<string>();- /// <summary>- /// Gets widget zones where this widget should be rendered- /// </summary>- /// <returns>Widget zones</returns>- public async Task<IList<string>> GetWidgetZones()- {- return await Task.FromResult(new List<string>- {- "body_end_html_tag_before", "clean_body_end_html_tag_before"- });- }+ /// <summary>+ /// Gets widget zones where this widget should be rendered+ /// </summary>+ /// <returns>Widget zones</returns>+ public async Task<IList<string>> GetWidgetZones()+ {+ return await Task.FromResult(new List<string> {+ "body_end_html_tag_before", "clean_body_end_html_tag_before"+ });+ }- public Task<string> GetPublicViewComponentName(string widgetZone)- {- return Task.FromResult("WidgetsGoogleAnalytics");- }+ public Task<string> GetPublicViewComponentName(string widgetZone)+ {+ return Task.FromResult("WidgetsGoogleAnalytics");}-}+}\ No newline at end of filediff --git a/src/Plugins/Widgets.GoogleAnalytics/GoogleAnalyticsConsentCookie.cs b/src/Plugins/Widgets.GoogleAnalytics/GoogleAnalyticsConsentCookie.csindex 05417bcc7..86d1e7bec 100644--- a/src/Plugins/Widgets.GoogleAnalytics/GoogleAnalyticsConsentCookie.cs+++ b/src/Plugins/Widgets.GoogleAnalytics/GoogleAnalyticsConsentCookie.cs@@ -1,32 +1,31 @@using Grand.Business.Core.Interfaces.Cms;-namespace Widgets.GoogleAnalytics+namespace Widgets.GoogleAnalytics;++public class GoogleAnalyticsConsentCookie : IConsentCookie{- public class GoogleAnalyticsConsentCookie : IConsentCookie- {- private readonly GoogleAnalyticsEcommerceSettings _googleAnalyticsEcommerceSettings;+ private readonly GoogleAnalyticsEcommerceSettings _googleAnalyticsEcommerceSettings;- public GoogleAnalyticsConsentCookie(GoogleAnalyticsEcommerceSettings googleAnalyticsEcommerceSettings)- {- _googleAnalyticsEcommerceSettings = googleAnalyticsEcommerceSettings;- }+ public GoogleAnalyticsConsentCookie(GoogleAnalyticsEcommerceSettings googleAnalyticsEcommerceSettings)+ {+ _googleAnalyticsEcommerceSettings = googleAnalyticsEcommerceSettings;+ }- public string SystemName => GoogleAnalyticDefaults.ConsentCookieSystemName;+ public string SystemName => GoogleAnalyticDefaults.ConsentCookieSystemName;- public bool AllowToDisable => _googleAnalyticsEcommerceSettings.AllowToDisableConsentCookie;+ public bool AllowToDisable => _googleAnalyticsEcommerceSettings.AllowToDisableConsentCookie;- public bool? DefaultState => _googleAnalyticsEcommerceSettings.ConsentDefaultState;+ public bool? DefaultState => _googleAnalyticsEcommerceSettings.ConsentDefaultState;- public int DisplayOrder => 10;+ public int DisplayOrder => 10;- public Task<string> FullDescription()- {- return Task.FromResult(_googleAnalyticsEcommerceSettings.ConsentDescription);- }+ public Task<string> FullDescription()+ {+ return Task.FromResult(_googleAnalyticsEcommerceSettings.ConsentDescription);+ }- public Task<string> Name()- {- return Task.FromResult(_googleAnalyticsEcommerceSettings.ConsentName);- }+ public Task<string> Name()+ {+ return Task.FromResult(_googleAnalyticsEcommerceSettings.ConsentName);}-}+}\ No newline at end of filediff --git a/src/Plugins/Widgets.GoogleAnalytics/GoogleAnalyticsEcommerceSettings.cs b/src/Plugins/Widgets.GoogleAnalytics/GoogleAnalyticsEcommerceSettings.csindex 8a1398878..5f365bf1f 100644--- a/src/Plugins/Widgets.GoogleAnalytics/GoogleAnalyticsEcommerceSettings.cs+++ b/src/Plugins/Widgets.GoogleAnalytics/GoogleAnalyticsEcommerceSettings.cs@@ -1,18 +1,17 @@using Grand.Domain.Configuration;-namespace Widgets.GoogleAnalytics+namespace Widgets.GoogleAnalytics;++public class GoogleAnalyticsEcommerceSettings : ISettings{- public class GoogleAnalyticsEcommerceSettings : ISettings- {- public string GoogleId { get; set; }- public string TrackingScript { get; set; }- public string EcommerceScript { get; set; }- public string EcommerceDetailScript { get; set; }- public bool IncludingTax { get; set; }- public bool AllowToDisableConsentCookie { get; set; }- public bool ConsentDefaultState { get; set; }- public string ConsentName { get; set; }- public string ConsentDescription { get; set; }- public int DisplayOrder { get; set; }- }+ public string GoogleId { get; set; }+ public string TrackingScript { get; set; }+ public string EcommerceScript { get; set; }+ public string EcommerceDetailScript { get; set; }+ public bool IncludingTax { get; set; }+ public bool AllowToDisableConsentCookie { get; set; }+ public bool ConsentDefaultState { get; set; }+ public string ConsentName { get; set; }+ public string ConsentDescription { get; set; }+ public int DisplayOrder { get; set; }}\ No newline at end of filediff --git a/src/Plugins/Widgets.GoogleAnalytics/Models/ConfigurationModel.cs b/src/Plugins/Widgets.GoogleAnalytics/Models/ConfigurationModel.csindex 1cbbf9b33..2badff029 100644--- a/src/Plugins/Widgets.GoogleAnalytics/Models/ConfigurationModel.cs+++ b/src/Plugins/Widgets.GoogleAnalytics/Models/ConfigurationModel.cs@@ -1,39 +1,37 @@using Grand.Infrastructure.ModelBinding;using Grand.Infrastructure.Models;-namespace Widgets.GoogleAnalytics.Models-{- public class ConfigurationModel : BaseModel- {- public string StoreScope { get; set; }+namespace Widgets.GoogleAnalytics.Models;- [GrandResourceDisplayName("Widgets.GoogleAnalytics.GoogleId")]- public string GoogleId { get; set; }+public class ConfigurationModel : BaseModel+{+ public string StoreScope { get; set; }- [GrandResourceDisplayName("Widgets.GoogleAnalytics.TrackingScript")]- //tracking code- public string TrackingScript { get; set; }+ [GrandResourceDisplayName("Widgets.GoogleAnalytics.GoogleId")]+ public string GoogleId { get; set; }- [GrandResourceDisplayName("Widgets.GoogleAnalytics.EcommerceScript")]- public string EcommerceScript { get; set; }+ [GrandResourceDisplayName("Widgets.GoogleAnalytics.TrackingScript")]+ //tracking code+ public string TrackingScript { get; set; }- [GrandResourceDisplayName("Widgets.GoogleAnalytics.EcommerceDetailScript")]- public string EcommerceDetailScript { get; set; }+ [GrandResourceDisplayName("Widgets.GoogleAnalytics.EcommerceScript")]+ public string EcommerceScript { get; set; }- [GrandResourceDisplayName("Widgets.GoogleAnalytics.IncludingTax")]- public bool IncludingTax { get; set; }+ [GrandResourceDisplayName("Widgets.GoogleAnalytics.EcommerceDetailScript")]+ public string EcommerceDetailScript { get; set; }- [GrandResourceDisplayName("Widgets.GoogleAnalytics.AllowToDisableConsentCookie")]- public bool AllowToDisableConsentCookie { get; set; }+ [GrandResourceDisplayName("Widgets.GoogleAnalytics.IncludingTax")]+ public bool IncludingTax { get; set; }- [GrandResourceDisplayName("Widgets.GoogleAnalytics.ConsentDefaultState")]- public bool ConsentDefaultState { get; set; }+ [GrandResourceDisplayName("Widgets.GoogleAnalytics.AllowToDisableConsentCookie")]+ public bool AllowToDisableConsentCookie { get; set; }- [GrandResourceDisplayName("Widgets.GoogleAnalytics.ConsentName")]- public string ConsentName { get; set; }+ [GrandResourceDisplayName("Widgets.GoogleAnalytics.ConsentDefaultState")]+ public bool ConsentDefaultState { get; set; }- [GrandResourceDisplayName("Widgets.GoogleAnalytics.ConsentDescription")]- public string ConsentDescription { get; set; }+ [GrandResourceDisplayName("Widgets.GoogleAnalytics.ConsentName")]+ public string ConsentName { get; set; }- }+ [GrandResourceDisplayName("Widgets.GoogleAnalytics.ConsentDescription")]+ public string ConsentDescription { get; set; }}\ No newline at end of filediff --git a/src/Plugins/Widgets.GoogleAnalytics/StartupApplication.cs b/src/Plugins/Widgets.GoogleAnalytics/StartupApplication.csindex fa4f6aed4..4e64f76bd 100644--- a/src/Plugins/Widgets.GoogleAnalytics/StartupApplication.cs+++ b/src/Plugins/Widgets.GoogleAnalytics/StartupApplication.cs@@ -5,22 +5,21 @@ using Microsoft.AspNetCore.Hosting;using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;-namespace Widgets.GoogleAnalytics+namespace Widgets.GoogleAnalytics;++public class StartupApplication : IStartupApplication{- public class StartupApplication : IStartupApplication+ public void ConfigureServices(IServiceCollection services, IConfiguration configuration){- public void ConfigureServices(IServiceCollection services, IConfiguration configuration)- {- services.AddScoped<IWidgetProvider, GoogleAnalyticProvider>();- services.AddScoped<IConsentCookie, GoogleAnalyticsConsentCookie>();- }+ services.AddScoped<IWidgetProvider, GoogleAnalyticProvider>();+ services.AddScoped<IConsentCookie, GoogleAnalyticsConsentCookie>();+ }- public int Priority => 10;- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)- {+ public int Priority => 10;- }- public bool BeforeConfigure => false;+ public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)+ {}-}+ public bool BeforeConfigure => false;+}\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/Areas/Admin/Controllers/WidgetsSliderController.cs b/src/Plugins/Widgets.Slider/Areas/Admin/Controllers/WidgetsSliderController.csindex 47b849f25..71d0bd18d 100644--- a/src/Plugins/Widgets.Slider/Areas/Admin/Controllers/WidgetsSliderController.cs+++ b/src/Plugins/Widgets.Slider/Areas/Admin/Controllers/WidgetsSliderController.cs@@ -1,8 +1,9 @@using Grand.Business.Core.Extensions;using Grand.Business.Core.Interfaces.Common.Configuration;+using Grand.Business.Core.Interfaces.Common.Directory;using Grand.Business.Core.Interfaces.Common.Localization;-using Grand.Business.Core.Utilities.Common.Security;using Grand.Business.Core.Interfaces.Storage;+using Grand.Business.Core.Utilities.Common.Security;using Grand.Web.Common.Controllers;using Grand.Web.Common.DataSource;using Grand.Web.Common.Filters;@@ -10,151 +11,157 @@ using Grand.Web.Common.Security.Authorization;using Microsoft.AspNetCore.Mvc;using Widgets.Slider.Models;using Widgets.Slider.Services;-using Grand.Business.Core.Interfaces.Common.Directory;-namespace Widgets.Slider.Areas.Admin.Controllers+namespace Widgets.Slider.Areas.Admin.Controllers;++[PermissionAuthorize(PermissionSystemName.Widgets)]+public class WidgetsSliderController : BaseAdminPluginController{- [PermissionAuthorize(PermissionSystemName.Widgets)]- public class WidgetsSliderController : BaseAdminPluginController+ private readonly IDateTimeService _dateTimeService;+ private readonly ILanguageService _languageService;+ private readonly IPictureService _pictureService;+ private readonly ISettingService _settingService;+ private readonly ISliderService _sliderService;+ private readonly SliderWidgetSettings _sliderWidgetSettings;+ private readonly ITranslationService _translationService;++ public WidgetsSliderController(+ IPictureService pictureService,+ ITranslationService translationService,+ ISliderService sliderService,+ ILanguageService languageService,+ ISettingService settingService,+ SliderWidgetSettings sliderWidgetSettings,+ IDateTimeService dateTimeService){- private readonly IPictureService _pictureService;- private readonly ITranslationService _translationService;- private readonly ISliderService _sliderService;- private readonly ILanguageService _languageService;- private readonly SliderWidgetSettings _sliderWidgetSettings;- private readonly ISettingService _settingService;- private readonly IDateTimeService _dateTimeService;-- public WidgetsSliderController(- IPictureService pictureService,- ITranslationService translationService,- ISliderService sliderService,- ILanguageService languageService,- ISettingService settingService,- SliderWidgetSettings sliderWidgetSettings,- IDateTimeService dateTimeService)- {- _pictureService = pictureService;- _translationService = translationService;- _sliderService = sliderService;- _languageService = languageService;- _settingService = settingService;- _sliderWidgetSettings = sliderWidgetSettings;- _dateTimeService = dateTimeService;- }- public IActionResult Configure()- {- var model = new ConfigurationModel {- DisplayOrder = _sliderWidgetSettings.DisplayOrder,- CustomerGroups = _sliderWidgetSettings.LimitedToGroups?.ToArray(),- Stores = _sliderWidgetSettings.LimitedToStores?.ToArray()- };- return View(model);- }+ _pictureService = pictureService;+ _translationService = translationService;+ _sliderService = sliderService;+ _languageService = languageService;+ _settingService = settingService;+ _sliderWidgetSettings = sliderWidgetSettings;+ _dateTimeService = dateTimeService;+ }- [HttpPost]- public IActionResult Configure(ConfigurationModel model)- {- _sliderWidgetSettings.DisplayOrder = model.DisplayOrder;- _sliderWidgetSettings.LimitedToGroups = model.CustomerGroups == null ? new List<string>() : model.CustomerGroups.ToList();- _sliderWidgetSettings.LimitedToStores = model.Stores == null ? new List<string>() : model.Stores.ToList();- _settingService.SaveSetting(_sliderWidgetSettings);- return Json("Ok");- }+ public IActionResult Configure()+ {+ var model = new ConfigurationModel {+ DisplayOrder = _sliderWidgetSettings.DisplayOrder,+ CustomerGroups = _sliderWidgetSettings.LimitedToGroups?.ToArray(),+ Stores = _sliderWidgetSettings.LimitedToStores?.ToArray()+ };+ return View(model);+ }++ [HttpPost]+ public IActionResult Configure(ConfigurationModel model)+ {+ _sliderWidgetSettings.DisplayOrder = model.DisplayOrder;+ _sliderWidgetSettings.LimitedToGroups =+ model.CustomerGroups == null ? new List<string>() : model.CustomerGroups.ToList();+ _sliderWidgetSettings.LimitedToStores = model.Stores == null ? new List<string>() : model.Stores.ToList();+ _settingService.SaveSetting(_sliderWidgetSettings);+ return Json("Ok");+ }++ [HttpPost]+ public async Task<IActionResult> List(DataSourceRequest command)+ {+ var sliders = await _sliderService.GetPictureSliders();- [HttpPost]- public async Task<IActionResult> List(DataSourceRequest command)+ var items = new List<SlideListModel>();+ foreach (var x in sliders){- var sliders = await _sliderService.GetPictureSliders();-- var items = new List<SlideListModel>();- foreach (var x in sliders)- {- var model = x.ToListModel();- var picture = await _pictureService.GetPictureById(x.PictureId);- if (picture != null)- {- model.PictureUrl = await _pictureService.GetPictureUrl(picture, 150);- }- items.Add(model);- }- var gridModel = new DataSourceResult {- Data = items,- Total = sliders.Count- };- return Json(gridModel);+ var model = x.ToListModel();+ var picture = await _pictureService.GetPictureById(x.PictureId);+ if (picture != null) model.PictureUrl = await _pictureService.GetPictureUrl(picture, 150);+ items.Add(model);}- public async Task<IActionResult> Create()+ var gridModel = new DataSourceResult {+ Data = items,+ Total = sliders.Count+ };+ return Json(gridModel);+ }++ public async Task<IActionResult> Create()+ {+ var model = new SlideModel();+ //locales+ await AddLocales(_languageService, model.Locales);++ return View(model);+ }++ [HttpPost]+ [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]+ public async Task<IActionResult> Create(SlideModel model, bool continueEditing)+ {+ if (ModelState.IsValid){- var model = new SlideModel();- //locales- await AddLocales(_languageService, model.Locales);+ var pictureSlider = model.ToEntity(_dateTimeService);+ pictureSlider.Locales = model.Locales.ToLocalizedProperty();- return View(model);+ await _sliderService.InsertPictureSlider(pictureSlider);++ Success(_translationService.GetResource("Widgets.Slider.Added"));+ return continueEditing+ ? RedirectToAction("Edit", new { id = pictureSlider.Id })+ : RedirectToAction("Configure");}- [HttpPost, ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]- public async Task<IActionResult> Create(SlideModel model, bool continueEditing)- {- if (ModelState.IsValid)- {- var pictureSlider = model.ToEntity(_dateTimeService);- pictureSlider.Locales = model.Locales.ToLocalizedProperty();- await _sliderService.InsertPictureSlider(pictureSlider);+ return View(model);+ }- Success(_translationService.GetResource("Widgets.Slider.Added"));- return continueEditing ? RedirectToAction("Edit", new { id = pictureSlider.Id }) : RedirectToAction("Configure");+ public async Task<IActionResult> Edit(string id)+ {+ var slide = await _sliderService.GetById(id);+ if (slide == null)+ return RedirectToAction("Configure");- }- return View(model);- }- public async Task<IActionResult> Edit(string id)- {- var slide = await _sliderService.GetById(id);- if (slide == null)- return RedirectToAction("Configure");+ var model = slide.ToModel(_dateTimeService);- var model = slide.ToModel(_dateTimeService);+ //locales+ await AddLocales(_languageService, model.Locales, (locale, languageId) =>+ {+ locale.Name = slide.GetTranslation(x => x.Name, languageId, false);+ locale.Description = slide.GetTranslation(x => x.Description, languageId, false);+ });- //locales- await AddLocales(_languageService, model.Locales, (locale, languageId) =>- {- locale.Name = slide.GetTranslation(x => x.Name, languageId, false);- locale.Description = slide.GetTranslation(x => x.Description, languageId, false);- });+ return View(model);+ }- return View(model);- }+ [HttpPost]+ [ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]+ public async Task<IActionResult> Edit(SlideModel model, bool continueEditing)+ {+ var pictureSlider = await _sliderService.GetById(model.Id);+ if (pictureSlider == null)+ return RedirectToAction("Configure");- [HttpPost, ArgumentNameFilter(KeyName = "save-continue", Argument = "continueEditing")]- public async Task<IActionResult> Edit(SlideModel model, bool continueEditing)+ if (ModelState.IsValid){- var pictureSlider = await _sliderService.GetById(model.Id);- if (pictureSlider == null)- return RedirectToAction("Configure");-- if (ModelState.IsValid)- {- pictureSlider = model.ToEntity(pictureSlider, _dateTimeService);- pictureSlider.Locales = model.Locales.ToLocalizedProperty();- await _sliderService.UpdatePictureSlider(pictureSlider);- Success(_translationService.GetResource("Widgets.Slider.Edited"));- return continueEditing ? RedirectToAction("Edit", new { id = pictureSlider.Id }) : RedirectToAction("Configure");-- }- return View(model);+ pictureSlider = model.ToEntity(pictureSlider, _dateTimeService);+ pictureSlider.Locales = model.Locales.ToLocalizedProperty();+ await _sliderService.UpdatePictureSlider(pictureSlider);+ Success(_translationService.GetResource("Widgets.Slider.Edited"));+ return continueEditing+ ? RedirectToAction("Edit", new { id = pictureSlider.Id })+ : RedirectToAction("Configure");}- public async Task<IActionResult> Delete(string id)- {- var pictureSlider = await _sliderService.GetById(id);- if (pictureSlider == null)- return Json(new DataSourceResult { Errors = "This pictureSlider not exists" });+ return View(model);+ }- await _sliderService.DeleteSlider(pictureSlider);+ public async Task<IActionResult> Delete(string id)+ {+ var pictureSlider = await _sliderService.GetById(id);+ if (pictureSlider == null)+ return Json(new DataSourceResult { Errors = "This pictureSlider not exists" });- return new JsonResult("");- }+ await _sliderService.DeleteSlider(pictureSlider);++ return new JsonResult("");}-}+}\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/Configure.cshtml b/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/Configure.cshtmlindex 126ea9191..c82494ee2 100644--- a/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/Configure.cshtml+++ b/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/Configure.cshtml@@ -17,7 +17,9 @@@Loc["Widgets.Slider.Manage"]</div><div class="actions btn-group btn-group-devided util-btn-margin-bottom-5">- <a href="@Url.Action("Create", "WidgetsSlider")" class="btn green"><i class="fa fa-plus"></i><span class="hidden-xs"> @Loc["Admin.Common.AddNew"] </span></a>+ <a href="@Url.Action("Create", "WidgetsSlider")" class="btn green">+ <i class="fa fa-plus"></i><span class="hidden-xs"> @Loc["Admin.Common.AddNew"] </span>+ </a></div></div><div class="x_content">@@ -115,5 +117,4 @@}]});});-</script>-+</script>\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/Create.cshtml b/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/Create.cshtmlindex 75234de5d..4cb9cf605 100644--- a/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/Create.cshtml+++ b/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/Create.cshtml@@ -5,7 +5,7 @@Layout = "_ConfigurePlugin";}<form asp-controller="WidgetsSlider" asp-action="Create" method="post" id="slider-form">-+<div class="row"><div class="col-md-12"><div class="x_panel light form-fit">@@ -13,17 +13,23 @@<div class="caption"><i class="fa fa-sitemap"></i>@Loc["Widgets.Slider.AddNew"]- <small><i class="fa fa-arrow-circle-left"></i>@Html.ActionLink(Loc["Widgets.Slider.BackToList"], "Configure")</small>+ <small>+ <i class="fa fa-arrow-circle-left"></i>@Html.ActionLink(Loc["Widgets.Slider.BackToList"], "Configure")+ </small></div><div class="actions"><div class="btn-group btn-group-devided util-btn-margin-bottom-5">- <button class="btn btn-success" type="submit" name="save"><i class="fa fa-check"></i> @Loc["Admin.Common.Save"] </button>- <button class="btn btn-success" type="submit" name="save-continue"><i class="fa fa-check-circle"></i> @Loc["Admin.Common.SaveContinue"] </button>+ <button class="btn btn-success" type="submit" name="save">+ <i class="fa fa-check"></i> @Loc["Admin.Common.Save"]+ </button>+ <button class="btn btn-success" type="submit" name="save-continue">+ <i class="fa fa-check-circle"></i> @Loc["Admin.Common.SaveContinue"]+ </button></div></div></div><div class="x_content form">- <partial name="_CreateOrUpdate.cshtml" model="Model" />+ <partial name="_CreateOrUpdate.cshtml" model="Model"/></div></div></div>diff --git a/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/Edit.cshtml b/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/Edit.cshtmlindex 71dad8fc9..aebc3982f 100644--- a/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/Edit.cshtml+++ b/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/Edit.cshtml@@ -5,7 +5,7 @@Layout = "_ConfigurePlugin";}<form asp-controller="WidgetsSlider" asp-action="Edit" method="post" id="slider-form">-+<div class="row"><div class="col-md-12"><div class="x_panel light form-fit">@@ -13,17 +13,23 @@<div class="caption"><i class="fa fa-sitemap"></i>@Loc["Widgets.Slider.Edit"]- <small><i class="fa fa-arrow-circle-left"></i>@Html.ActionLink(Loc["Widgets.Slider.BackToList"], "Configure")</small>+ <small>+ <i class="fa fa-arrow-circle-left"></i>@Html.ActionLink(Loc["Widgets.Slider.BackToList"], "Configure")+ </small></div><div class="actions"><div class="btn-group btn-group-devided util-btn-margin-bottom-5">- <button class="btn btn-success" type="submit" name="save"><i class="fa fa-check"></i> @Loc["Admin.Common.Save"] </button>- <button class="btn btn-success" type="submit" name="save-continue"><i class="fa fa-check-circle"></i> @Loc["Admin.Common.SaveContinue"] </button>+ <button class="btn btn-success" type="submit" name="save">+ <i class="fa fa-check"></i> @Loc["Admin.Common.Save"]+ </button>+ <button class="btn btn-success" type="submit" name="save-continue">+ <i class="fa fa-check-circle"></i> @Loc["Admin.Common.SaveContinue"]+ </button></div></div></div><div class="x_content form">- <partial name="_CreateOrUpdate.cshtml" model="Model" />+ <partial name="_CreateOrUpdate.cshtml" model="Model"/></div></div></div>diff --git a/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/_CreateOrUpdate.TabInfo.cshtml b/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/_CreateOrUpdate.TabInfo.cshtmlindex 4afd55f15..766a4f24f 100644--- a/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/_CreateOrUpdate.TabInfo.cshtml+++ b/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/_CreateOrUpdate.TabInfo.cshtml@@ -26,40 +26,41 @@}}</script>-@{Func<int, HelperResult> template = @<div class="form-horizontal">+@{+ Func<int, HelperResult> template = @<div class="form-horizontal"><div class="form-body"><div class="form-group">- <admin-label asp-for="@Model.Locales[item].Name" />+ <admin-label asp-for="@Model.Locales[item].Name"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="@Model.Locales[item].Name" />+ <admin-input asp-for="@Model.Locales[item].Name"/><span asp-validation-for="@Model.Locales[item].Name"></span></div></div><div class="form-group">- <admin-label asp-for="@Model.Locales[item].Description" />+ <admin-label asp-for="@Model.Locales[item].Description"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="@Model.Locales[item].Description" asp-template="Editor" />+ <admin-input asp-for="@Model.Locales[item].Description" asp-template="Editor"/><span asp-validation-for="@Model.Locales[item].Description"></span></div></div>- <input type="hidden" asp-for="@Model.Locales[item].LanguageId" />+ <input type="hidden" asp-for="@Model.Locales[item].LanguageId"/></div></div>;}<div class="form-horizontal">- <localized-editor localized-template=@template name="slide-info-localized" [email protected](c=>c.LanguageId).ToList()>+ <localized-editor localized-template="@template" name="slide-info-localized" language-ids="@Model.Locales.Select(c => c.LanguageId).ToList()"><div class="form-body"><div class="form-group">- <admin-label asp-for="Name" />+ <admin-label asp-for="Name"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="Name" />+ <admin-input asp-for="Name"/><span asp-validation-for="Name"></span></div></div><div class="form-group">- <admin-label asp-for="Description" />+ <admin-label asp-for="Description"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="Description" asp-template="Editor" />+ <admin-input asp-for="Description" asp-template="Editor"/><span asp-validation-for="Description"></span></div></div>@@ -67,92 +68,92 @@</localized-editor><div class="form-body"><div class="form-group">- <admin-label asp-for="PictureId" />+ <admin-label asp-for="PictureId"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="PictureId" />+ <admin-input asp-for="PictureId"/><span asp-validation-for="PictureId"></span></div></div><div class="form-group">- <admin-label asp-for="Link" />+ <admin-label asp-for="Link"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="Link" />+ <admin-input asp-for="Link"/><span asp-validation-for="Link"></span></div></div><div class="form-group">- <admin-label asp-for="Published" />+ <admin-label asp-for="Published"/><div class="col-md-9 col-sm-9"><label class="mt-checkbox mt-checkbox-outline control control-checkbox">- <admin-input asp-for="Published" />+ <admin-input asp-for="Published"/><div class="control__indicator"></div></label><span asp-validation-for="Published"></span></div></div><div class="form-group">- <admin-label asp-for="Stores" />+ <admin-label asp-for="Stores"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="Stores" />+ <admin-input asp-for="Stores"/><span asp-validation-for="Stores"></span></div></div><div class="form-group">- <admin-label asp-for="FullWidth" />+ <admin-label asp-for="FullWidth"/><div class="col-md-9 col-sm-9"><label class="mt-checkbox mt-checkbox-outline control control-checkbox">- <admin-input asp-for="FullWidth" />+ <admin-input asp-for="FullWidth"/><div class="control__indicator"></div></label><span asp-validation-for="FullWidth"></span></div></div><div class="form-group">- <admin-label asp-for="SliderTypeId" />+ <admin-label asp-for="SliderTypeId"/><div class="col-md-9 col-sm-9">- <admin-select asp-for="SliderTypeId" asp-items="((SliderType)Model.SliderTypeId).ToSelectList()" />+ <admin-select asp-for="SliderTypeId" asp-items="((SliderType)Model.SliderTypeId).ToSelectList()"/><span asp-validation-for="SliderTypeId"></span></div></div><div class="form-group" id="pnlCategory">- <admin-label asp-for="CategoryId" />+ <admin-label asp-for="CategoryId"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="CategoryId" />+ <admin-input asp-for="CategoryId"/><span asp-validation-for="CategoryId"></span></div></div><div class="form-group" id="pnlCollection">- <admin-label asp-for="CollectionId" />+ <admin-label asp-for="CollectionId"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="CollectionId" />+ <admin-input asp-for="CollectionId"/><span asp-validation-for="CollectionId"></span></div></div><div class="form-group" id="pnlBrand">- <admin-label asp-for="BrandId" />+ <admin-label asp-for="BrandId"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="BrandId" />+ <admin-input asp-for="BrandId"/><span asp-validation-for="BrandId"></span></div></div><div class="form-group">- <admin-label asp-for="DisplayOrder" />+ <admin-label asp-for="DisplayOrder"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="DisplayOrder" />+ <admin-input asp-for="DisplayOrder"/><span asp-validation-for="DisplayOrder"></span></div></div><div class="form-group">- <admin-label asp-for="StartDateUtc" />+ <admin-label asp-for="StartDateUtc"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="StartDateUtc" />+ <admin-input asp-for="StartDateUtc"/></div></div><div class="form-group">- <admin-label asp-for="EndDateUtc" />+ <admin-label asp-for="EndDateUtc"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="EndDateUtc" />+ <admin-input asp-for="EndDateUtc"/></div></div></div>-</div>+</div>\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/_CreateOrUpdate.cshtml b/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/_CreateOrUpdate.cshtmlindex 12d308258..bff7835a5 100644--- a/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/_CreateOrUpdate.cshtml+++ b/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/_CreateOrUpdate.cshtml@@ -1,14 +1,14 @@@model SlideModel<div asp-validation-summary="All"></div>-<input asp-for="Id" type="hidden" />+<input asp-for="Id" type="hidden"/><admin-tabstrip name="slide-edit"><items><tabstrip-item text="@Loc["Widgets.Slider.Info"]" tab-index="0"><content><div>- <partial name="_CreateOrUpdate.TabInfo.cshtml" model="Model" />+ <partial name="_CreateOrUpdate.TabInfo.cshtml" model="Model"/></div></content>- </tabstrip-item>+ </tabstrip-item></items></admin-tabstrip>\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/_Settings.cshtml b/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/_Settings.cshtmlindex dfdea55a4..492b755f9 100644--- a/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/_Settings.cshtml+++ b/src/Plugins/Widgets.Slider/Areas/Admin/Views/WidgetsSlider/_Settings.cshtml@@ -1,6 +1,7 @@-@model ConfigurationModel+@using Widgets.Slider+@model ConfigurationModel-@inject Widgets.Slider.SliderWidgetSettings setting+@inject SliderWidgetSettings setting<form method="post" id="widget-settings-form"><div class="panel-group">@@ -9,28 +10,28 @@<div class="form-body"><div class="form-group"><div class="col-md-3 col-sm-3 text-right">- <admin-label asp-for="DisplayOrder" class="control-label" />+ <admin-label asp-for="DisplayOrder" class="control-label"/></div><div class="col-md-9 col-sm-9">- <admin-input asp-for="DisplayOrder" />+ <admin-input asp-for="DisplayOrder"/></div></div><div class="form-group">- <admin-label asp-for="CustomerGroups" />+ <admin-label asp-for="CustomerGroups"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="CustomerGroups" />+ <admin-input asp-for="CustomerGroups"/><span asp-validation-for="CustomerGroups"></span></div></div><div class="form-group">- <admin-label asp-for="Stores" />+ <admin-label asp-for="Stores"/><div class="col-md-9 col-sm-9">- <admin-input asp-for="Stores" />+ <admin-input asp-for="Stores"/><span asp-validation-for="Stores"></span></div></div><div class="form-group">- <input type="button" id="savegeneralsettings" class="btn default" value="@Loc["Admin.Common.Save"]" />+ <input type="button" id="savegeneralsettings" class="btn default" value="@Loc["Admin.Common.Save"]"/><script>$(function () {$('#savegeneralsettings').click(function () {diff --git a/src/Plugins/Widgets.Slider/Areas/Admin/Views/_ViewImports.cshtml b/src/Plugins/Widgets.Slider/Areas/Admin/Views/_ViewImports.cshtmlindex 585228251..3bb6a52f0 100644--- a/src/Plugins/Widgets.Slider/Areas/Admin/Views/_ViewImports.cshtml+++ b/src/Plugins/Widgets.Slider/Areas/Admin/Views/_ViewImports.cshtml@@ -10,5 +10,6 @@@using Widgets.Slider.Domain@using Grand.Web.Common@using Grand.Web.Common.Extensions+@using Grand.Web.Common.Localization-@inject Grand.Web.Common.Localization.LocService Loc+@inject LocService Loc\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/Components/WidgetSliderComponent.cs b/src/Plugins/Widgets.Slider/Components/WidgetSliderComponent.csindex 49c62cf52..37ded1502 100644--- a/src/Plugins/Widgets.Slider/Components/WidgetSliderComponent.cs+++ b/src/Plugins/Widgets.Slider/Components/WidgetSliderComponent.cs@@ -6,81 +6,83 @@ using Widgets.Slider.Domain;using Widgets.Slider.Models;using Widgets.Slider.Services;-namespace Widgets.Slider.Components+namespace Widgets.Slider.Components;++[ViewComponent(Name = "WidgetSlider")]+public class WidgetSliderComponent : ViewComponent{- [ViewComponent(Name = "WidgetSlider")]- public class WidgetSliderComponent : ViewComponent+ private readonly IPictureService _pictureService;+ private readonly ISliderService _sliderService;+ private readonly IWorkContext _workContext;++ public WidgetSliderComponent(+ IPictureService pictureService,+ ISliderService sliderService,+ IWorkContext workContext){- private readonly IPictureService _pictureService;- private readonly ISliderService _sliderService;- private readonly IWorkContext _workContext;+ _pictureService = pictureService;+ _sliderService = sliderService;+ _workContext = workContext;+ }- public WidgetSliderComponent(- IPictureService pictureService,- ISliderService sliderService,- IWorkContext workContext)- {- _pictureService = pictureService;- _sliderService = sliderService;- _workContext = workContext;- }+ private async Task<string> GetPictureUrl(string pictureId)+ {+ var url = await _pictureService.GetPictureUrl(pictureId, showDefaultPicture: false) ?? "";++ return url;+ }- private async Task<string> GetPictureUrl(string pictureId)+ private async Task PrepareModel(IList<PictureSlider> sliders, PublicInfoModel model)+ {+ var i = 1;+ foreach (var item in sliders.OrderBy(x => x.DisplayOrder)){- var url = await _pictureService.GetPictureUrl(pictureId, showDefaultPicture: false) ?? "";+ if ((item.StartDateUtc.HasValue && item.StartDateUtc > DateTime.UtcNow) ||+ (item.EndDateUtc.HasValue && item.EndDateUtc < DateTime.UtcNow))+ continue;- return url;+ model.Slide.Add(new PublicInfoModel.Slider {+ Link = item.Link,+ PictureUrl = await GetPictureUrl(item.PictureId),+ Name = item.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),+ Description = item.GetTranslation(x => x.Description, _workContext.WorkingLanguage.Id),+ FullWidth = item.FullWidth,+ CssClass = i == 1 ? "active" : ""+ });+ i++;}+ }- private async Task PrepareModel(IList<PictureSlider> sliders, PublicInfoModel model)+ public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData = null)+ {+ var model = new PublicInfoModel();+ if (widgetZone == SliderWidgetDefaults.WidgetZoneHomePage){- var i = 1;- foreach (var item in sliders.OrderBy(x => x.DisplayOrder))- {- if ((item.StartDateUtc.HasValue && item.StartDateUtc > DateTime.UtcNow) || (item.EndDateUtc.HasValue && item.EndDateUtc < DateTime.UtcNow))- continue;+ var slides = await _sliderService.GetPictureSliders(SliderType.HomePage);+ await PrepareModel(slides, model);+ }- model.Slide.Add(new PublicInfoModel.Slider {- Link = item.Link,- PictureUrl = await GetPictureUrl(item.PictureId),- Name = item.GetTranslation(x => x.Name, _workContext.WorkingLanguage.Id),- Description = item.GetTranslation(x => x.Description, _workContext.WorkingLanguage.Id),- FullWidth = item.FullWidth,- CssClass = i == 1 ? "active" : ""- });- i++;- }+ if (widgetZone == SliderWidgetDefaults.WidgetZoneCategoryPage)+ {+ var slides = await _sliderService.GetPictureSliders(SliderType.Category, additionalData?.ToString());+ await PrepareModel(slides, model);}- public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData = null)+ if (widgetZone == SliderWidgetDefaults.WidgetZoneCollectionPage){+ var slides = await _sliderService.GetPictureSliders(SliderType.Collection, additionalData?.ToString());+ await PrepareModel(slides, model);+ }- var model = new PublicInfoModel();- if (widgetZone == SliderWidgetDefaults.WidgetZoneHomePage)- {- var slides = await _sliderService.GetPictureSliders(SliderType.HomePage);- await PrepareModel(slides, model);- }- if (widgetZone == SliderWidgetDefaults.WidgetZoneCategoryPage)- {- var slides = await _sliderService.GetPictureSliders(SliderType.Category, additionalData?.ToString());- await PrepareModel(slides, model);- }- if (widgetZone == SliderWidgetDefaults.WidgetZoneCollectionPage)- {- var slides = await _sliderService.GetPictureSliders(SliderType.Collection, additionalData?.ToString());- await PrepareModel(slides, model);- }- if (widgetZone == SliderWidgetDefaults.WidgetZoneBrandPage)- {- var slides = await _sliderService.GetPictureSliders(SliderType.Brand, additionalData?.ToString());- await PrepareModel(slides, model);- }+ if (widgetZone == SliderWidgetDefaults.WidgetZoneBrandPage)+ {+ var slides = await _sliderService.GetPictureSliders(SliderType.Brand, additionalData?.ToString());+ await PrepareModel(slides, model);+ }- if (!model.Slide.Any())- return Content("");+ if (!model.Slide.Any())+ return Content("");- return View(model);- }+ return View(model);}}\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/Domain/PictureSlider.cs b/src/Plugins/Widgets.Slider/Domain/PictureSlider.csindex 43ee2bc77..ba1b5aa89 100644--- a/src/Plugins/Widgets.Slider/Domain/PictureSlider.cs+++ b/src/Plugins/Widgets.Slider/Domain/PictureSlider.cs@@ -2,23 +2,22 @@using Grand.Domain.Localization;using Grand.Domain.Stores;-namespace Widgets.Slider.Domain+namespace Widgets.Slider.Domain;++public class PictureSlider : BaseEntity, ITranslationEntity, IStoreLinkEntity{- public class PictureSlider : BaseEntity, ITranslationEntity, IStoreLinkEntity- {- public string PictureId { get; set; }- public string Name { get; set; }- public string Description { get; set; }- public string Link { get; set; }- public int DisplayOrder { get; set; }- public bool FullWidth { get; set; }- public bool Published { get; set; }- public string ObjectEntry { get; set; }- public SliderType SliderTypeId { get; set; }- public bool LimitedToStores { get; set; }- public IList<string> Stores { get; set; } = new List<string>();- public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();- public DateTime? StartDateUtc { get; set; }- public DateTime? EndDateUtc { get; set; }- }-}+ public string PictureId { get; set; }+ public string Name { get; set; }+ public string Description { get; set; }+ public string Link { get; set; }+ public int DisplayOrder { get; set; }+ public bool FullWidth { get; set; }+ public bool Published { get; set; }+ public string ObjectEntry { get; set; }+ public SliderType SliderTypeId { get; set; }+ public DateTime? StartDateUtc { get; set; }+ public DateTime? EndDateUtc { get; set; }+ public bool LimitedToStores { get; set; }+ public IList<string> Stores { get; set; } = new List<string>();+ public IList<TranslationEntity> Locales { get; set; } = new List<TranslationEntity>();+}\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/Domain/SliderType.cs b/src/Plugins/Widgets.Slider/Domain/SliderType.csindex cec3274c5..494f4d769 100644--- a/src/Plugins/Widgets.Slider/Domain/SliderType.cs+++ b/src/Plugins/Widgets.Slider/Domain/SliderType.cs@@ -1,11 +1,9 @@--namespace Widgets.Slider.Domain+namespace Widgets.Slider.Domain;++public enum SliderType{- public enum SliderType- {- HomePage = 0,- Category = 1,- Collection = 2,- Brand = 3- }-}+ HomePage = 0,+ Category = 1,+ Collection = 2,+ Brand = 3+}\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/Extensions.cs b/src/Plugins/Widgets.Slider/Extensions.csindex e5e0cf8d9..4adabb6cb 100644--- a/src/Plugins/Widgets.Slider/Extensions.cs+++ b/src/Plugins/Widgets.Slider/Extensions.cs@@ -1,76 +1,76 @@-using Grand.Web.Common.Models;+using Grand.Business.Core.Interfaces.Common.Directory;using Grand.Domain.Localization;using Grand.Infrastructure.Mapper;+using Grand.Web.Common.Extensions;+using Grand.Web.Common.Models;using System.Reflection;using Widgets.Slider.Domain;using Widgets.Slider.Models;-using Grand.Business.Core.Interfaces.Common.Directory;-using Grand.Web.Common.Extensions;-namespace Widgets.Slider+namespace Widgets.Slider;++public static class MyExtensions{- public static class MyExtensions+ public static SlideModel ToModel(this PictureSlider entity, IDateTimeService dateTimeService){- public static SlideModel ToModel(this PictureSlider entity, IDateTimeService dateTimeService)- {- var slideModel = entity.MapTo<PictureSlider, SlideModel>();- slideModel.StartDateUtc = entity.StartDateUtc.ConvertToUserTime(dateTimeService);- slideModel.EndDateUtc = entity.EndDateUtc.ConvertToUserTime(dateTimeService);- return slideModel;- }+ var slideModel = entity.MapTo<PictureSlider, SlideModel>();+ slideModel.StartDateUtc = entity.StartDateUtc.ConvertToUserTime(dateTimeService);+ slideModel.EndDateUtc = entity.EndDateUtc.ConvertToUserTime(dateTimeService);+ return slideModel;+ }- public static PictureSlider ToEntity(this SlideModel model, IDateTimeService dateTimeService)- {- var pictureSlider = model.MapTo<SlideModel, PictureSlider>();- pictureSlider.StartDateUtc = model.StartDateUtc.ConvertToUtcTime(dateTimeService);- pictureSlider.EndDateUtc = model.EndDateUtc.ConvertToUtcTime(dateTimeService);- return pictureSlider;- }- public static PictureSlider ToEntity(this SlideModel model, PictureSlider destination, IDateTimeService dateTimeService)- {- var pictureSlider = model.MapTo(destination);- pictureSlider.StartDateUtc = model.StartDateUtc.ConvertToUtcTime(dateTimeService);- pictureSlider.EndDateUtc = model.EndDateUtc.ConvertToUtcTime(dateTimeService);- return pictureSlider;- }+ public static PictureSlider ToEntity(this SlideModel model, IDateTimeService dateTimeService)+ {+ var pictureSlider = model.MapTo<SlideModel, PictureSlider>();+ pictureSlider.StartDateUtc = model.StartDateUtc.ConvertToUtcTime(dateTimeService);+ pictureSlider.EndDateUtc = model.EndDateUtc.ConvertToUtcTime(dateTimeService);+ return pictureSlider;+ }- public static SlideListModel ToListModel(this PictureSlider entity)- {- return entity.MapTo<PictureSlider, SlideListModel>();- }+ public static PictureSlider ToEntity(this SlideModel model, PictureSlider destination,+ IDateTimeService dateTimeService)+ {+ var pictureSlider = model.MapTo(destination);+ pictureSlider.StartDateUtc = model.StartDateUtc.ConvertToUtcTime(dateTimeService);+ pictureSlider.EndDateUtc = model.EndDateUtc.ConvertToUtcTime(dateTimeService);+ return pictureSlider;+ }- public static List<TranslationEntity> ToLocalizedProperty<T>(this IList<T> list) where T : ILocalizedModelLocal+ public static SlideListModel ToListModel(this PictureSlider entity)+ {+ return entity.MapTo<PictureSlider, SlideListModel>();+ }++ public static List<TranslationEntity> ToLocalizedProperty<T>(this IList<T> list) where T : ILocalizedModelLocal+ {+ var local = new List<TranslationEntity>();+ foreach (var item in list){- var local = new List<TranslationEntity>();- foreach (var item in list)+ var interfaces = item.GetType().GetInterfaces();+ var props = item.GetType()+ .GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy);+ foreach (var prop in props){- Type[] interfaces = item.GetType().GetInterfaces();- PropertyInfo[] props = item.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy);- foreach (var prop in props)- {- var insert = true;+ var insert = true;- foreach (var i in interfaces)- {- if (i.HasProperty(prop.Name))- {- insert = false;- }- }+ foreach (var i in interfaces)+ if (i.HasProperty(prop.Name))+ insert = false;- if (insert && prop.GetValue(item) != null)- local.Add(new TranslationEntity {- LanguageId = item.LanguageId,- LocaleKey = prop.Name,- LocaleValue = prop.GetValue(item)?.ToString()- });- }+ if (insert && prop.GetValue(item) != null)+ local.Add(new TranslationEntity {+ LanguageId = item.LanguageId,+ LocaleKey = prop.Name,+ LocaleValue = prop.GetValue(item)?.ToString()+ });}- return local;}- public static bool HasProperty(this Type obj, string propertyName)- {- return obj.GetProperty(propertyName) != null;- }- }++ return local;+ }++ public static bool HasProperty(this Type obj, string propertyName)+ {+ return obj.GetProperty(propertyName) != null;+ }}\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/Infrastructure/Mapper/SliderMapperConfiguration.cs b/src/Plugins/Widgets.Slider/Infrastructure/Mapper/SliderMapperConfiguration.csindex 133e5b0b7..39fe2b93d 100644--- a/src/Plugins/Widgets.Slider/Infrastructure/Mapper/SliderMapperConfiguration.cs+++ b/src/Plugins/Widgets.Slider/Infrastructure/Mapper/SliderMapperConfiguration.cs@@ -3,57 +3,57 @@ using Grand.Infrastructure.Mapper;using Widgets.Slider.Domain;using Widgets.Slider.Models;-namespace Widgets.Slider.Infrastructure.Mapper+namespace Widgets.Slider.Infrastructure.Mapper;++public class SliderMapperConfiguration : Profile, IAutoMapperProfile{- public class SliderMapperConfiguration : Profile, IAutoMapperProfile+ public SliderMapperConfiguration()+ {+ CreateMap<SlideModel, PictureSlider>()+ .ForMember(dest => dest.ObjectEntry, mo => mo.MapFrom(x => SetObjectEntry(x)))+ .ForMember(dest => dest.LimitedToStores, mo => mo.MapFrom(x => x.Stores != null && x.Stores.Any()))+ .ForMember(dest => dest.Locales, mo => mo.Ignore());++ CreateMap<PictureSlider, SlideModel>()+ .ForMember(dest => dest.CategoryId, mo => mo.MapFrom(x => GetCategoryId(x)))+ .ForMember(dest => dest.CollectionId, mo => mo.MapFrom(x => GetCollectionId(x)))+ .ForMember(dest => dest.BrandId, mo => mo.MapFrom(x => GetBrandId(x)))+ .ForMember(dest => dest.Locales, mo => mo.Ignore());++ CreateMap<SlideListModel, PictureSlider>()+ .ForMember(dest => dest.Locales, mo => mo.Ignore())+ .ForMember(dest => dest.Stores, mo => mo.Ignore());++ CreateMap<PictureSlider, SlideListModel>()+ .ForMember(dest => dest.UserFields, mo => mo.Ignore())+ .ForMember(dest => dest.PictureUrl, mo => mo.Ignore());+ }++ public int Order => 0;++ private string SetObjectEntry(SlideModel model)+ {+ return model.SliderTypeId switch {+ (int)SliderType.HomePage => "",+ (int)SliderType.Category => model.CategoryId,+ (int)SliderType.Collection => model.CollectionId,+ (int)SliderType.Brand => model.BrandId,+ _ => ""+ };+ }++ private string GetCategoryId(PictureSlider pictureSlider)+ {+ return pictureSlider.SliderTypeId == SliderType.Category ? pictureSlider.ObjectEntry : "";+ }++ private string GetCollectionId(PictureSlider pictureSlider)+ {+ return pictureSlider.SliderTypeId == SliderType.Collection ? pictureSlider.ObjectEntry : "";+ }++ private string GetBrandId(PictureSlider pictureSlider){- private string SetObjectEntry(SlideModel model)- {- return model.SliderTypeId switch {- (int)SliderType.HomePage => "",- (int)SliderType.Category => model.CategoryId,- (int)SliderType.Collection => model.CollectionId,- (int)SliderType.Brand => model.BrandId,- _ => ""- };- }-- private string GetCategoryId(PictureSlider pictureSlider)- {- return pictureSlider.SliderTypeId == SliderType.Category ? pictureSlider.ObjectEntry : "";- }-- private string GetCollectionId(PictureSlider pictureSlider)- {- return pictureSlider.SliderTypeId == SliderType.Collection ? pictureSlider.ObjectEntry : "";- }-- private string GetBrandId(PictureSlider pictureSlider)- {- return pictureSlider.SliderTypeId == SliderType.Brand ? pictureSlider.ObjectEntry : "";- }-- public SliderMapperConfiguration()- {- CreateMap<SlideModel, PictureSlider>()- .ForMember(dest => dest.ObjectEntry, mo => mo.MapFrom(x => SetObjectEntry(x)))- .ForMember(dest => dest.LimitedToStores, mo => mo.MapFrom(x => x.Stores != null && x.Stores.Any()))- .ForMember(dest => dest.Locales, mo => mo.Ignore());-- CreateMap<PictureSlider, SlideModel>()- .ForMember(dest => dest.CategoryId, mo => mo.MapFrom(x => GetCategoryId(x)))- .ForMember(dest => dest.CollectionId, mo => mo.MapFrom(x => GetCollectionId(x)))- .ForMember(dest => dest.BrandId, mo => mo.MapFrom(x => GetBrandId(x)))- .ForMember(dest => dest.Locales, mo => mo.Ignore());-- CreateMap<SlideListModel, PictureSlider>()- .ForMember(dest => dest.Locales, mo => mo.Ignore())- .ForMember(dest => dest.Stores, mo => mo.Ignore());-- CreateMap<PictureSlider, SlideListModel>()- .ForMember(dest => dest.UserFields, mo => mo.Ignore())- .ForMember(dest => dest.PictureUrl, mo => mo.Ignore());- }- public int Order => 0;+ return pictureSlider.SliderTypeId == SliderType.Brand ? pictureSlider.ObjectEntry : "";}-}+}\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/Models/ConfigurationModel.cs b/src/Plugins/Widgets.Slider/Models/ConfigurationModel.csindex 4eae05adb..73fc829ce 100644--- a/src/Plugins/Widgets.Slider/Models/ConfigurationModel.cs+++ b/src/Plugins/Widgets.Slider/Models/ConfigurationModel.cs@@ -2,21 +2,19 @@using Grand.Infrastructure.Models;using System.ComponentModel.DataAnnotations;-namespace Widgets.Slider.Models+namespace Widgets.Slider.Models;++public class ConfigurationModel : BaseModel{- public class ConfigurationModel : BaseModel- {-- [GrandResourceDisplayName("Widgets.Slider.Fields.DisplayOrder")]- public int DisplayOrder { get; set; }+ [GrandResourceDisplayName("Widgets.Slider.Fields.DisplayOrder")]+ public int DisplayOrder { get; set; }- [UIHint("CustomerGroups")]- [GrandResourceDisplayName("Widgets.Slider.Fields.LimitedToGroups")]- public string[] CustomerGroups { get; set; }+ [UIHint("CustomerGroups")]+ [GrandResourceDisplayName("Widgets.Slider.Fields.LimitedToGroups")]+ public string[] CustomerGroups { get; set; }- //Store acl- [GrandResourceDisplayName("Widgets.Slider.Fields.LimitedToStores")]- [UIHint("Stores")]- public string[] Stores { get; set; }- }+ //Store acl+ [GrandResourceDisplayName("Widgets.Slider.Fields.LimitedToStores")]+ [UIHint("Stores")]+ public string[] Stores { get; set; }}\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/Models/PublicInfoModel.cs b/src/Plugins/Widgets.Slider/Models/PublicInfoModel.csindex 820db2d13..1cf2d8dde 100644--- a/src/Plugins/Widgets.Slider/Models/PublicInfoModel.cs+++ b/src/Plugins/Widgets.Slider/Models/PublicInfoModel.cs@@ -1,21 +1,18 @@using Grand.Infrastructure.Models;-namespace Widgets.Slider.Models-{- public class PublicInfoModel : BaseModel- {- public IList<Slider> Slide { get; set; } = new List<Slider>();-- public class Slider- {- public string PictureUrl { get; set; }- public string Name { get; set; }- public string Description { get; set; }- public string Link { get; set; }- public bool FullWidth { get; set; }- public string CssClass { get; set; }+namespace Widgets.Slider.Models;- }+public class PublicInfoModel : BaseModel+{+ public IList<Slider> Slide { get; set; } = new List<Slider>();+ public class Slider+ {+ public string PictureUrl { get; set; }+ public string Name { get; set; }+ public string Description { get; set; }+ public string Link { get; set; }+ public bool FullWidth { get; set; }+ public string CssClass { get; set; }}}\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/Models/SlideListModel.cs b/src/Plugins/Widgets.Slider/Models/SlideListModel.csindex 93e0346f6..3125a1934 100644--- a/src/Plugins/Widgets.Slider/Models/SlideListModel.cs+++ b/src/Plugins/Widgets.Slider/Models/SlideListModel.cs@@ -1,16 +1,14 @@using Grand.Infrastructure.Models;-namespace Widgets.Slider.Models-{- public class SlideListModel : BaseModel- {- public string Id { get; set; }- public string PictureUrl { get; set; }- public string Name { get; set; }- public string DisplayOrder { get; set; }- public string Link { get; set; }- public bool Published { get; set; }- public string ObjectType { get; set; }+namespace Widgets.Slider.Models;- }-}+public class SlideListModel : BaseModel+{+ public string Id { get; set; }+ public string PictureUrl { get; set; }+ public string Name { get; set; }+ public string DisplayOrder { get; set; }+ public string Link { get; set; }+ public bool Published { get; set; }+ public string ObjectType { get; set; }+}\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/Models/SlideModel.cs b/src/Plugins/Widgets.Slider/Models/SlideModel.csindex 57e1ad56a..3e4b9d49d 100644--- a/src/Plugins/Widgets.Slider/Models/SlideModel.cs+++ b/src/Plugins/Widgets.Slider/Models/SlideModel.cs@@ -4,74 +4,72 @@ using Grand.Web.Common.Link;using Grand.Web.Common.Models;using System.ComponentModel.DataAnnotations;-namespace Widgets.Slider.Models-{- public class SlideModel : BaseEntityModel, ILocalizedModel<SlideLocalizedModel>, IStoreLinkModel- {- [GrandResourceDisplayName("Widgets.Slider.Name")]- public string Name { get; set; }+namespace Widgets.Slider.Models;- [GrandResourceDisplayName("Widgets.Slider.Description")]- public string Description { get; set; }+public class SlideModel : BaseEntityModel, ILocalizedModel<SlideLocalizedModel>, IStoreLinkModel+{+ [GrandResourceDisplayName("Widgets.Slider.Name")]+ public string Name { get; set; }- [GrandResourceDisplayName("Widgets.Slider.Link")]- public string Link { get; set; }+ [GrandResourceDisplayName("Widgets.Slider.Description")]+ public string Description { get; set; }- [GrandResourceDisplayName("Widgets.Slider.DisplayOrder")]- public int DisplayOrder { get; set; }+ [GrandResourceDisplayName("Widgets.Slider.Link")]+ public string Link { get; set; }- [GrandResourceDisplayName("Widgets.Slider.Published")]- public bool Published { get; set; }+ [GrandResourceDisplayName("Widgets.Slider.DisplayOrder")]+ public int DisplayOrder { get; set; }- [GrandResourceDisplayName("Widgets.Slider.FullWidth")]- public bool FullWidth { get; set; }+ [GrandResourceDisplayName("Widgets.Slider.Published")]+ public bool Published { get; set; }- [GrandResourceDisplayName("Widgets.Slider.SliderType")]- public int SliderTypeId { get; set; }+ [GrandResourceDisplayName("Widgets.Slider.FullWidth")]+ public bool FullWidth { get; set; }- [GrandResourceDisplayName("Widgets.Slider.Picture")]- [UIHint("Picture")]- public string PictureId { get; set; }+ [GrandResourceDisplayName("Widgets.Slider.SliderType")]+ public int SliderTypeId { get; set; }- public IList<SlideLocalizedModel> Locales { get; set; } = new List<SlideLocalizedModel>();+ [GrandResourceDisplayName("Widgets.Slider.Picture")]+ [UIHint("Picture")]+ public string PictureId { get; set; }- //Store acl- [GrandResourceDisplayName("Widgets.Slider.LimitedToStores")]- [UIHint("Stores")]- public string[] Stores { get; set; }+ [UIHint("Category")]+ [GrandResourceDisplayName("Widgets.Slider.Category")]+ public string CategoryId { get; set; }- [UIHint("Category")]- [GrandResourceDisplayName("Widgets.Slider.Category")]- public string CategoryId { get; set; }- [UIHint("Collection")]- [GrandResourceDisplayName("Widgets.Slider.Collection")]- public string CollectionId { get; set; }+ [UIHint("Collection")]+ [GrandResourceDisplayName("Widgets.Slider.Collection")]+ public string CollectionId { get; set; }- [UIHint("Brand")]- [GrandResourceDisplayName("Widgets.Slider.Brand")]- public string BrandId { get; set; }+ [UIHint("Brand")]+ [GrandResourceDisplayName("Widgets.Slider.Brand")]+ public string BrandId { get; set; }- [GrandResourceDisplayName("Widgets.Slider.StartDate")]- [UIHint("DateTimeNullable")]- public DateTime? StartDateUtc { get; set; }+ [GrandResourceDisplayName("Widgets.Slider.StartDate")]+ [UIHint("DateTimeNullable")]+ public DateTime? StartDateUtc { get; set; }- [GrandResourceDisplayName("Widgets.Slider.EndDate")]- [UIHint("DateTimeNullable")]- public DateTime? EndDateUtc { get; set; }+ [GrandResourceDisplayName("Widgets.Slider.EndDate")]+ [UIHint("DateTimeNullable")]+ public DateTime? EndDateUtc { get; set; }- }+ public IList<SlideLocalizedModel> Locales { get; set; } = new List<SlideLocalizedModel>();- public class SlideLocalizedModel : ILocalizedModelLocal- {- public string LanguageId { get; set; }+ //Store acl+ [GrandResourceDisplayName("Widgets.Slider.LimitedToStores")]+ [UIHint("Stores")]+ public string[] Stores { get; set; }+}- [GrandResourceDisplayName("Widgets.Slider.Name")]+public class SlideLocalizedModel : ILocalizedModelLocal+{+ [GrandResourceDisplayName("Widgets.Slider.Name")]- public string Name { get; set; }+ public string Name { get; set; }- [GrandResourceDisplayName("Widgets.Slider.Description")]+ [GrandResourceDisplayName("Widgets.Slider.Description")]- public string Description { get; set; }+ public string Description { get; set; }- }-}+ public string LanguageId { get; set; }+}\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/Services/ISliderService.cs b/src/Plugins/Widgets.Slider/Services/ISliderService.csindex 19b51a58e..80c6c42a0 100644--- a/src/Plugins/Widgets.Slider/Services/ISliderService.cs+++ b/src/Plugins/Widgets.Slider/Services/ISliderService.cs@@ -1,44 +1,43 @@using Widgets.Slider.Domain;-namespace Widgets.Slider.Services+namespace Widgets.Slider.Services;++public interface ISliderService{- public interface ISliderService- {- /// <summary>- /// Delete a slider- /// </summary>- /// <param name="slide">Slide</param>- Task DeleteSlider(PictureSlider slide);+ /// <summary>+ /// Delete a slider+ /// </summary>+ /// <param name="slide">Slide</param>+ Task DeleteSlider(PictureSlider slide);- /// <summary>- /// Gets all- /// </summary>- /// <returns>Picture Sliders</returns>- Task<IList<PictureSlider>> GetPictureSliders();+ /// <summary>+ /// Gets all+ /// </summary>+ /// <returns>Picture Sliders</returns>+ Task<IList<PictureSlider>> GetPictureSliders();- /// <summary>- /// Gets by type- /// </summary>- /// <returns>Picture Sliders</returns>- Task<IList<PictureSlider>> GetPictureSliders(SliderType sliderType, string objectEntry = "");+ /// <summary>+ /// Gets by type+ /// </summary>+ /// <returns>Picture Sliders</returns>+ Task<IList<PictureSlider>> GetPictureSliders(SliderType sliderType, string objectEntry = "");- /// <summary>- /// Gets a tax rate- /// </summary>- /// <param name="slideId">Slide identifier</param>- /// <returns>Tax rate</returns>- Task<PictureSlider> GetById(string slideId);+ /// <summary>+ /// Gets a tax rate+ /// </summary>+ /// <param name="slideId">Slide identifier</param>+ /// <returns>Tax rate</returns>+ Task<PictureSlider> GetById(string slideId);- /// <summary>- /// Inserts a slide- /// </summary>- /// <param name="slide">Picture Slider</param>- Task InsertPictureSlider(PictureSlider slide);+ /// <summary>+ /// Inserts a slide+ /// </summary>+ /// <param name="slide">Picture Slider</param>+ Task InsertPictureSlider(PictureSlider slide);- /// <summary>- /// Updates slide- /// </summary>- /// <param name="slide">Picture Slider</param>- Task UpdatePictureSlider(PictureSlider slide);- }-}+ /// <summary>+ /// Updates slide+ /// </summary>+ /// <param name="slide">Picture Slider</param>+ Task UpdatePictureSlider(PictureSlider slide);+}\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/Services/SliderService.cs b/src/Plugins/Widgets.Slider/Services/SliderService.csindex 9d1d46ce5..405faeb63 100644--- a/src/Plugins/Widgets.Slider/Services/SliderService.cs+++ b/src/Plugins/Widgets.Slider/Services/SliderService.cs@@ -4,136 +4,138 @@ using Grand.Infrastructure;using Grand.Infrastructure.Caching;using Widgets.Slider.Domain;-namespace Widgets.Slider.Services+namespace Widgets.Slider.Services;++public class SliderService : ISliderService{- public class SliderService : ISliderService+ public SliderService(IRepository<PictureSlider> repositoryPictureSlider,+ IWorkContext workContext, IAclService aclService,+ ICacheBase cacheManager){- #region Fields-- private readonly IRepository<PictureSlider> _repositoryPictureSlider;- private readonly IAclService _aclService;- private readonly IWorkContext _workContext;- private readonly ICacheBase _cacheBase;-- /// <summary>- /// Key for sliders- /// </summary>- /// <remarks>- /// {0} : Store id- /// {1} : Slider type- /// {2} : Object entry / categoryId || collectionId- /// </remarks>- private const string SLIDERS_MODEL_KEY = "Grand.slider-{0}-{1}-{2}";-- private const string SLIDERS_PATTERN_KEY = "Grand.slider";-- #endregion-- public SliderService(IRepository<PictureSlider> repositoryPictureSlider,- IWorkContext workContext, IAclService aclService,- ICacheBase cacheManager)- {- _repositoryPictureSlider = repositoryPictureSlider;- _workContext = workContext;- _aclService = aclService;- _cacheBase = cacheManager;- }- /// <summary>- /// Delete a slider- /// </summary>- /// <param name="slider">Slider</param>- public virtual async Task DeleteSlider(PictureSlider slider)- {- ArgumentNullException.ThrowIfNull(slider);+ _repositoryPictureSlider = repositoryPictureSlider;+ _workContext = workContext;+ _aclService = aclService;+ _cacheBase = cacheManager;+ }- //clear cache- await _cacheBase.RemoveByPrefix(SLIDERS_PATTERN_KEY);+ /// <summary>+ /// Delete a slider+ /// </summary>+ /// <param name="slider">Slider</param>+ public virtual async Task DeleteSlider(PictureSlider slider)+ {+ ArgumentNullException.ThrowIfNull(slider);- await _repositoryPictureSlider.DeleteAsync(slider);- }+ //clear cache+ await _cacheBase.RemoveByPrefix(SLIDERS_PATTERN_KEY);- /// <summary>- /// Gets all- /// </summary>- /// <returns>Picture Sliders</returns>- public virtual async Task<IList<PictureSlider>> GetPictureSliders()- {- return await Task.FromResult(_repositoryPictureSlider.Table.OrderBy(x => x.SliderTypeId).ThenBy(x => x.DisplayOrder).ToList());- }-- /// <summary>- /// Gets by type- /// </summary>- /// <returns>Picture Sliders</returns>- public virtual async Task<IList<PictureSlider>> GetPictureSliders(SliderType sliderType, string objectEntry = "")- {- var cacheKey = string.Format(SLIDERS_MODEL_KEY, _workContext.CurrentStore.Id, sliderType.ToString(), objectEntry);- return await _cacheBase.GetAsync(cacheKey, async () =>- {- var query = from s in _repositoryPictureSlider.Table- where s.SliderTypeId == sliderType && s.Published- select s;-- if (!string.IsNullOrEmpty(objectEntry))- query = query.Where(x => x.ObjectEntry == objectEntry);-- var items = query.ToList();- return await Task.FromResult(items.Where(c => _aclService.Authorize(c, _workContext.CurrentStore.Id)).ToList());- });- }--- /// <summary>- /// Gets a tax rate- /// </summary>- /// <param name="slideId">Slide identifier</param>- /// <returns>Tax rate</returns>- public virtual Task<PictureSlider> GetById(string slideId)- {- return _repositoryPictureSlider.GetByIdAsync(slideId);- }-- /// <summary>- /// Inserts a slide- /// </summary>- /// <param name="slide">Picture Slider</param>- public virtual async Task InsertPictureSlider(PictureSlider slide)+ await _repositoryPictureSlider.DeleteAsync(slider);+ }++ /// <summary>+ /// Gets all+ /// </summary>+ /// <returns>Picture Sliders</returns>+ public virtual async Task<IList<PictureSlider>> GetPictureSliders()+ {+ return await Task.FromResult(_repositoryPictureSlider.Table.OrderBy(x => x.SliderTypeId)+ .ThenBy(x => x.DisplayOrder).ToList());+ }++ /// <summary>+ /// Gets by type+ /// </summary>+ /// <returns>Picture Sliders</returns>+ public virtual async Task<IList<PictureSlider>> GetPictureSliders(SliderType sliderType, string objectEntry = "")+ {+ var cacheKey = string.Format(SLIDERS_MODEL_KEY, _workContext.CurrentStore.Id, sliderType.ToString(),+ objectEntry);+ return await _cacheBase.GetAsync(cacheKey, async () =>{- ArgumentNullException.ThrowIfNull(slide);+ var query = from s in _repositoryPictureSlider.Table+ where s.SliderTypeId == sliderType && s.Published+ select s;- //clear cache- await _cacheBase.RemoveByPrefix(SLIDERS_PATTERN_KEY);+ if (!string.IsNullOrEmpty(objectEntry))+ query = query.Where(x => x.ObjectEntry == objectEntry);- await _repositoryPictureSlider.InsertAsync(slide);- }+ var items = query.ToList();+ return await Task.FromResult(items.Where(c => _aclService.Authorize(c, _workContext.CurrentStore.Id))+ .ToList());+ });+ }- /// <summary>- /// Updates slide- /// </summary>- /// <param name="slide">Picture Slider</param>- public virtual async Task UpdatePictureSlider(PictureSlider slide)- {- ArgumentNullException.ThrowIfNull(slide);- //clear cache- await _cacheBase.RemoveByPrefix(SLIDERS_PATTERN_KEY);+ /// <summary>+ /// Gets a tax rate+ /// </summary>+ /// <param name="slideId">Slide identifier</param>+ /// <returns>Tax rate</returns>+ public virtual Task<PictureSlider> GetById(string slideId)+ {+ return _repositoryPictureSlider.GetByIdAsync(slideId);+ }++ /// <summary>+ /// Inserts a slide+ /// </summary>+ /// <param name="slide">Picture Slider</param>+ public virtual async Task InsertPictureSlider(PictureSlider slide)+ {+ ArgumentNullException.ThrowIfNull(slide);- await _repositoryPictureSlider.UpdateAsync(slide);- }+ //clear cache+ await _cacheBase.RemoveByPrefix(SLIDERS_PATTERN_KEY);- /// <summary>- /// Delete slide- /// </summary>- /// <param name="slide">Picture Slider</param>- public virtual async Task DeletePictureSlider(PictureSlider slide)- {- ArgumentNullException.ThrowIfNull(slide);+ await _repositoryPictureSlider.InsertAsync(slide);+ }++ /// <summary>+ /// Updates slide+ /// </summary>+ /// <param name="slide">Picture Slider</param>+ public virtual async Task UpdatePictureSlider(PictureSlider slide)+ {+ ArgumentNullException.ThrowIfNull(slide);++ //clear cache+ await _cacheBase.RemoveByPrefix(SLIDERS_PATTERN_KEY);- //clear cache- await _cacheBase.RemoveByPrefix(SLIDERS_PATTERN_KEY);+ await _repositoryPictureSlider.UpdateAsync(slide);+ }++ /// <summary>+ /// Delete slide+ /// </summary>+ /// <param name="slide">Picture Slider</param>+ public virtual async Task DeletePictureSlider(PictureSlider slide)+ {+ ArgumentNullException.ThrowIfNull(slide);- await _repositoryPictureSlider.DeleteAsync(slide);- }+ //clear cache+ await _cacheBase.RemoveByPrefix(SLIDERS_PATTERN_KEY);+ await _repositoryPictureSlider.DeleteAsync(slide);}-}++ #region Fields++ private readonly IRepository<PictureSlider> _repositoryPictureSlider;+ private readonly IAclService _aclService;+ private readonly IWorkContext _workContext;+ private readonly ICacheBase _cacheBase;++ /// <summary>+ /// Key for sliders+ /// </summary>+ /// <remarks>+ /// {0} : Store id+ /// {1} : Slider type+ /// {2} : Object entry / categoryId || collectionId+ /// </remarks>+ private const string SLIDERS_MODEL_KEY = "Grand.slider-{0}-{1}-{2}";++ private const string SLIDERS_PATTERN_KEY = "Grand.slider";++ #endregion+}\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/SliderWidgetDefaults.cs b/src/Plugins/Widgets.Slider/SliderWidgetDefaults.csindex 1b3886908..eaaaf84ea 100644--- a/src/Plugins/Widgets.Slider/SliderWidgetDefaults.cs+++ b/src/Plugins/Widgets.Slider/SliderWidgetDefaults.cs@@ -1,14 +1,13 @@-namespace Widgets.Slider+namespace Widgets.Slider;++public static class SliderWidgetDefaults{- public static class SliderWidgetDefaults- {- public const string ProviderSystemName = "Widgets.Slider";- public const string FriendlyName = "Widgets.Slider.FriendlyName";- public const string ConfigurationUrl = "../WidgetsSlider/Configure";+ public const string ProviderSystemName = "Widgets.Slider";+ public const string FriendlyName = "Widgets.Slider.FriendlyName";+ public const string ConfigurationUrl = "../WidgetsSlider/Configure";- public static string WidgetZoneHomePage => "home_page_top";- public static string WidgetZoneCategoryPage => "home_page_category";- public static string WidgetZoneCollectionPage => "home_page_collection";- public static string WidgetZoneBrandPage => "home_page_brand";- }-}+ public static string WidgetZoneHomePage => "home_page_top";+ public static string WidgetZoneCategoryPage => "home_page_category";+ public static string WidgetZoneCollectionPage => "home_page_collection";+ public static string WidgetZoneBrandPage => "home_page_brand";+}\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/SliderWidgetPlugin.cs b/src/Plugins/Widgets.Slider/SliderWidgetPlugin.csindex 17502b0c5..bf27b6c28 100644--- a/src/Plugins/Widgets.Slider/SliderWidgetPlugin.cs+++ b/src/Plugins/Widgets.Slider/SliderWidgetPlugin.cs@@ -2,194 +2,271 @@ using Grand.Business.Core.Extensions;using Grand.Business.Core.Interfaces.Common.Localization;using Grand.Business.Core.Interfaces.Storage;using Grand.Data;+using Grand.Domain.Common;using Grand.Infrastructure.Plugins;using Grand.SharedKernel.Extensions;using Widgets.Slider.Domain;-namespace Widgets.Slider+namespace Widgets.Slider;++/// <summary>+/// Plugin+/// </summary>+public class SliderWidgetPlugin : BasePlugin, IPlugin{+ private readonly IDatabaseContext _databaseContext;+ private readonly ILanguageService _languageService;+ private readonly IPictureService _pictureService;+ private readonly IRepository<PictureSlider> _pictureSliderRepository;+ private readonly ITranslationService _translationService;++ public SliderWidgetPlugin(IPictureService pictureService,+ IRepository<PictureSlider> pictureSliderRepository,+ ITranslationService translationService,+ ILanguageService languageService,+ IDatabaseContext databaseContext)+ {+ _pictureService = pictureService;+ _pictureSliderRepository = pictureSliderRepository;+ _translationService = translationService;+ _languageService = languageService;+ _databaseContext = databaseContext;+ }++ /// <summary>+ /// Install plugin+ /// </summary>+ public override async Task Install()+ {+ //Create index+ await _databaseContext.CreateIndex(_pictureSliderRepository,+ OrderBuilder<PictureSlider>.Create().Ascending(x => x.SliderTypeId).Ascending(x => x.DisplayOrder),+ "SliderTypeId_DisplayOrder");++ //pictures+ var sampleImagesPath = CommonPath.MapPath("Plugins/Widgets.Slider/Assets/slider/sample-images/");+ var byte1 = await File.ReadAllBytesAsync(sampleImagesPath + "banner1.png");+ var byte2 = await File.ReadAllBytesAsync(sampleImagesPath + "banner2.png");++ var pictureSlider1 = new PictureSlider {+ DisplayOrder = 0,+ Link = "",+ Name = "Sample slider 1",+ FullWidth = true,+ Published = true,+ Description =+ "<div class=\"row slideRow justify-content-start\"><div class=\"col-lg-6 d-flex flex-column justify-content-center align-items-center\"><div><div class=\"animate-top animate__animated animate__backInDown\" >exclusive - modern - elegant</div><div class=\"animate-center-title animate__animated animate__backInLeft animate__delay-05s\">Smart watches</div><div class=\"animate-center-content animate__animated animate__backInLeft animate__delay-1s\">Go to collection and see more...</div><a href=\"/smartwatches\" class=\"animate-bottom btn btn-info animate__animated animate__backInUp animate__delay-15s\"> SHOP NOW </a></div></div></div>"+ };++ var pic1 = await _pictureService.InsertPicture(byte1, "image/png", "banner_1", reference: Reference.Widget,+ objectId: pictureSlider1.Id, validateBinary: false);+ pictureSlider1.PictureId = pic1.Id;+ await _pictureSliderRepository.InsertAsync(pictureSlider1);+++ var pictureSlider2 = new PictureSlider {+ DisplayOrder = 1,+ Link = "https://grandnode.com",+ Name = "Sample slider 2",+ FullWidth = true,+ Published = true,+ Description =+ "<div class=\"row slideRow\"><div class=\"col-md-6 offset-md-6 col-12 offset-0 d-flex flex-column justify-content-center align-items-start px-0 pr-md-3\"><div class=\"slide-title text-dark animate__animated animate__fadeInRight animate__delay-05s\"><h2 class=\"mt-0\">Redmi Note 9</h2></div><div class=\"slide-content animate__animated animate__fadeInRight animate__delay-1s\"><p class=\"mb-0\"><span>Equipped with a high-performance octa-core processor <br/> with a maximum clock frequency of 2.0 GHz.</span></p></div><div class=\"slide-price animate__animated animate__fadeInRight animate__delay-15s d-inline-flex align-items-center justify-content-start w-100 mt-2\"><p class=\"actual\">$249.00</p><p class=\"old-price\">$399.00</p></div><div class=\"slide-button animate__animated animate__fadeInRight animate__delay-2s mt-3\"><a class=\"btn btn-outline-info\" href=\"/redmi-note-9\">BUY REDMI NOTE 9</a></div></div></div>"+ };+ var pic2 = await _pictureService.InsertPicture(byte2, "image/png", "banner_2", reference: Reference.Widget,+ objectId: pictureSlider2.Id, validateBinary: false);+ pictureSlider2.PictureId = pic2.Id;++ await _pictureSliderRepository.InsertAsync(pictureSlider2);++ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Fields.DisplayOrder", "Display order");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Fields.LimitedToGroups", "Limited to groups");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Fields.LimitedToStores", "Limited to stores");+++ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.FriendlyName", "Widget Slider");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Added",+ "Slider added");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Addnew",+ "Add new slider");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.AvailableStores", "Available stores");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.AvailableStores.Hint", "Select stores for which the slider will be shown.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Backtolist", "Back to list");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Category",+ "Category");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Category.Hint", "Select the category where slider should appear.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Category.Required", "Category is required");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Description", "Description");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Description.Hint", "Enter the description of the slider");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.DisplayOrder", "Display Order");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.DisplayOrder.Hint", "The slider display order. 1 represents the first item in the list.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Edit",+ "Edit slider");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Edited",+ "Slider edited");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Fields.Displayorder", "Display Order");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Fields.Link", "Link");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Fields.ObjectType", "Slider type");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Fields.Picture", "Picture");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Fields.Published", "Published");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Fields.Title", "Title");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.FullWidth",+ "Full width");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.FullWidth.hint", "Full width");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Info",+ "Info");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.LimitedToStores", "Limited to stores");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.LimitedToStores.Hint",+ "Determines whether the slider is available only at certain stores.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Link",+ "URL");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Link.Hint",+ "Enter URL. Leave empty if you don't want this picture to be clickable.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Manage",+ "Manage Bootstrap Slider");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Collection", "Collection");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Collection.Hint", "Select the collection where slider should appear.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Collection.Required", "Collection is required");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Brand",+ "Brand");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Brand.Hint", "Select the brand where slider should appear.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Brand.Required", "Brand is required");++ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Name",+ "Name");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Name.Hint",+ "Enter the name of the slider");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Name.Required", "Name is required");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Picture",+ "Picture");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Picture.Required", "Picture is required");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Published",+ "Published");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.Published.Hint", "Specify it should be visible or not");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.SliderType", "Slider type");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService,+ "Widgets.Slider.SliderType.Hint", "Choose the slider type. Home page, category or collection page.");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Stores",+ "Stores");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.StartDate",+ "Start Date");+ await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.EndDate",+ "End Date");++ await base.Install();+ }+/// <summary>- /// Plugin+ /// Uninstall plugin/// </summary>- public class SliderWidgetPlugin : BasePlugin, IPlugin+ public override async Task Uninstall()+ {+ //clear repository+ await _pictureSliderRepository.DeleteAsync(_pictureSliderRepository.Table.ToList());++ //locales+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Added");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Addnew");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.AvailableStores");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.AvailableStores.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Backtolist");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Category");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.Category.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.Category.Required");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Description");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.Description.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.DisplayOrder");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.DisplayOrder.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Edit");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Edited");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.Fields.Displayorder");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Fields.Link");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.Fields.ObjectType");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.Fields.Picture");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.Fields.Published");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.Fields.Title");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Info");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.LimitedToStores");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.LimitedToStores.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Link");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Link.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Manage");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Collection");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.Collection.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.Collection.Required");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Brand");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Brand.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.Brand.Required");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Name");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Name.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.Name.Required");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Picture");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.Picture.Required");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Published");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.Published.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.SliderType");+ await this.DeletePluginTranslationResource(_translationService, _languageService,+ "Widgets.Slider.SliderType.Hint");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Stores");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.StartDate");+ await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.EndDate");++ await base.Uninstall();+ }++ public override string ConfigurationUrl(){- private readonly IPictureService _pictureService;- private readonly IRepository<PictureSlider> _pictureSliderRepository;- private readonly ITranslationService _translationService;- private readonly ILanguageService _languageService;- private readonly IDatabaseContext _databaseContext;-- public SliderWidgetPlugin(IPictureService pictureService,- IRepository<PictureSlider> pictureSliderRepository,- ITranslationService translationService,- ILanguageService languageService,- IDatabaseContext databaseContext)- {- _pictureService = pictureService;- _pictureSliderRepository = pictureSliderRepository;- _translationService = translationService;- _languageService = languageService;- _databaseContext = databaseContext;- }-- /// <summary>- /// Install plugin- /// </summary>- public override async Task Install()- {- //Create index- await _databaseContext.CreateIndex(_pictureSliderRepository, OrderBuilder<PictureSlider>.Create().Ascending(x => x.SliderTypeId).Ascending(x => x.DisplayOrder), "SliderTypeId_DisplayOrder");-- //pictures- var sampleImagesPath = CommonPath.MapPath("Plugins/Widgets.Slider/Assets/slider/sample-images/");- var byte1 = await File.ReadAllBytesAsync(sampleImagesPath + "banner1.png");- var byte2 = await File.ReadAllBytesAsync(sampleImagesPath + "banner2.png");-- var pictureSlider1 = new PictureSlider {- DisplayOrder = 0,- Link = "",- Name = "Sample slider 1",- FullWidth = true,- Published = true,- Description = "<div class=\"row slideRow justify-content-start\"><div class=\"col-lg-6 d-flex flex-column justify-content-center align-items-center\"><div><div class=\"animate-top animate__animated animate__backInDown\" >exclusive - modern - elegant</div><div class=\"animate-center-title animate__animated animate__backInLeft animate__delay-05s\">Smart watches</div><div class=\"animate-center-content animate__animated animate__backInLeft animate__delay-1s\">Go to collection and see more...</div><a href=\"/smartwatches\" class=\"animate-bottom btn btn-info animate__animated animate__backInUp animate__delay-15s\"> SHOP NOW </a></div></div></div>"- };-- var pic1 = await _pictureService.InsertPicture(byte1, "image/png", "banner_1",reference: Grand.Domain.Common.Reference.Widget, objectId: pictureSlider1.Id, validateBinary: false);- pictureSlider1.PictureId = pic1.Id;- await _pictureSliderRepository.InsertAsync(pictureSlider1);--- var pictureSlider2 = new PictureSlider {- DisplayOrder = 1,- Link = "https://grandnode.com",- Name = "Sample slider 2",- FullWidth = true,- Published = true,- Description = "<div class=\"row slideRow\"><div class=\"col-md-6 offset-md-6 col-12 offset-0 d-flex flex-column justify-content-center align-items-start px-0 pr-md-3\"><div class=\"slide-title text-dark animate__animated animate__fadeInRight animate__delay-05s\"><h2 class=\"mt-0\">Redmi Note 9</h2></div><div class=\"slide-content animate__animated animate__fadeInRight animate__delay-1s\"><p class=\"mb-0\"><span>Equipped with a high-performance octa-core processor <br/> with a maximum clock frequency of 2.0 GHz.</span></p></div><div class=\"slide-price animate__animated animate__fadeInRight animate__delay-15s d-inline-flex align-items-center justify-content-start w-100 mt-2\"><p class=\"actual\">$249.00</p><p class=\"old-price\">$399.00</p></div><div class=\"slide-button animate__animated animate__fadeInRight animate__delay-2s mt-3\"><a class=\"btn btn-outline-info\" href=\"/redmi-note-9\">BUY REDMI NOTE 9</a></div></div></div>"- };- var pic2 = await _pictureService.InsertPicture(byte2, "image/png", "banner_2", reference: Grand.Domain.Common.Reference.Widget, objectId: pictureSlider2.Id, validateBinary: false);- pictureSlider2.PictureId = pic2.Id;-- await _pictureSliderRepository.InsertAsync(pictureSlider2);-- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Fields.DisplayOrder", "Display order");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Fields.LimitedToGroups", "Limited to groups");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Fields.LimitedToStores", "Limited to stores");--- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.FriendlyName", "Widget Slider");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Added", "Slider added");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Addnew", "Add new slider");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.AvailableStores", "Available stores");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.AvailableStores.Hint", "Select stores for which the slider will be shown.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Backtolist", "Back to list");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Category", "Category");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Category.Hint", "Select the category where slider should appear.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Category.Required", "Category is required");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Description", "Description");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Description.Hint", "Enter the description of the slider");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.DisplayOrder", "Display Order");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.DisplayOrder.Hint", "The slider display order. 1 represents the first item in the list.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Edit", "Edit slider");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Edited", "Slider edited");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Fields.Displayorder", "Display Order");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Fields.Link", "Link");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Fields.ObjectType", "Slider type");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Fields.Picture", "Picture");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Fields.Published", "Published");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Fields.Title", "Title");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.FullWidth", "Full width");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.FullWidth.hint", "Full width");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Info", "Info");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.LimitedToStores", "Limited to stores");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.LimitedToStores.Hint", "Determines whether the slider is available only at certain stores.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Link", "URL");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Link.Hint", "Enter URL. Leave empty if you don't want this picture to be clickable.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Manage", "Manage Bootstrap Slider");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Collection", "Collection");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Collection.Hint", "Select the collection where slider should appear.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Collection.Required", "Collection is required");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Brand", "Brand");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Brand.Hint", "Select the brand where slider should appear.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Brand.Required", "Brand is required");-- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Name", "Name");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Name.Hint", "Enter the name of the slider");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Name.Required", "Name is required");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Picture", "Picture");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Picture.Required", "Picture is required");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Published", "Published");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Published.Hint", "Specify it should be visible or not");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.SliderType", "Slider type");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.SliderType.Hint", "Choose the slider type. Home page, category or collection page.");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Stores", "Stores");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.StartDate", "Start Date");- await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.EndDate", "End Date");-- await base.Install();- }-- /// <summary>- /// Uninstall plugin- /// </summary>- public override async Task Uninstall()- {-- //clear repository- await _pictureSliderRepository.DeleteAsync(_pictureSliderRepository.Table.ToList());-- //locales- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Added");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Addnew");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.AvailableStores");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.AvailableStores.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Backtolist");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Category");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Category.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Category.Required");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Description");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Description.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.DisplayOrder");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.DisplayOrder.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Edit");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Edited");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Fields.Displayorder");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Fields.Link");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Fields.ObjectType");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Fields.Picture");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Fields.Published");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Fields.Title");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Info");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.LimitedToStores");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.LimitedToStores.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Link");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Link.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Manage");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Collection");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Collection.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Collection.Required");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Brand");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Brand.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Brand.Required");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Name");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Name.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Name.Required");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Picture");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Picture.Required");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Published");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Published.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.SliderType");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.SliderType.Hint");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.Stores");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.StartDate");- await this.DeletePluginTranslationResource(_translationService, _languageService, "Widgets.Slider.EndDate");-- await base.Uninstall();- }-- public override string ConfigurationUrl()- {- return SliderWidgetDefaults.ConfigurationUrl;- }+ return SliderWidgetDefaults.ConfigurationUrl;}-}+}\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/SliderWidgetProvider.cs b/src/Plugins/Widgets.Slider/SliderWidgetProvider.csindex 2e23b1926..65706a61b 100644--- a/src/Plugins/Widgets.Slider/SliderWidgetProvider.cs+++ b/src/Plugins/Widgets.Slider/SliderWidgetProvider.cs@@ -1,50 +1,47 @@using Grand.Business.Core.Interfaces.Cms;using Grand.Business.Core.Interfaces.Common.Localization;-namespace Widgets.Slider-{- public class SliderWidgetProvider : IWidgetProvider- {- private readonly ITranslationService _translationService;- private readonly SliderWidgetSettings _sliderWidgetSettings;+namespace Widgets.Slider;- public SliderWidgetProvider(ITranslationService translationService, SliderWidgetSettings sliderWidgetSettings)- {- _translationService = translationService;- _sliderWidgetSettings = sliderWidgetSettings;- }+public class SliderWidgetProvider : IWidgetProvider+{+ private readonly SliderWidgetSettings _sliderWidgetSettings;+ private readonly ITranslationService _translationService;- public string ConfigurationUrl => SliderWidgetDefaults.ConfigurationUrl;+ public SliderWidgetProvider(ITranslationService translationService, SliderWidgetSettings sliderWidgetSettings)+ {+ _translationService = translationService;+ _sliderWidgetSettings = sliderWidgetSettings;+ }- public string SystemName => SliderWidgetDefaults.ProviderSystemName;+ public string ConfigurationUrl => SliderWidgetDefaults.ConfigurationUrl;- public string FriendlyName => _translationService.GetResource(SliderWidgetDefaults.FriendlyName);+ public string SystemName => SliderWidgetDefaults.ProviderSystemName;- public int Priority => _sliderWidgetSettings.DisplayOrder;+ public string FriendlyName => _translationService.GetResource(SliderWidgetDefaults.FriendlyName);- public IList<string> LimitedToStores => _sliderWidgetSettings.LimitedToStores;+ public int Priority => _sliderWidgetSettings.DisplayOrder;- public IList<string> LimitedToGroups => _sliderWidgetSettings.LimitedToGroups;+ public IList<string> LimitedToStores => _sliderWidgetSettings.LimitedToStores;- /// <summary>- /// Gets widget zones where this widget should be rendered- /// </summary>- /// <returns>Widget zones</returns>- public async Task<IList<string>> GetWidgetZones()- {- return await Task.FromResult(new List<string>- {- SliderWidgetDefaults.WidgetZoneHomePage,- SliderWidgetDefaults.WidgetZoneCategoryPage,- SliderWidgetDefaults.WidgetZoneCollectionPage,- SliderWidgetDefaults.WidgetZoneBrandPage- });- }+ public IList<string> LimitedToGroups => _sliderWidgetSettings.LimitedToGroups;- public Task<string> GetPublicViewComponentName(string widgetZone)- {- return Task.FromResult("WidgetSlider");- }+ /// <summary>+ /// Gets widget zones where this widget should be rendered+ /// </summary>+ /// <returns>Widget zones</returns>+ public async Task<IList<string>> GetWidgetZones()+ {+ return await Task.FromResult(new List<string> {+ SliderWidgetDefaults.WidgetZoneHomePage,+ SliderWidgetDefaults.WidgetZoneCategoryPage,+ SliderWidgetDefaults.WidgetZoneCollectionPage,+ SliderWidgetDefaults.WidgetZoneBrandPage+ });+ }+ public Task<string> GetPublicViewComponentName(string widgetZone)+ {+ return Task.FromResult("WidgetSlider");}-}+}\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/SliderWidgetSettings.cs b/src/Plugins/Widgets.Slider/SliderWidgetSettings.csindex a54e6a568..c669c5f6d 100644--- a/src/Plugins/Widgets.Slider/SliderWidgetSettings.cs+++ b/src/Plugins/Widgets.Slider/SliderWidgetSettings.cs@@ -1,12 +1,11 @@using Grand.Domain.Configuration;-namespace Widgets.Slider+namespace Widgets.Slider;++public class SliderWidgetSettings : ISettings{- public class SliderWidgetSettings : ISettings- {- public int DisplayOrder { get; set; }- public IList<string> LimitedToStores { get; set; } = new List<string>();+ public int DisplayOrder { get; set; }+ public IList<string> LimitedToStores { get; set; } = new List<string>();- public IList<string> LimitedToGroups { get; set; } = new List<string>();- }-}+ public IList<string> LimitedToGroups { get; set; } = new List<string>();+}\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/StartupApplication.cs b/src/Plugins/Widgets.Slider/StartupApplication.csindex 131d27767..fbe49b1c6 100644--- a/src/Plugins/Widgets.Slider/StartupApplication.cs+++ b/src/Plugins/Widgets.Slider/StartupApplication.cs@@ -6,22 +6,21 @@ using Microsoft.Extensions.Configuration;using Microsoft.Extensions.DependencyInjection;using Widgets.Slider.Services;-namespace Widgets.Slider+namespace Widgets.Slider;++public class StartupApplication : IStartupApplication{- public class StartupApplication : IStartupApplication+ public void ConfigureServices(IServiceCollection services, IConfiguration configuration){- public void ConfigureServices(IServiceCollection services, IConfiguration configuration)- {- services.AddScoped<IWidgetProvider, SliderWidgetProvider>();- services.AddScoped<ISliderService, SliderService>();- }+ services.AddScoped<IWidgetProvider, SliderWidgetProvider>();+ services.AddScoped<ISliderService, SliderService>();+ }- public int Priority => 10;- public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)- {+ public int Priority => 10;- }- public bool BeforeConfigure => false;+ public void Configure(IApplicationBuilder application, IWebHostEnvironment webHostEnvironment)+ {}-}+ public bool BeforeConfigure => false;+}\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/Validators/SlideValidator.cs b/src/Plugins/Widgets.Slider/Validators/SlideValidator.csindex 17254588c..3a4a70512 100644--- a/src/Plugins/Widgets.Slider/Validators/SlideValidator.cs+++ b/src/Plugins/Widgets.Slider/Validators/SlideValidator.cs@@ -4,16 +4,17 @@ using Grand.Infrastructure.Validators;using Widgets.Slider.Domain;using Widgets.Slider.Models;-namespace Widgets.Slider.Validators+namespace Widgets.Slider.Validators;++public class SliderValidator : BaseGrandValidator<SlideModel>{- public class SliderValidator : BaseGrandValidator<SlideModel>+ public SliderValidator(IEnumerable<IValidatorConsumer<SlideModel>> validators,+ ITranslationService translationService) : base(validators){- public SliderValidator(IEnumerable<IValidatorConsumer<SlideModel>> validators,- ITranslationService translationService) : base(validators)- {- RuleFor(x => x.Name).NotEmpty().WithMessage(translationService.GetResource("Widgets.Slider.Name.Required"));- RuleFor(x => x.SliderTypeId == (int)SliderType.Category && string.IsNullOrEmpty(x.CategoryId)).Equal(false).WithMessage(translationService.GetResource("Widgets.Slider.Category.Required"));- RuleFor(x => x.SliderTypeId == (int)SliderType.Collection && string.IsNullOrEmpty(x.CollectionId)).Equal(false).WithMessage(translationService.GetResource("Widgets.Slider.Collection.Required"));- }+ RuleFor(x => x.Name).NotEmpty().WithMessage(translationService.GetResource("Widgets.Slider.Name.Required"));+ RuleFor(x => x.SliderTypeId == (int)SliderType.Category && string.IsNullOrEmpty(x.CategoryId)).Equal(false)+ .WithMessage(translationService.GetResource("Widgets.Slider.Category.Required"));+ RuleFor(x => x.SliderTypeId == (int)SliderType.Collection && string.IsNullOrEmpty(x.CollectionId)).Equal(false)+ .WithMessage(translationService.GetResource("Widgets.Slider.Collection.Required"));}}\ No newline at end of filediff --git a/src/Plugins/Widgets.Slider/Views/Shared/Components/WidgetSlider/Default.cshtml b/src/Plugins/Widgets.Slider/Views/Shared/Components/WidgetSlider/Default.cshtmlindex fc895c4ab..7b7e4ec7e 100644--- a/src/Plugins/Widgets.Slider/Views/Shared/Components/WidgetSlider/Default.cshtml+++ b/src/Plugins/Widgets.Slider/Views/Shared/Components/WidgetSlider/Default.cshtml@@ -1,21 +1,42 @@-@model Widgets.Slider.Models.PublicInfoModel+@model PublicInfoModel-<link rel="stylesheet" type="text/css" asp-src="/Plugins/Widgets.Slider/Assets/vue-style.css" />+<link rel="stylesheet" type="text/css" asp-src="/Plugins/Widgets.Slider/Assets/vue-style.css"/><b-carousel id="GrandCarousel" fade controls indicators img-width="1024" img-height="267" :interval="6000">@foreach (var item in Model.Slide){if (string.IsNullOrEmpty(item.PictureUrl)){- <b-carousel-slide height="500" img-blank img-alt="Blank image" caption-html="@item.Description" @if (item.FullWidth) { <text> data-width="full" </text> } @if (!string.IsNullOrEmpty(item.Link)) { <text> class="link" onclick="window.location='@item.Link'" </text> }></b-carousel-slide>+ <b-carousel-slide height="500" img-blank img-alt="Blank image" caption-html="@item.Description"+ @if (item.FullWidth)+ {+ <text> data-width="full" </text>+ }+ @if (!string.IsNullOrEmpty(item.Link))+ {+ <text> class="link" onclick="window.location='@item.Link'" </text>+ }>+ </b-carousel-slide>}else{- <b-carousel-slide text-html="@item.Description" @if (item.FullWidth) { <text> data-width="full" class="img-desc wide-img @if (!string.IsNullOrEmpty(item.Link)) { <text> link </text> }" </text> } else { <text> class="img-desc no-wide-img @if (!string.IsNullOrEmpty(item.Link)) { <text> link </text> }" </text> } @if (!string.IsNullOrEmpty(item.Link)) { <text> onclick="window.location='@item.Link'" </text> }>+ <b-carousel-slide text-html="@item.Description"+ @if (item.FullWidth)+ {+ <text> data-width="full" class="img-desc wide-img @if (!string.IsNullOrEmpty(item.Link)) { <text> link </text> }" </text>+ }+ else+ {+ <text> class="img-desc no-wide-img @if (!string.IsNullOrEmpty(item.Link)) { <text> link </text> }" </text>+ }+ @if (!string.IsNullOrEmpty(item.Link))+ {+ <text> onclick="window.location='@item.Link'" </text>+ }><template #img><picture>- <source media="(max-width: 767px)" sizes="1px" srcset="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 1w" />- <img class="d-block img-fluid" width="1920" height="500" src="@item.PictureUrl" data-thumb="@item.PictureUrl" data-transition="" alt="@item.Name" title="" />+ <source media="(max-width: 767px)" sizes="1px" srcset="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 1w"/>+ <img class="d-block img-fluid" width="1920" height="500" src="@item.PictureUrl" data-thumb="@item.PictureUrl" data-transition="" alt="@item.Name" title=""/></picture></template></b-carousel-slide>diff --git a/src/Plugins/Widgets.Slider/Views/_ViewImports.cshtml b/src/Plugins/Widgets.Slider/Views/_ViewImports.cshtmlindex 585228251..3bb6a52f0 100644--- a/src/Plugins/Widgets.Slider/Views/_ViewImports.cshtml+++ b/src/Plugins/Widgets.Slider/Views/_ViewImports.cshtml@@ -10,5 +10,6 @@@using Widgets.Slider.Domain@using Grand.Web.Common@using Grand.Web.Common.Extensions+@using Grand.Web.Common.Localization-@inject Grand.Web.Common.Localization.LocService Loc+@inject LocService Loc\ No newline at end of file