function op_products_view_table in Ubercart 6.2
Same name and namespace in other branches
- 5 uc_order/uc_order_order_pane.inc \op_products_view_table()
Builds the order view products table.
1 string reference to 'op_products_view_table'
- uc_order_pane_products in uc_order/
uc_order.order_pane.inc - Handles the "Products" order pane.
File
- uc_order/
uc_order.order_pane.inc, line 716 - This file contains the callbacks for the default order panes supplied with Ubercart and their corresponding helper functions.
Code
function op_products_view_table($order) {
$table = array(
'#type' => 'tapir_table',
'#attributes' => array(
'class' => 'order-pane-table',
),
);
$table['#columns']['qty'] = array(
'cell' => array(
'data' => t('Qty'),
'class' => 'qty',
),
'weight' => 0,
);
$table['#columns']['product'] = array(
'cell' => array(
'data' => t('Product'),
'class' => 'product',
),
'weight' => 1,
);
$table['#columns']['model'] = array(
'cell' => array(
'data' => t('SKU'),
'class' => 'sku',
),
'weight' => 2,
);
if (user_access('administer products')) {
$table['#columns']['cost'] = array(
'cell' => array(
'data' => t('Cost'),
'class' => 'cost',
),
'weight' => 3,
);
}
$table['#columns']['price'] = array(
'cell' => array(
'data' => t('Price'),
'class' => 'price',
),
'weight' => 4,
);
$table['#columns']['total'] = array(
'cell' => array(
'data' => t('Total'),
'class' => 'total',
),
'weight' => 5,
);
drupal_alter('tapir_table_header', $table['#columns'], 'op_products_view_table');
$context = array(
'revision' => 'themed',
'type' => 'order_product',
'subject' => array(
'order' => $order,
),
);
if (is_array($order->products)) {
foreach ($order->products as $product) {
$data = array();
$data['qty'] = array(
'#value' => $product->qty . '×',
'#cell_attributes' => array(
'class' => 'qty',
),
);
$node = node_load($product->nid);
$title = node_access('view', $node) ? l($product->title, 'node/' . $node->nid) : check_plain($product->title);
$data['product'] = array(
'#value' => $title . uc_product_get_description($product),
'#cell_attributes' => array(
'class' => 'product',
),
);
$data['model'] = array(
'#value' => check_plain($product->model),
'#cell_attributes' => array(
'class' => 'sku',
),
);
$context['subject']['product'] = $product;
$context['subject']['node'] = node_load($product->nid);
if (user_access('administer products')) {
$context['field'] = 'cost';
$data['cost'] = array(
'#value' => uc_price($product->cost, $context),
'#cell_attributes' => array(
'class' => 'cost',
),
);
}
$context['field'] = 'price';
$price_info = array(
'price' => $product->price,
'qty' => $product->qty,
);
$data['price'] = array(
'#value' => uc_price($product->price, $context),
'#cell_attributes' => array(
'class' => 'price',
),
);
$data['total'] = array(
'#value' => uc_price($price_info, $context),
'#cell_attributes' => array(
'class' => 'total',
),
);
$table['#rows'][] = $data;
}
}
else {
$table['#rows'][]['product'] = array(
'#value' => t('This order contains no products.'),
'#cell_attributes' => array(
'colspan' => 'full',
),
);
}
return $table;
}