hook_line_item()
ubercart/docs/hooks.php, line 528
Used to define line items that are attached to orders.
A line item is a representation of charges, fees, and totals for an order. Default line items include the subtotal and total line items, the tax line item, and the shipping line item. There is also a generic line item that store admins can use to add extra fees and discounts to manually created orders. Module developers will use this hook to define new types of line items for their stores. An example use would be for a module that allows customers to use coupons and wants to represent an entered coupon as a line item.
Once a line item has been defined in hook_line_item, Übercart will begin interacting with it in various parts of the code. One of the primary ways this is done is through the callback function you specify for the line item.
Your hook should return an array of associative arrays. Each item in the array represents a single line item and should use the following keys:
| Name | Description |
|---|---|
| Hooks | Allow modules to interact with the Drupal core. |
<?php
function hook_line_item() {
$items[] = array(
'id' => 'generic',
'title' => t('Empty Line'),
'weight' => 2,
'default' => FALSE,
'stored' => TRUE,
'add_list' => TRUE,
'calculated' => TRUE,
'callback' => 'uc_line_item_generic',
);
return $items;
}
?>