You are here

function commerce_order_type_get_name in Commerce Core 7

Returns the name of the specified order type or all names keyed by type if no type is specified.

For Drupal Commerce 1.0, the decision was made to support order types at the database level but not to introduce their complexity into the UI. To that end order "types" (i.e. bundles) may only be defined by altering the entity info.

This function merely traverses the bundles array looking for data instead of relying on a special hook.

Parameters

$type: The order type whose name should be returned; corresponds to the bundle key in the order entity definition.

Return value

Either the specified name, defaulting to the type itself if the name is not found, or an array of all names keyed by type if no type is passed in.

5 calls to commerce_order_type_get_name()
CommerceOrderCRUDTestCase::testCommerceOrderTokens in modules/order/tests/commerce_order.test
Test order Token replacement.
commerce_order_handler_field_order_type::render in modules/order/includes/views/handlers/commerce_order_handler_field_order_type.inc
Render the field.
commerce_order_handler_filter_order_type::get_value_options in modules/order/includes/views/handlers/commerce_order_handler_filter_order_type.inc
Child classes should be used to override this function and set the 'value options', unless 'options callback' is defined as a valid function or static public method to generate these values.
commerce_order_tokens in modules/order/commerce_order.tokens.inc
Implements hook_tokens().
commerce_order_type_options_list in modules/order/commerce_order.module
Wraps commerce_order_type_get_name() for the Entity module.

File

modules/order/commerce_order.module, line 683
Defines the core Commerce order entity and API functions to manage orders and interact with them.

Code

function commerce_order_type_get_name($type = NULL) {
  $names = array();
  $entity = entity_get_info('commerce_order');
  foreach ($entity['bundles'] as $key => $value) {
    $names[$key] = $value['label'];
  }
  if (empty($type)) {
    return $names;
  }
  if (empty($names[$type])) {
    return check_plain($type);
  }
  else {
    return $names[$type];
  }
}