You are here

function commerce_addressbook_get_default_profile_id in Commerce Addressbook 7.2

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

Returns the default profile id for a specific uid and profile type.

Parameters

$uid: The uid of the user whose default profile id should be returned.

$type: The type of customer profile to look up.

Return value

The id of the default profile if set, FALSE otherwise.

6 calls to commerce_addressbook_get_default_profile_id()
commerce_addressbook_commerce_customer_profile_delete in ./commerce_addressbook.module
Implements hook_commerce_customer_profile_delete().
commerce_addressbook_commerce_customer_profile_insert in ./commerce_addressbook.module
Implements hook_commerce_customer_profile_insert().
commerce_addressbook_commerce_customer_profile_update in ./commerce_addressbook.module
Implements hook_commerce_customer_profile_update().
commerce_addressbook_commerce_order_presave in ./commerce_addressbook.module
Implements hook_commerce_order_presave().
commerce_addressbook_customer_profile_form_submit in includes/commerce_addressbook.user.inc
Submit handler for commerce_addressbook_customer_profile_form.

... See full list

File

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

Code

function commerce_addressbook_get_default_profile_id($uid, $type) {
  $query = db_select('commerce_addressbook_defaults', 'cad')
    ->fields('cad', array(
    'profile_id',
  ))
    ->condition('uid', $uid)
    ->condition('type', $type)
    ->execute();
  $record = $query
    ->fetchObject();
  return $record ? $record->profile_id : FALSE;
}