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
Move OrderTotal Component to the ShoppingCartController
support0d54263e90fc
diff --git a/src/Web/Grand.Web/Components/OrderTotals.cs b/src/Web/Grand.Web/Components/OrderTotals.csdeleted file mode 100644index 42ad3aeec..000000000--- a/src/Web/Grand.Web/Components/OrderTotals.cs+++ /dev/null@@ -1,44 +0,0 @@-using Grand.Business.Core.Interfaces.Checkout.Orders;-using Grand.Infrastructure;-using Grand.Domain.Orders;-using Grand.Web.Common.Components;-using Grand.Web.Features.Models.ShoppingCart;-using MediatR;-using Microsoft.AspNetCore.Mvc;--namespace Grand.Web.ViewComponents-{- public class OrderTotalsViewComponent : BaseViewComponent- {- private readonly IMediator _mediator;- private readonly IShoppingCartService _shoppingCartService;- private readonly IWorkContext _workContext;-- public OrderTotalsViewComponent(- IMediator mediator,- IShoppingCartService shoppingCartService,- IWorkContext workContext)- {- _mediator = mediator;- _shoppingCartService = shoppingCartService;- _workContext = workContext;- }-- public async Task<IViewComponentResult> InvokeAsync(bool isEditable)- {- var cart = await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, ShoppingCartType.ShoppingCart, ShoppingCartType.Auctions);-- var model = await _mediator.Send(new GetOrderTotals()- {- Cart = cart,- IsEditable = isEditable,- Store = _workContext.CurrentStore,- Currency = _workContext.WorkingCurrency,- Customer = _workContext.CurrentCustomer,- Language = _workContext.WorkingLanguage,- TaxDisplayType = _workContext.TaxDisplayType- });- return View(model);- }- }-}diff --git a/src/Web/Grand.Web/Controllers/ShoppingCartController.cs b/src/Web/Grand.Web/Controllers/ShoppingCartController.csindex 680fff7ca..f70e18f39 100644--- a/src/Web/Grand.Web/Controllers/ShoppingCartController.cs+++ b/src/Web/Grand.Web/Controllers/ShoppingCartController.cs@@ -299,7 +299,22 @@ namespace Grand.Web.Controllers});return View(model);+ }+ [DenySystemAccount]+ public async Task<IActionResult> CartTotal()+ {+ var cart = await _shoppingCartService.GetShoppingCart(_workContext.CurrentStore.Id, ShoppingCartType.ShoppingCart, ShoppingCartType.Auctions);++ var model = await _mediator.Send(new GetOrderTotals() {+ Cart = cart,+ Store = _workContext.CurrentStore,+ Currency = _workContext.WorkingCurrency,+ Customer = _workContext.CurrentCustomer,+ Language = _workContext.WorkingLanguage,+ TaxDisplayType = _workContext.TaxDisplayType+ });+ return View(model);}[AutoValidateAntiforgeryToken]diff --git a/src/Web/Grand.Web/Endpoints/EndpointProvider.cs b/src/Web/Grand.Web/Endpoints/EndpointProvider.csindex 42c0c3972..68d91aa3f 100644--- a/src/Web/Grand.Web/Endpoints/EndpointProvider.cs+++ b/src/Web/Grand.Web/Endpoints/EndpointProvider.cs@@ -543,6 +543,11 @@ namespace Grand.Web.Endpoints$"{pattern}cart/summary/",new { controller = "ShoppingCart", action = "CartSummary" });+ //shopping cart total+ endpointRouteBuilder.MapControllerRoute("ShoppingCartTotal",+ $"{pattern}cart/total/",+ new { controller = "ShoppingCart", action = "CartTotal" });+//Continue shoppingendpointRouteBuilder.MapControllerRoute("ContinueShopping",$"{pattern}cart/continueshopping/",diff --git a/src/Web/Grand.Web/Views/ShoppingCart/_ModelScript.cshtml b/src/Web/Grand.Web/Views/ShoppingCart/_ModelScript.cshtmlindex 02258a75e..87108899e 100644--- a/src/Web/Grand.Web/Views/ShoppingCart/_ModelScript.cshtml+++ b/src/Web/Grand.Web/Views/ShoppingCart/_ModelScript.cshtml@@ -48,7 +48,7 @@},updateTotals() {axios({- baseURL: '/Component/Index?Name=OrderTotals',+ baseURL: '@Url.RouteUrl("ShoppingCartTotal")',method: 'get',data: null,headers: {diff --git a/src/Web/Grand.Web/wwwroot/theme/script/public.checkout.js b/src/Web/Grand.Web/wwwroot/theme/script/public.checkout.jsindex cd205cef1..a14fd3c25 100644--- a/src/Web/Grand.Web/wwwroot/theme/script/public.checkout.js+++ b/src/Web/Grand.Web/wwwroot/theme/script/public.checkout.js@@ -763,7 +763,7 @@ var vmorder = new Vue({},updateTotals() {axios({- baseURL: '/Component/Index?Name=OrderTotals',+ baseURL: '/cart/total/',method: 'get',data: null,headers: {