function commerce_cardonfile_commerce_customer_profile_can_delete in Commerce Card on File 7.2
Implements hook_commerce_customer_profile_can_delete().
Don't allow a customer profile to be deleted (and trigger duplication) if it's referenced by a card.
File
- ./
commerce_cardonfile.module, line 960 - 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_commerce_customer_profile_can_delete($profile) {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'commerce_cardonfile')
->fieldCondition('commerce_cardonfile_profile', 'profile_id', $profile->profile_id)
->count();
$count = $query
->execute();
return $count == 0;
}