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


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;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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