Drupal Commerce Need Function To Retrieve Customer Profile Fields From Commerce Order I want to display some info from the Customer Profile (Customer Number, Contact Number) whenever the shopping cart view displays. I can see these fields in 'People' but obviously they are -extended- fields... when I run this:

$my_user = user_load( $user-&gt;uid );


...I get the field names for the data I want, but not the values. 

I -thought- I could do this...

$order = commerce_cart_order_load($user-&gt;uid);


...and then somehow get to the customer_profile like so:

commerce_customer_profile_load ($profile_id);


...but I have no idea how to connect the $order or the global $user->uid with the $profile_id

How does one do this?

Again, I just need to retrieve the string values of Customer Number and Contact Number.

TIA,

---JC
There are probably a few different ways to bridge that gap but here are the first 2 that spring to mind:


Use commerce_customer_profile_load_multiple instead, and make use of the $conditions parameter, e.g.

$profiles = commerce_customer_profile_load_multiple(array(), array('uid' =&gt; $order-&gt;uid));

foreach ($profiles as $profile) {
  // Make sure this is the correct profile (users can have multiple profiles)
  // and extract the field values as you would with any entity (field_get_items())
}


But the $conditions array is deprecated for core entities so probably will be for commerce entities too at some point.
Use an EntityFieldQuery to get the profiles, e.g.

$query = new EntityFieldQuery();
$query-&gt;entityCondition('entity_type', 'commerce_customer_profile')
  -&gt;propertyCondition('uid', $order-&gt;uid);

$results = $query-&gt;execute();

if (!empty($results['commerce_customer_profile'])) {
  $profiles = commerce_customer_profile_load_multiple(array_keys($results['commerce_customer_profile']));

  foreach ($profiles as $profile) {
    // ...
  }
}