You are here

function commerce_coupon_types_overview_page in Commerce Coupon 7.2

Menu callback: display an overview of available types.

1 string reference to 'commerce_coupon_types_overview_page'
commerce_coupon_menu in ./commerce_coupon.module
Implements hook_menu().

File

includes/commerce_coupon.admin.inc, line 26
Administrative forms and callbacks for Commerce Coupon.

Code

function commerce_coupon_types_overview_page() {
  $header = array(
    t('Name'),
    t('Operations'),
  );
  $rows = array();

  // Loop through all defined product types.
  foreach (commerce_coupon_get_types() as $type => $coupon_type) {

    // Build the operation links for the current product type.
    $links = menu_contextual_links('commerce-coupon-type', 'admin/commerce/coupons/types', array(
      strtr($type, array(
        '_' => '-',
      )),
    ));
    $coupon_type['type'] = $type;

    // Add the product type's row to the table's rows array.
    $rows[] = array(
      theme('commerce_coupon_type_admin_overview', array(
        'coupon_type' => $coupon_type,
      )),
      theme('links', array(
        'links' => $links,
        'attributes' => array(
          'class' => 'links inline operations',
        ),
      )),
    );
  }
  return theme('table', array(
    'header' => $header,
    'rows' => $rows,
  ));
}