function commerce_coupon_usage_evaluate_usage_build in Commerce Coupon 7.2
Inline conditions build callback: evaluate max usage for coupon.
1 string reference to 'commerce_coupon_usage_evaluate_usage_build'
- commerce_coupon_usage_inline_conditions_info in modules/
usage/ commerce_coupon_usage.module - Implements hook_inline_conditions_info().
File
- modules/
usage/ commerce_coupon_usage.module, line 110
Code
function commerce_coupon_usage_evaluate_usage_build($coupon, $max_usage) {
// Set the exclude_cart argument.
$usage = commerce_coupon_usage_get_usage($coupon->coupon_id, TRUE);
if ($usage >= $max_usage) {
// Set an error message in this static variable.
$error =& drupal_static('commerce_coupon_error_' . strtolower($coupon->code));
$error = t('Coupon has exceeded maximum number of uses.');
}
else {
return TRUE;
}
}