I have edited with the [ OrderSummary.cshtml ] file to make it match my theme, but while doing so I have broke something, and I don't know what :(
Here is my code, can someone please tell me what do I need to add back to get the checkout to work as normal ?
As you can see I have removed many of the code block modules which I know for certain won't be used in my shop. But unfortunatley that has had cause on the check out.
By the way, NopCommerce uses a ThemableViewEngine locating views per theme. I assume what you meant is that you edited the original file in /Views/ShoppingCart. Instead, copy the OrderSummary.cshtml file to /Themes/<your theme>/Views/ShoppingCart and edit the copy. This file will be loaded when your theme is active.
What I suggest you do is to take back the original file from codeplex, copy it as I described and modify it while testing that things keep working.
Yes you can do that or just copy the files you actually modify to make sure to use the latest version of the views you didn't modify if you reinstall a new version of Nop in the future.
The only files right now that can't be modified out of the box are the views used as Layout because they are not processed through the view engine.
Oh so like [ _Root.cshtml ] & [ _ColumnsThree ] ? << I can't edit those for my theme only ? If I edit them, they changes will effect all other themes ?
If that is the case, then I haven't benefited much, cause my themes are radically different, that I need to edit the Layout files ! :s
What I meant is that even if you copy _Root, _ColumnsThree, etc to your theme folder, that copied version won't be used. If you modify the original files, it will affect all themes.
What I did to be able to copy those files to my theme's shared folder and have that version used is to modify the base view page to force the Layout property to load the view using the view engine (instead of just locating the view by its path).
In Nop.Web.Framework.ViewEngines.Razor.WebViewPage, add this code. What it does is take the view name out of the path, use the view engine to find the view referenced by that name and set the view's path in Layout. Once you have that, you can override the views used as Layout.
publicoverridestring Layout { get { var layout = base.Layout;
if (!string.IsNullOrEmpty(layout)) { var filename = System.IO.Path.GetFileNameWithoutExtension(layout); ViewEngineResult viewResult = System.Web.Mvc.ViewEngines.Engines.FindView(ViewContext.Controller.ControllerContext, filename, "");
if (viewResult.View != null) { layout = (viewResult.View as RazorView).ViewPath; } }
Are there any limitations or undesired side effects to the above code ?
I'm just curious .. cause if only a few lines of code allows such good functionality, why didn't the development team behind nopCommerce use it !
Thanks
PS. I sorted out the checkout issue ! I still don't know what was wrong .. but I copied original code again, and once again started taking things away !