function uc_coupon_token_values in Ubercart Discount Coupons 6
Same name and namespace in other branches
- 5 uc_coupon_purchase/uc_coupon_purchase.module \uc_coupon_token_values()
Implementation of hook_token_values().
File
- ./
uc_coupon.module, line 1208 - Provides discount coupons for Ubercart.
Code
function uc_coupon_token_values($type, $object = NULL) {
$values = array();
switch ($type) {
case 'order':
$values['order-coupon-code'] = isset($object->data['coupon']) ? $object->data['coupon'] : '';
break;
case 'coupon':
$values['coupon-name'] = $object->name;
$values['coupon-code'] = $object->code;
if ($object->bulk) {
$codes = array();
for ($id = 0; $id < $object->data['bulk_number']; $id++) {
$codes[] = uc_coupon_get_bulk_code($object, $id);
}
$values['coupon-bulk-codes'] .= implode("\n", $codes);
}
$values['coupon-value'] = isset($object->amount) ? uc_coupon_price($object->amount) : uc_coupon_format_discount($object);
break;
}
return $values;
}