I have the following code in a custom plugin in NopCommerce v4.0
I am trying to Override the page of default ordertotal of IComponent in nopcommerce and try to overrride from my Plugin with given Code
ViewLocationExpander.cs
public class BundledDiscountsViewEngine : IViewLocationExpander
{
public void PopulateValues(ViewLocationExpanderContext context)
{
//nothing to do here.
}
public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations)
{
if (context.AreaName == null && context.ViewName == "Components/OrderTotals/Default")
{
viewLocations = new string[] { $"/Plugins/Demo/Views/Components/OrderTotals/{{0}}.cshtml"
}.Concat(viewLocations);
}
return viewLocations;
}
}
Nopstartup.cs
public class NopStartup : INopStartup
{
public void ConfigureServices(IServiceCollection services, IConfigurationRoot configuration)
{
services.Configure<RazorViewEngineOptions>(options =>
{
options.ViewLocationExpanders.Add(new ViewLocationExpander());
});
}
public void Configure(IApplicationBuilder application)
{
}
public int Order
{
get { return 1001; } //add after nopcommerce is done
}
}
It calling is come in ExpandViewLocations.cs file and also the path is OK but it redirect the default page of nopcommerce in Views/shared/component/OrderTotals/Default.cshtml
i have tried many different thing but didn't get any solution if any one have idea please reply
Thank you Ilyas Patel
I face the same issue , In nop 4.0 there is they take default view path you have to just declare like this
viewLocations = new string[] { $"/Plugins/Demo/Views/{{0}}.cshtml"
}.Concat(viewLocations);
It can helpful