How to do the same with Nopcommerce 3.7? i search for Module folder. it is not present in nop 3.7. Please help. i want to First name insted of Email in header.
If you want to show customer first name in the header you should put the following string
you have to add 1 property to ur Header link Model for set the Name . and have to modify ur Commancontroller for model HeaderLinksModel. use @Modal.Name in the HeaderLinks.chtml
Just try replace code for HeaderLinksModel with this in controller.
//getting user name using for loop string FirstName = null; foreach (var item in customer.Addresses) { FirstName = item.FirstName; }
var model = new HeaderLinksModel { IsAuthenticated = customer.IsRegistered(), CustomerEmailUsername = customer.IsRegistered() ? (_customerSettings.UsernamesEnabled ? customer.Username : customer.Email) : "", Name = customer.IsRegistered() ? FirstName : "", //use here ShoppingCartEnabled = _permissionService.Authorize(StandardPermissionProvider.EnableShoppingCart), WishlistEnabled = _permissionService.Authorize(StandardPermissionProvider.EnableWishlist), AllowPrivateMessages = customer.IsRegistered() && _forumSettings.AllowPrivateMessages, UnreadPrivateMessages = unreadMessage, AlertMessage = alertMessage, };
you have to add 1 property to ur Header link Model for set the Name . and have to modify ur Commancontroller for model HeaderLinksModel. use @Modal.Name in the HeaderLinks.chtml
Just try replace code for HeaderLinksModel with this in controller.
//getting user name using for loop string FirstName = null; foreach (var item in customer.Addresses) { FirstName = item.FirstName; }
var model = new HeaderLinksModel { IsAuthenticated = customer.IsRegistered(), CustomerEmailUsername = customer.IsRegistered() ? (_customerSettings.UsernamesEnabled ? customer.Username : customer.Email) : "", Name = customer.IsRegistered() ? FirstName : "", //use here ShoppingCartEnabled = _permissionService.Authorize(StandardPermissionProvider.EnableShoppingCart), WishlistEnabled = _permissionService.Authorize(StandardPermissionProvider.EnableWishlist), AllowPrivateMessages = customer.IsRegistered() && _forumSettings.AllowPrivateMessages, UnreadPrivateMessages = unreadMessage, AlertMessage = alertMessage, };
You can optimize your code. If you have 100 addresses for one customer then loop goes for 100 times. And if a customer does not have any address in that case you dont get any first name. In that case you can get first name by this code
I don't understand why everyone on this forum thread is discussing how to change the code. Why doesn't this feature just work with a stable build of nopCommerce? I've recently installed the latest 3.8 and it definitely is still broken. Can we list this in the bugs/defects to be fixed in an upcoming build? This really seems very trivial and it is my opinion that it should just work correctly without users/customers having to edit their code.
Michael
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.