View Shopper Account Details

Current version: 8.2

Create a page that shows various properties of a user account.

Complete the following prerequisites:

At your Visual Studio Solution setup:

  1. Controller action

    RequestResponse
    
    UserObject model = null;
    if (Sitecore.Context.User.IsAuthenticated)
    {
    	var user = Sitecore.Context.User;
    	model = user.GetCommerceProfileModel();
    }
    return View(model);
    
    
  2. View

    RequestResponse
    
    @model MVCSite.Models.Generated.UserObject
    
    <h4>Hi @Sitecore.Context.User.LocalName, could we please get some more details from you... </h4>
    
    @using (Html.BeginRouteForm(Sitecore.Mvc.Configuration.MvcSettings.SitecoreRouteName, FormMethod.Post, new { @class = "form-horizontal" }))
    {
    	@Html.Sitecore().FormHandler()
    
    	<div class="control-group">
    		@Html.LabelFor(model => model.TelephoneNumber, new {@class = "control-label"})
    		<div class="controls">
    			@Html.TextBoxFor(model => model.TelephoneNumber, new { placeholder="+1 (613) 123-1234" })
    		</div>
    	</div>
    	<div class="control-group">
    		@Html.LabelFor(model => model.Email, new {@class = "control-label"})
    		<div class="controls">
    			@Html.TextBoxFor(model => model.Email, new { placeholder="[email protected]" })
    		</div>
    	</div>
    
    

Do you have some feedback for us?

If you have suggestions for improving this article,