You are here

function commerce_uuid_commerce_customer_profile_presave in Commerce UUID 7

Implements hook_commerce_customer_profile_presave().

File

./commerce_uuid.module, line 140
Adds universally unique identifiers support to Drupal Commerce.

Code

function commerce_uuid_commerce_customer_profile_presave($profile) {
  $info = entity_get_info('commerce_customer_profile');
  if (empty($profile->profile_id) && !empty($info['uuid']) && !empty($info['entity keys']['uuid'])) {
    $uuid_key = $info['entity keys']['uuid'];
    $profile->{$uuid_key} = '';
    if (empty($profile->revision_id) && !empty($info['entity keys']['revision uuid'])) {
      $vuuid_key = $info['entity keys']['revision uuid'];
      $profile->{$vuuid_key} = '';
    }
  }
}