function theme_uc_coupon_code in Ubercart Discount Coupons 6
Same name and namespace in other branches
- 7.3 uc_coupon.admin.inc \theme_uc_coupon_code()
- 7.2 uc_coupon.admin.inc \theme_uc_coupon_code()
Show coupon code in Views.
Parameters
$coupon: The coupon object for which this code is to be formatted. $coupon->usage can optionally be set. For bulk coupons, $coupon->code should be set to the specific code to display,.
1 theme call to theme_uc_coupon_code()
- uc_coupon_handler_field_codes::render_item in views/
uc_coupon_handler_field_codes.inc - Render a single coupon code.
File
- ./
uc_coupon.admin.inc, line 1079
Code
function theme_uc_coupon_code($coupon) {
$code = $coupon->code;
$class = "uc-coupon-code";
if (isset($coupon->usage)) {
$uses = $coupon->usage['codes'][$coupon->code];
if ($coupon->max_uses == 0 || $coupon->max_uses > $uses) {
$class .= ' uc-coupon-code-available';
if (arg(0) == 'user') {
$code = l($code, "user/" . arg(1) . '/coupons/' . $coupon->cid . "/view/{$code}");
}
}
else {
$class .= ' uc-coupon-code-used';
}
}
return '<span class="' . $class . '">' . $code . '</span>';
}