You are here

function commerce_addressbook_commerce_customer_profile_insert in Commerce Addressbook 7.2

Same name and namespace in other branches
  1. 7.3 commerce_addressbook.module \commerce_addressbook_commerce_customer_profile_insert()

Implements hook_commerce_customer_profile_insert().

Set the new customer profile as default if there's none.

File

./commerce_addressbook.module, line 566
Defines addressbook functionality for customer profiles, allowing them to be reused and managed on a per-user basis.

Code

function commerce_addressbook_commerce_customer_profile_insert($profile) {
  if (!empty($profile->profile_id) && $profile->uid != 0) {
    $default_profile = commerce_addressbook_get_default_profile_id($profile->uid, $profile->type);
    if (!$default_profile) {
      commerce_addressbook_set_default_profile($profile);
    }
  }
}