function commerce_line_item_type_get_name in Commerce Core 7
Returns the human readable name of any or all line item types.
Parameters
$type: Optional parameter specifying the type whose name to return.
Return value
Either an array of all line item type names keyed by the machine name or a string containing the human readable name for the specified type. If a type is specified that does not exist, this function returns FALSE.
10 calls to commerce_line_item_type_get_name()
- commerce_cart_field_formatter_settings_form in modules/
cart/ commerce_cart.module - Implements hook_field_formatter_settings_form().
- commerce_cart_field_formatter_settings_summary in modules/
cart/ commerce_cart.module - Implements hook_field_formatter_settings_summary().
- commerce_cart_handler_field_add_to_cart_form::options_form in modules/
cart/ includes/ views/ handlers/ commerce_cart_handler_field_add_to_cart_form.inc - Provide the add to cart display options.
- commerce_line_item_entity_info in modules/
line_item/ commerce_line_item.module - Implements hook_entity_info().
- commerce_line_item_entity_property_info in modules/
line_item/ commerce_line_item.info.inc - Implements hook_entity_property_info().
File
- modules/
line_item/ commerce_line_item.module, line 500 - Defines the core Commerce line item entity and API functions interact with line items on orders.
Code
function commerce_line_item_type_get_name($type = NULL) {
$line_item_types = commerce_line_item_types();
// Return a type name if specified and it exists.
if (!empty($type)) {
if (isset($line_item_types[$type])) {
return $line_item_types[$type]['name'];
}
else {
// Return FALSE if it does not exist.
return FALSE;
}
}
// Otherwise turn the array values into the type name only.
$line_item_type_names = array();
foreach ($line_item_types as $key => $value) {
$line_item_type_names[$key] = $value['name'];
}
return $line_item_type_names;
}