You are here

function theme_uc_coupon_code in Ubercart Discount Coupons 7.3

Same name and namespace in other branches
  1. 6 uc_coupon.admin.inc \theme_uc_coupon_code()
  2. 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 1078
Discount Coupons administration pages.

Code

function theme_uc_coupon_code($variables) {
  $coupon = $variables['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>';
}