You are here

function commerce_line_item_configure_line_item_type in Commerce Core 7

Configures a line item type by adding default price fields and then calling its configuration callback.

Parameters

$line_item_type: The fully loaded line item type array to configure.

2 calls to commerce_line_item_configure_line_item_type()
commerce_line_item_configure_line_item_fields in modules/line_item/commerce_line_item.module
Configures line item types defined by other modules that are enabled after the Line Item module.
commerce_line_item_configure_line_item_types in modules/line_item/commerce_line_item.module
Configures line item types defined by enabled modules.

File

modules/line_item/commerce_line_item.module, line 277
Defines the core Commerce line item entity and API functions interact with line items on orders.

Code

function commerce_line_item_configure_line_item_type($line_item_type) {

  // Add the default price fields to the line item type.
  $weight = 0;
  foreach (array(
    'commerce_unit_price' => t('Unit price'),
    'commerce_total' => t('Total'),
  ) as $field_name => $label) {
    commerce_price_create_instance($field_name, 'commerce_line_item', $line_item_type['type'], $label, $weight++);
  }

  // If this line item type specifies a configuration callback...
  if ($callback = commerce_line_item_type_callback($line_item_type, 'configuration')) {

    // Invoke it now.
    $callback($line_item_type);
  }
}