You are here

function uc_attribute_options in Ubercart 5

3 string references to 'uc_attribute_options'
uc_attribute_menu in uc_attribute/uc_attribute.module
Implementation of hook_menu().
uc_attribute_update_2 in uc_attribute/uc_attribute.install
uc_attribute_update_5 in uc_attribute/uc_attribute.install

File

uc_attribute/uc_attribute.module, line 551

Code

function uc_attribute_options($aid) {
  $attribute = uc_attribute_load($aid);

  // If we got a bunk attribute ID, kick out an error message.
  if (empty($attribute)) {
    drupal_set_message(t('There is no attribute with that ID.'), 'error');
    drupal_goto('admin/store/products/attributes');
  }
  drupal_set_title(t('Options for %name', array(
    '%name' => $attribute->name,
  )));
  $header = array(
    t('Name'),
    t('Default cost'),
    t('Default price'),
    t('Default weight'),
    t('Order'),
    t('Operations'),
  );
  foreach ($attribute->options as $key => $data) {
    $ops = array(
      l(t('edit'), 'admin/store/products/attributes/' . $aid . '/options/' . $key . '/edit'),
      l(t('delete'), 'admin/store/products/attributes/' . $aid . '/options/' . $key . '/delete'),
    );
    $rows[] = array(
      $data->name,
      $data->cost,
      $data->price,
      $data->weight,
      $data->ordering,
      implode(' ', $ops),
    );
  }
  if (count($rows) == 0) {
    $rows[] = array(
      array(
        'data' => t('No options for this attribute have been added yet.'),
        'colspan' => '6',
      ),
    );
  }
  $output .= theme('table', $header, $rows) . l(t('Add an option'), 'admin/store/products/attributes/' . $aid . '/options/add');
  return $output;
}