function uc_coupon_handler_field_codes::pre_render in Ubercart Discount Coupons 7.2
Same name and namespace in other branches
- 6 views/uc_coupon_handler_field_codes.inc \uc_coupon_handler_field_codes::pre_render()
- 7.3 views/uc_coupon_handler_field_codes.inc \uc_coupon_handler_field_codes::pre_render()
Expand the coupon codes for each coupon in the result set.
Overrides views_handler_field::pre_render
See also
views_handler_field::pre_render()
File
- views/
uc_coupon_handler_field_codes.inc, line 53 - Views handler for a list of bulk codes based on a coupon
Class
- uc_coupon_handler_field_codes
- Generate a list of the codes associated with this coupon
Code
function pre_render($values) {
foreach ($values as $value) {
$cid = $value->{$this->field_alias};
$coupon = uc_coupon_load($cid);
// Find the maximum number of codes to display.
$limit = $coupon->bulk ? $coupon->data['bulk_number'] : 1;
if ($this->options['max_num'] && $this->options['max_num'] < $limit) {
$limit = $this->options['max_num'];
}
$coupon->usage = uc_coupon_count_usage($cid);
// List selected coupons.
for ($i = 0; $i < $limit; $i++) {
$icoupon = $limit > 1 ? clone $coupon : $coupon;
if ($coupon->bulk) {
$icoupon->code = uc_coupon_get_bulk_code($coupon, $i);
}
if ($this
->include_coupon($icoupon)) {
$this->items[$cid][] = array(
'coupon' => $icoupon,
);
}
}
}
}