You are here

function uc_coupon_print in Ubercart Discount Coupons 7.3

Same name and namespace in other branches
  1. 6 uc_coupon.admin.inc \uc_coupon_print()
  2. 7.2 uc_coupon.admin.inc \uc_coupon_print()

Print a coupon, or set of bulk coupons.

1 call to uc_coupon_print()
uc_coupon_purchase_print in uc_coupon_purchase/uc_coupon_purchase.pages.inc
Print a purchased coupon.
1 string reference to 'uc_coupon_print'
uc_coupon_menu in ./uc_coupon.module
Implements hook_menu().

File

./uc_coupon.admin.inc, line 210
Discount Coupons administration pages.

Code

function uc_coupon_print($coupon, $code = NULL, $op = 'view') {
  if ($code) {
    $codes = array(
      $code,
    );
  }
  elseif (!$coupon->bulk) {
    $codes = array(
      $coupon->code,
    );
  }
  else {
    $codes = array();
    for ($id = 0; $id < $coupon->data['bulk_number']; $id++) {
      $codes[] = uc_coupon_get_bulk_code($coupon, $id);
    }
  }
  $output = '';
  foreach ($codes as $code) {
    $output .= theme('uc_coupon_certificate', array(
      'coupon' => $coupon,
      'code' => $code,
    ));
  }
  drupal_add_css(drupal_get_path('module', 'uc_coupon') . '/uc_coupon.css');
  if ($op == 'print') {
    echo theme('uc_coupon_page', array(
      'content' => $output,
    ));
    exit;
  }
  return $output;
}