function add_discount_line_items_to_order in Ubercart Discounts (Alternative) 6.2
Add discount line items to order
Note: assumes discount objects are the result of a call to get_discounts_for_order()
2 calls to add_discount_line_items_to_order()
- uc_checkout_pane_discounts in uc_discounts/
uc_discounts.module - Discounts checkout pane callback
- uc_discounts_apply in uc_discounts/
uc_discounts.module - Applies the discounts to an order by creating the necessary line items.
File
- uc_discounts/
uc_discounts.module, line 626
Code
function add_discount_line_items_to_order(&$order, $discounts) {
//Create line items for discounts and store in order's uc_discounts_line_items field
$line_items = array();
foreach ($discounts as $discount) {
$line_item = array(
'type' => LINE_ITEM_KEY_NAME,
'title' => $discount->short_description,
'amount' => -$discount->amount,
'weight' => LINE_ITEM_WEIGHT,
'data' => array(
'discount_id' => $discount->discount_id,
),
);
$line_items[] = $line_item;
}
$order->uc_discounts_line_items = $line_items;
}