function commerce_addressbook_get_active_profiles in Commerce Addressbook 7.3
Loads the active customer profiles of the specified type for a given user.
Parameters
$uid: The uid of the user.
$type: The type of customer profile to look up.
Return value
array An array of customer profiles of the specified type for a given user.
1 call to commerce_addressbook_get_active_profiles()
- commerce_addressbook_pane_checkout_form in ./
commerce_addressbook.checkout_pane.inc - Checkout pane callback: returns a customer profile edit form.
File
- ./
commerce_addressbook.module, line 204 - Defines addressbook functionality for customer profiles, allowing them to be reused and managed on a per-user basis.
Code
function commerce_addressbook_get_active_profiles($uid, $type) {
if (!$uid) {
return array();
}
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'commerce_customer_profile')
->entityCondition('bundle', $type)
->propertyCondition('uid', $uid)
->propertyCondition('status', TRUE)
->entityOrderBy('entity_id', 'DESC')
->addTag('commerce_addressbook')
->range(0, 10);
$results = $query
->execute();
if (isset($results['commerce_customer_profile'])) {
return commerce_customer_profile_load_multiple(array_keys($results['commerce_customer_profile']));
}
return array();
}