You are here

function hook_uc_line_item in Ubercart 7.3

Defines 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_uc_line_item, Ubercart 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.

Return value

Your hook should return an array of associative arrays. Each item in the array represents a single line item, keyed by the internal ID of the line item, and with the following members:

  • "title"

    • type: string
    • value: The title of the line item shown to the user in various interfaces. Use t().
  • "callback"
    • type: string
    • value: Name of the line item's callback function, called for various operations.
  • "weight"
    • type: integer
    • value: Display order of the line item in lists; "lighter" items are displayed first.
  • "stored"
    • type: boolean
    • value: Whether or not the line item will be stored in the database. Should be TRUE for any line item that is modifiable from the order edit screen.
  • "add_list"
    • type: boolean
    • value: Whether or not a line item should be included in the "Add a Line Item" select box on the order edit screen.
  • "calculated"
    • type: boolean
    • value: Whether or not the value of this line item should be added to the order total. (Ex: would be TRUE for a shipping charge line item but FALSE for the subtotal line item since the product prices are already taken into account.)
  • "display_only"
    • type: boolean
    • value: Whether or not this line item is simply a display of information but not calculated anywhere. (Ex: the total line item uses display to simply show the total of the order at the bottom of the list of line items.)
3 functions implement hook_uc_line_item()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

uc_order_uc_line_item in uc_order/uc_order.module
Implements hook_uc_line_item().
uc_quote_uc_line_item in shipping/uc_quote/uc_quote.module
Implements hook_uc_line_item().
uc_taxes_uc_line_item in uc_taxes/uc_taxes.module
Implements hook_uc_line_item().
1 invocation of hook_uc_line_item()
_uc_line_item_list in uc_order/uc_order.line_item.inc
Builds a list of line items defined in the enabled modules.

File

uc_order/uc_order.api.php, line 80
Hooks provided by the Order module.

Code

function hook_uc_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;
}