You are here

function uc_coupon_get_bulk_code in Ubercart Discount Coupons 5

Same name and namespace in other branches
  1. 6 uc_coupon.module \uc_coupon_get_bulk_code()
  2. 7.3 uc_coupon.module \uc_coupon_get_bulk_code()
  3. 7.2 uc_coupon.module \uc_coupon_get_bulk_code()

Generate a single bulk coupon code.

2 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_token_values in uc_coupon_purchase/uc_coupon_purchase.module
Implementation of hook_token_values().

File

./uc_coupon.module, line 796
Provides discount coupons for Ubercart.

Code

function uc_coupon_get_bulk_code($coupon, $id) {
  $id = str_pad(dechex($id), strlen(dechex($coupon->data['bulk_number'])), '0', STR_PAD_LEFT);
  $length = strlen($coupon->code) + $coupon->data['bulk_length'];
  return strtoupper(substr($coupon->code . $id . md5($coupon->bulk_seed . $id), 0, $length));
}