You are here

function commerce_line_item_configure_line_item_fields in Commerce Core 7

Configures line item types defined by other modules that are enabled after the Line Item module.

Parameters

$modules: An array of module names whose line item type fields should be configured; if left NULL, will default to all modules that implement hook_commerce_line_item_type_info().

1 call to commerce_line_item_configure_line_item_fields()
commerce_line_item_modules_enabled in modules/line_item/commerce_line_item.module
Implements hook_modules_enabled().

File

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

Code

function commerce_line_item_configure_line_item_fields($modules = NULL) {

  // If no modules array is passed, recheck the fields for all line item types
  // defined by enabled modules.
  if (empty($modules)) {
    $modules = module_implements('commerce_line_item_type_info');
  }

  // Reset the line item type cache to get types added by newly enabled modules.
  commerce_line_item_types_reset();

  // Loop through all the enabled modules.
  foreach ($modules as $module) {

    // If the module implements hook_commerce_line_item_type_info()...
    if (module_hook($module, 'commerce_line_item_type_info')) {

      // Loop through and configure the line item types defined by the module.
      foreach (module_invoke($module, 'commerce_line_item_type_info') as $type => $line_item_type) {

        // Load the line item type to ensure we have callbacks set.
        $line_item_type = commerce_line_item_type_load($type);
        commerce_line_item_configure_line_item_type($line_item_type);
      }
    }
  }
}