hook_cart_display($item)
ubercart/docs/hooks.php, line 115
Control the display of an item in the cart.
Product type modules allow the creation of nodes that can be added to the cart. The cart determines how they are displayed through this hook. This is especially important for product kits, because it may be displayed as a single unit in the cart even though it is represented as several items.
$item The item in the cart to display.
A form array containing the following elements:
| Name | Description |
|---|---|
| Hooks | Allow modules to interact with the Drupal core. |
<?php
function hook_cart_display($item) {
$node = node_load($item->nid);
$element = array();
$element['nid'] = array('#type' => 'value', '#value' => $node->nid);
$element['module'] = array('#type' => 'value', '#value' => 'uc_product');
$element['remove'] = array('#type' => 'checkbox');
$op_names = '';
if (module_exists('uc_attribute')){
$op_names = "<ul class=\"cart-options\">\n";
foreach ($item->options as $option){
$op_names .= '<li>'. $option['attribute'] .': '. $option['name'] ."</li>\n";
}
$op_names .= "</ul>\n";
}
$element['options'] = array('#value' => $op_names);
$element['title'] = array(
'#value' => l($node->title, 'node/'. $node->nid),
);
$element['#total'] = $item->price * $item->qty;
$element['data'] = array('#type' => 'hidden', '#value' => serialize($item->data));
$element['qty'] = array(
'#type' => 'textfield',
'#default_value' => $item->qty,
'#size' => 3,
'#maxlength' => 3
);
return $element;
}
?>