You are here

function commerce_line_item_types in Commerce Core 7

Returns an array of line item type arrays keyed by type.

8 calls to commerce_line_item_types()
commerce_line_item_configure_line_item_types in modules/line_item/commerce_line_item.module
Configures line item types defined by enabled modules.
commerce_line_item_field_extra_fields in modules/line_item/commerce_line_item.module
Implements hook_field_extra_fields().
commerce_line_item_type_get_name in modules/line_item/commerce_line_item.module
Returns the human readable name of any or all line item types.
commerce_line_item_type_load in modules/line_item/commerce_line_item.module
Returns a single line item type array.
commerce_line_item_ui_menu in modules/line_item/commerce_line_item_ui.module
Implements hook_menu().

... See full list

1 string reference to 'commerce_line_item_types'
commerce_line_item_types_reset in modules/line_item/commerce_line_item.module
Resets the cached list of line item types.

File

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

Code

function commerce_line_item_types() {

  // First check the static cache for a line item types array.
  $line_item_types =& drupal_static(__FUNCTION__);

  // If it did not exist, fetch the types now.
  if (!isset($line_item_types)) {
    $line_item_types = module_invoke_all('commerce_line_item_type_info');
    drupal_alter('commerce_line_item_type_info', $line_item_types);
    foreach ($line_item_types as $type => &$line_item_type) {
      $defaults = array(
        'type' => $type,
        'product' => FALSE,
        'base' => $type,
        'callbacks' => array(),
      );
      $line_item_type += $defaults;

      // Merge in default callbacks.
      foreach (array(
        'configuration',
        'title',
        'add_form',
        'add_form_submit',
      ) as $callback) {
        if (!isset($line_item_type['callbacks'][$callback])) {
          $line_item_type['callbacks'][$callback] = $line_item_type['base'] . '_' . $callback;
        }
      }
    }
  }
  return $line_item_types;
}