function commerce_product_ui_types_overview in Commerce Core 7
Menu callback: display an overview of available types.
1 string reference to 'commerce_product_ui_types_overview'
- commerce_product_ui_menu in modules/
product/ commerce_product_ui.module - Implements hook_menu().
File
- modules/
product/ includes/ commerce_product_ui.types.inc, line 11
Code
function commerce_product_ui_types_overview() {
drupal_add_css(drupal_get_path('module', 'commerce_product') . '/theme/commerce_product.admin.css');
$header = array(
t('Name'),
t('Operations'),
);
$rows = array();
// Loop through all defined product types.
foreach (commerce_product_types() as $type => $product_type) {
// Build the operation links for the current product type.
$links = menu_contextual_links('commerce-product-type', 'admin/commerce/products/types', array(
strtr($type, array(
'_' => '-',
)),
));
// Add the product type's row to the table's rows array.
$rows[] = array(
theme('product_type_admin_overview', array(
'product_type' => $product_type,
)),
theme('links', array(
'links' => $links,
'attributes' => array(
'class' => 'links inline operations',
),
)),
);
}
// If no product types are defined...
if (empty($rows)) {
// Add a standard empty row with a link to add a new product type.
$rows[] = array(
array(
'data' => t('There are no product types yet. <a href="@link">Add product type</a>.', array(
'@link' => url('admin/commerce/products/types/add'),
)),
'colspan' => 2,
),
);
}
return theme('table', array(
'header' => $header,
'rows' => $rows,
));
}