You are here

function commerce_discount_offer_type_get_name in Commerce Discount 7

Returns the human readable name of any or all discount offer types.

Parameters

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

Return value

mixed Either an array of all discount offer 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.

File

./commerce_discount.module, line 825
Defines the discount and discount offer entities, bundles and functionality.

Code

function commerce_discount_offer_type_get_name($type = NULL) {
  $offer_types = commerce_discount_offer_types();

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

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

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