0

How to get PhoneNumber from Sitecore.Commerce.Plugin.Customers.Customer which is in CustomerDetailsComponent.

1 Answer 1

3

I was dotPeeking some of XC code and looks like it should do the trick:

var customerDetails = customer.GetComponent<CustomerDetailsComponent>();
var view = customerDetails.View?.ChildViews?.FirstOrDefault(v => v.Name.Equals("Details", StringComparison.OrdinalIgnoreCase)) as EntityView;
if (view != null)
{
   ExtendedCustomerPropertiesPolicy propertiesPolicy = context.GetPolicy<CustomerPropertiesPolicy>();    
   customerDetailsModel.PhoneNumber = view.Properties.FirstOrDefault(x => x.Name == propertiesPolicy.PhoneNumber)?.Value;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.