function uc_discounts_add_line_items_to_order in Ubercart Discounts (Alternative) 7.2
Add temporary discount line items to order.
Creates discount line items and saves them to order->uc_discounts_line_items. This is temporary storage and uc_discounts_apply() should be used to create real ubercart line items that affect totals.
Parameters
object $order: Fully loaded ubercart order.
array $discounts: Array of loaded discounts as created by uc_discounts_discounts_for_order().
2 calls to uc_discounts_add_line_items_to_order()
- uc_discounts_apply in uc_discounts/
uc_discounts.module - Applies the discounts to an order by creating the necessary line items.
- uc_discounts_uc_order_pane_callback in uc_discounts/
uc_discounts.module - Callback for hook_uc_order_pane().
File
- uc_discounts/
uc_discounts.module, line 660
Code
function uc_discounts_add_line_items_to_order(&$order, $discounts) {
$line_items = array();
foreach ($discounts as $discount) {
$line_item = array(
'type' => UC_DISCOUNTS_LINE_ITEM_TYPE,
'title' => $discount->short_description,
'amount' => -$discount->amount,
'weight' => UC_DISCOUNTS_LINE_ITEM_WEIGHT,
'data' => array(
'discount_id' => $discount->discount_id,
),
);
$line_items[] = $line_item;
}
$order->uc_discounts_line_items = $line_items;
}