You are here

function commerce_coupon_type_get_name in Commerce Coupon 7.2

Same name and namespace in other branches
  1. 7 commerce_coupon.module \commerce_coupon_type_get_name()

Returns the name of the specified coupon type.

It returns all coupon type labels keyed by type if no type is specified.

Parameters

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

Return value

string|array 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.

File

./commerce_coupon.module, line 89
Provides coupon functionality for Drupal Commerce.

Code

function commerce_coupon_type_get_name($type = NULL) {
  $coupon_types = commerce_coupon_get_types();

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

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

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