function commerce_cardonfile_load_multiple_by_uid in Commerce Card on File 7.2
Loads multiple cards belonging to a specific user.
Only active cards (status = 1) are returned.
Parameters
$uid: The uid of the card owner.
$instance_id: (Optional) The instance id of the payment method.
$default_only: Whether to load only default cards. A user can have one default card per payment method used. Defaults to FALSE.
Return value
An array of card entities indexed by card_id.
5 calls to commerce_cardonfile_load_multiple_by_uid()
- commerce_cardonfile_card_form in includes/
commerce_cardonfile.pages.inc - Form callback: create or edit a card.
- commerce_cardonfile_form_alter in ./
commerce_cardonfile.module - Implements hook_form_alter().
- commerce_cardonfile_form_commerce_payment_order_transaction_add_form_alter in ./
commerce_cardonfile.module - Implements hook_form_FORM_ID_alter().
- commerce_cardonfile_order_select_card in ./
commerce_cardonfile.module - Select the card on file that can be charged for an order.
- commerce_cardonfile_user_access in ./
commerce_cardonfile.module - Determines if the current user has access to the account's stored cards.
File
- ./
commerce_cardonfile.module, line 869 - Supports card on file functionality for credit card payment methods by associating card data reference IDs from payment gateways with user accounts.
Code
function commerce_cardonfile_load_multiple_by_uid($uid, $instance_id = NULL, $default_only = FALSE) {
// Never load any cards that may be created by anonymous users.
if ($uid == 0) {
return;
}
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'commerce_cardonfile')
->propertyCondition('uid', $uid)
->propertyCondition('status', 1);
if (!empty($instance_id)) {
$query
->propertyCondition('instance_id', $instance_id);
}
if ($default_only) {
$query
->propertyCondition('instance_default', TRUE);
}
$result = $query
->execute();
if (isset($result['commerce_cardonfile'])) {
return commerce_cardonfile_load_multiple(array_keys($result['commerce_cardonfile']));
}
else {
return array();
}
}