function commerce_coupon_commerce_coupon_can_delete in Commerce Coupon 7
Implements commerce_coupon_can_delete().
File
- ./
commerce_coupon.module, line 756 - Coupon System for Drupal Commerce.
Code
function commerce_coupon_commerce_coupon_can_delete($coupon) {
// Use EntityFieldQuery to look for orders referencing this coupon and don't
// allow the delete to occur if one exists.
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'commerce_order', '=')
->fieldCondition('commerce_coupon_order_reference', 'target_id', $coupon->coupon_id, '=')
->count();
return $query
->execute() == 0;
}