You are here

function commerce_physical_customer_profile_phone_number_field_name in Commerce Physical Product 7

Determines the name of the phone number field of a customer profile.

Parameters

commerce_cutomer_profile $profile: The customer profile whose phone number field name should be determined.

Return value

string The name of the field to use on the customer profile to find a phone number or NULL if none was found. Defaults to field_phone or field_phone_number if available; otherwise it's up to you to alter it in a custom module since we don't want to depend on an actual phone number field.

File

./commerce_physical.module, line 420
API for working with physical product types in Drupal Commerce.

Code

function commerce_physical_customer_profile_phone_number_field_name($profile) {
  if (!empty($profile->field_phone)) {
    $field_name = 'field_phone';
  }
  elseif (!empty($profile->field_phone_number)) {
    $field_name = 'field_phone_number';
  }
  else {
    $field_name = '';
  }

  // Allow other modules to specify a different field name.
  drupal_alter('commerce_physical_customer_profile_phone_number_field_name', $field_name, $profile);
  return $field_name;
}