function uc_coupon_get_bulk_code in Ubercart Discount Coupons 7.2
Same name and namespace in other branches
- 5 uc_coupon.module \uc_coupon_get_bulk_code()
- 6 uc_coupon.module \uc_coupon_get_bulk_code()
- 7.3 uc_coupon.module \uc_coupon_get_bulk_code()
Generate a single bulk coupon code.
6 calls to uc_coupon_get_bulk_code()
- uc_coupon_find in ./
uc_coupon.module - Load a coupon (single or bulk) from the supplied code.
- uc_coupon_handler_field_codes::pre_render in views/
uc_coupon_handler_field_codes.inc - Expand the coupon codes for each coupon in the result set.
- uc_coupon_print in ./
uc_coupon.admin.inc - Print a coupon, or set of bulk coupons.
- uc_coupon_purchase_view in uc_coupon_purchase/
uc_coupon_purchase.pages.inc - Display a list of purchased coupons.
- uc_coupon_tokens in ./
uc_coupon.tokens.inc - Implements hook_tokens().
File
- ./
uc_coupon.module, line 343
Code
function uc_coupon_get_bulk_code($coupon, $id) {
// If this coupon has been validated, then $coupon->code is already a bulk code.
if (isset($coupon->valid)) {
$prefix = drupal_substr($coupon->code, 0, strlen($coupon->code) - $coupon->data['bulk_length']);
}
else {
$prefix = $coupon->code;
}
$id = str_pad(dechex($id), strlen(dechex($coupon->data['bulk_number'])), '0', STR_PAD_LEFT);
$length = strlen($prefix) + $coupon->data['bulk_length'];
return strtoupper(substr($prefix . $id . md5($coupon->bulk_seed . $id), 0, $length));
}