function uc_product_table in Ubercart 5
Same name and namespace in other branches
- 6.2 uc_product/uc_product.module \uc_product_table()
Display product fields in a TAPIr table.
Display image, name, price, and add to cart form.
5 string references to 'uc_product_table'
- theme_uc_catalog_browse in uc_catalog/
uc_catalog.module - Display a formatted catalog page.
- theme_uc_catalog_products in uc_catalog/
uc_catalog.module - Display a formatted list of products.
- uc_product_administration in uc_product/
uc_product.module - List the subcategories of product administration.
- uc_product_default in uc_product/
uc_product.module - uc_product_table_settings in uc_product/
uc_product.module - Define up the product list table.
File
- uc_product/
uc_product.module, line 895 - The product module for Ubercart.
Code
function uc_product_table($op, $args = array()) {
switch ($op) {
case 'fields':
$fields = array();
$fields[] = array(
'name' => 'image',
'title' => t('Image'),
'weight' => -5,
'enabled' => module_exists('imagecache'),
);
$fields[] = array(
'name' => 'name',
'title' => t('Name'),
'weight' => 0,
'enabled' => true,
'attributes' => array(
'field' => 'n.title',
),
);
$fields[] = array(
'name' => 'list_price',
'title' => t('List price'),
'weight' => 3,
'enabled' => false,
'attributes' => array(
'field' => 'p.list_price',
),
);
$fields[] = array(
'name' => 'price',
'title' => t('Price'),
'weight' => 5,
'enabled' => true,
'attributes' => array(
'field' => 'p.sell_price',
),
);
if (module_exists('uc_cart') && (arg(0) != 'admin' || $_GET['q'] == 'admin/store/settings/tables/uc_product_table')) {
$fields[] = array(
'name' => 'add_to_cart',
'title' => t('Add to cart'),
'weight' => 10,
'enabled' => false,
'attributes' => array(
'nowrap' => 'nowrap',
),
);
}
return $fields;
case 'data':
$data = array();
foreach ($args['nids'] as $nid) {
$node = node_load($nid);
if ($node->type != 'image') {
if (module_exists('imagecache') && isset($node->field_image_cache) && file_exists($node->field_image_cache[0]['filepath'])) {
$data['image'][] = l(theme('imagecache', 'product_list', $node->field_image_cache[0]['filepath'], $node->field_image_cache[0]['alt'], $node->field_image_cache[0]['title']), 'node/' . $node->nid, array(), null, null, false, true);
}
else {
$data['image'][] = t('n/a');
}
$data['name'][] = array(
'data' => l($node->title, 'node/' . $node->nid),
'width' => '100%',
);
$data['list_price'][] = array(
'data' => theme('uc_product_price', $node->list_price, 'list_price'),
'nowrap' => 'nowrap',
);
$data['price'][] = array(
'data' => theme('uc_product_sell_price', $node->sell_price, true),
'nowrap' => 'nowrap',
);
if (module_exists('uc_cart') && arg(0) != 'admin') {
$data['add_to_cart'][] = drupal_get_form('uc_catalog_buy_it_now_form_' . $node->nid, $node);
}
}
}
return $data;
case 'attributes':
return $args['attributes'];
}
}