You are here

function merci_commerce_commerce_customer_profile_default_label in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3

1 string reference to 'merci_commerce_commerce_customer_profile_default_label'
merci_commerce_commerce_customer_profile_type_info_alter in merci_commerce/merci_commerce.module

File

merci_commerce/merci_commerce.module, line 38

Code

function merci_commerce_commerce_customer_profile_default_label($profile) {
  $label = '';

  // If the profile has a default address field...
  if (!empty($profile->commerce_customer_address)) {

    // Wrap the customer profile object for easier access to its field data.
    $profile_wrapper = entity_metadata_wrapper('commerce_customer_profile', $profile);
    if (isset($profile_wrapper->field_full_name)) {
      $label = $profile_wrapper->field_full_name
        ->value();
    }
  }

  // Return the profile ID if we couldn't derive a label from an address field.
  if (empty($label)) {
    $label = $profile->profile_id;
  }
  return $label;
}