You are here

function commerce_product_type_get_name in Commerce Core 7

Returns the human readable name of any or all product types.

Parameters

$type: Optional parameter specifying the type whose name to return.

Return value

Either an array of all product 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.

9 calls to commerce_product_type_get_name()
CommerceProductCRUDTestCase::testCommerceProductTokens in modules/product/tests/commerce_product.test
Test product Token replacement.
commerce_product_entity_info in modules/product/commerce_product.module
Implements hook_entity_info().
commerce_product_entity_property_info in modules/product/commerce_product.info.inc
Implements hook_entity_property_info().
commerce_product_handler_field_product_type::render in modules/product/includes/views/handlers/commerce_product_handler_field_product_type.inc
Render the field.
commerce_product_handler_filter_product_type::get_value_options in modules/product/includes/views/handlers/commerce_product_handler_filter_product_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.

... See full list

File

modules/product/commerce_product.module, line 435
Defines the core Commerce product entity, including the entity itself, the bundle definitions (product types), and various API functions to manage products and interact with them through forms and autocompletes.

Code

function commerce_product_type_get_name($type = NULL) {
  $product_types = commerce_product_types();

  // Return a type name if specified and it exists.
  if (!empty($type)) {
    if (isset($product_types[$type])) {
      return $product_types[$type]['name'];
    }
    else {

      // Return FALSE if it does not exist.
      return FALSE;
    }
  }

  // Otherwise turn the array values into the type name only.
  $product_type_names = array();
  foreach ($product_types as $key => $value) {
    $product_type_names[$key] = $value['name'];
  }
  return $product_type_names;
}