1. commerce
    1. 7
7 commerce_product_type_get_name($type = NULL)

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


$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.


modules/product/commerce_product.module, line 404

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.
  foreach ($product_types as $key => $value) {
    $product_types[$key] = $value['name'];

  return $product_types;