This doesn't solve the problem of getting the First name in the header links though. This is what I had to change:
Modify the HeaderLinksModel.cs file:
using Nop.Web.Framework.Mvc;
namespace Nop.Web.Models.Common
{
public class HeaderLinksModel : BaseNopModel
{
public bool IsAuthenticated { get; set; }
public string CustomerEmailUsername { get; set; }
public bool IsCustomerImpersonated { get; set; }
// Create a new string here
public string CustomerFirstName { get; set; }
public bool DisplayAdminLink { get; set; }
public bool ShoppingCartEnabled { get; set; }
public int ShoppingCartItems { get; set; }
public bool WishlistEnabled { get; set; }
public int WishlistItems { get; set; }
public bool AllowPrivateMessages { get; set; }
public string UnreadPrivateMessages { get; set; }
public string AlertMessage { get; set; }
}
}
then modify the CommonController.cs file:
var model = new HeaderLinksModel()
{
IsAuthenticated = customer.IsRegistered(),
// Assign the customers first name to the variable
CustomerFirstName = customer.GetAttribute<string>(SystemCustomerAttributeNames.FirstName),
CustomerEmailUsername = customer.IsRegistered() ? (_customerSettings.UsernamesEnabled ? customer.Username : customer.Email) : "",
IsCustomerImpersonated = _workContext.OriginalCustomerIfImpersonated != null,
DisplayAdminLink = _permissionService.Authorize(StandardPermissionProvider.AccessAdminPanel),
ShoppingCartEnabled = _permissionService.Authorize(StandardPermissionProvider.EnableShoppingCart),
ShoppingCartItems = customer.ShoppingCartItems.Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart).ToList().GetTotalProducts(),
WishlistEnabled = _permissionService.Authorize(StandardPermissionProvider.EnableWishlist),
WishlistItems = customer.ShoppingCartItems.Where(sci => sci.ShoppingCartType == ShoppingCartType.Wishlist).ToList().GetTotalProducts(),
AllowPrivateMessages = _forumSettings.AllowPrivateMessages,
UnreadPrivateMessages = unreadMessage,
AlertMessage = alertMessage,
};
and then finally update the HeaderLinks.cshtml file:
@if (Model.IsAuthenticated)
{
// Change this line to use the first name from the model
<li><a href="@Url.RouteUrl("CustomerMyAccount")" class="account">Welcome @Model.CustomerFirstName</a></li>
<li><a href="@Url.RouteUrl("Logout")" class="ico-logout">@T("Account.Logout")</a></li>
if (Model.AllowPrivateMessages)
{
<li><a href="@Url.RouteUrl("PrivateMessages", new { tab = "" })" class="ico-inbox">@T("PrivateMessages.Inbox")</a>
@Model.UnreadPrivateMessages</li>
if (!string.IsNullOrEmpty(Model.AlertMessage))
{
//using $(document).bind instead of $(document).ready to execute the alert after tabs load (on privatemessages page)
<script type="text/javascript">
$(document).bind("ready", function () {
alert('@Model.AlertMessage');
});
</script>
}
}
}