function _uc_coupon_cart_item in Ubercart Discount Coupons 7.2
Same name and namespace in other branches
- 7.3 uc_coupon.module \_uc_coupon_cart_item()
Creates a fake cart-item corrresponding to this coupon, allowing this coupon to be displayed in the cart.
Parameters
$coupon: The coupon to be displayed in the cart.
2 calls to _uc_coupon_cart_item()
- uc_coupon_form_uc_cart_checkout_form_alter in ./
uc_coupon.module - Implements hook_form_FORM_ID_alter() for uc_cart_checkout_form().
- uc_coupon_uc_cart_alter in ./
uc_coupon.module - Implements hook_uc_cart_alter().
File
- ./
uc_coupon.module, line 1651
Code
function _uc_coupon_cart_item($coupon) {
// Assign this a unique cart_item_id so it will be keyed properly by entity_view().
$id = -hexdec(substr(sha1($coupon->code), -8));
return (object) array(
'cart_item_id' => $id,
'module' => 'uc_coupon',
'title' => $coupon->title,
'nid' => 0,
'qty' => 1,
'price' => -$coupon->amount,
'data' => array(
'module' => 'uc_coupon',
'shippable' => FALSE,
'code' => $coupon->code,
'remove' => uc_coupon_session_get($coupon->code),
),
'model' => 0,
'weight' => 0,
);
}