Skip to content

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.

Change currency - more user friendly URL address #145

KrzysztofPajak311de8db8df9
diff --git a/src/Web/Grand.Web/Controllers/CommonController.cs b/src/Web/Grand.Web/Controllers/CommonController.cs
index a950bb247..b3ec782bf 100644
--- a/src/Web/Grand.Web/Controllers/CommonController.cs
+++ b/src/Web/Grand.Web/Controllers/CommonController.cs
@@ -210,9 +210,9 @@ namespace Grand.Web.Controllers
public virtual async Task<IActionResult> SetCurrency(
[FromServices] ICurrencyService currencyService,
[FromServices] IUserFieldService userFieldService,
- string customerCurrency, string returnUrl = "")
+ string currencyCode, string returnUrl = "")
{
- var currency = await currencyService.GetCurrencyById(customerCurrency);
+ var currency = await currencyService.GetCurrencyByCode(currencyCode);
if (currency != null)
await _workContext.SetWorkingCurrency(currency);
diff --git a/src/Web/Grand.Web/Endpoints/EndpointProvider.cs b/src/Web/Grand.Web/Endpoints/EndpointProvider.cs
index a07b31a4f..8e06d19b5 100644
--- a/src/Web/Grand.Web/Endpoints/EndpointProvider.cs
+++ b/src/Web/Grand.Web/Endpoints/EndpointProvider.cs
@@ -345,7 +345,7 @@ namespace Grand.Web.Endpoints
//change currency
endpointRouteBuilder.MapControllerRoute("ChangeCurrency",
- pattern + "changecurrency/{customercurrency}",
+ pattern + "changecurrency/{currencycode}",
new { controller = "Common", action = "SetCurrency" });
//change language
diff --git a/src/Web/Grand.Web/Views/Shared/_Selector_Currency.cshtml b/src/Web/Grand.Web/Views/Shared/_Selector_Currency.cshtml
index efb1de5f9..26654b85b 100644
--- a/src/Web/Grand.Web/Views/Shared/_Selector_Currency.cshtml
+++ b/src/Web/Grand.Web/Views/Shared/_Selector_Currency.cshtml
@@ -33,7 +33,7 @@ var currencyModel = new CurrencyModel
{
Name = x.Name,
Text = x.CurrencyCode,
- Value = Url.RouteUrl("ChangeCurrency", new { customercurrency = x.Id, returnUrl }),
+ Value = Url.RouteUrl("ChangeCurrency", new { currencyCode = x.CurrencyCode, returnUrl }),
Selected = x.Id.Equals(workContext.WorkingCurrency.Id)
});
<b-dropdown class="mr-2" text="@currencies.FirstOrDefault(x => x.Selected).Text">