function commerce_coupon_get_number_of_uses in Commerce Coupon 7
Same name and namespace in other branches
- 7.2 commerce_coupon.module \commerce_coupon_get_number_of_uses()
Returns the number of uses for this coupon.
Parameters
$coupon_id: Coupon id to check.
Return value
integer Returns number of uses of the coupon in all orders.
3 calls to commerce_coupon_get_number_of_uses()
- commerce_coupon_action_get_coupon_uses in ./
commerce_coupon.rules.inc - Action to get all uses for a coupon.
- commerce_coupon_get_properties in ./
commerce_coupon.module - Callback for getting coupon properties.
- commerce_coupon_handler_field_times_used::render in includes/
views/ handlers/ commerce_coupon_handler_field_times_used.inc - Render the field.
File
- ./
commerce_coupon.module, line 800 - Coupon System for Drupal Commerce.
Code
function commerce_coupon_get_number_of_uses($coupon_id) {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'commerce_order')
->fieldCondition('commerce_coupon_order_reference', 'target_id', $coupon_id, '=');
return $query
->count()
->execute();
}