function commerce_addressbook_get_default_profile_id in Commerce Addressbook 7.3
Same name and namespace in other branches
- 7.2 commerce_addressbook.module \commerce_addressbook_get_default_profile_id()
Returns the default customer profile id for a given user id 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.
7 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_customer_profile_form_submit in includes/
commerce_addressbook.user.inc - Submit handler for commerce_addressbook_customer_profile_form().
- commerce_addressbook_entity_view in ./
commerce_addressbook.module - Implements hook_entity_view().
File
- ./
commerce_addressbook.module, line 294 - 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) {
$results =& drupal_static(__FUNCTION__, array());
if (isset($results[$uid][$type])) {
return $results[$uid][$type];
}
$query = db_select('commerce_addressbook_defaults', 'cad')
->fields('cad', array(
'profile_id',
))
->condition('uid', $uid)
->condition('type', $type)
->execute();
$record = $query
->fetchObject();
$results[$uid][$type] = $record ? $record->profile_id : FALSE;
return $results[$uid][$type];
}