There is a hook called hook_cart_item.
If I want to add a small piece of information to the text for every item in the cart, I can (or not) do this:
function hook_cart_item($op, $item) {
if($op == 'load') {
$n = node_load($item->nid);
$item->title = $item->title.' (blah blah)';
}
}This will show "node title (blah blah)" in the cart block, but not in the cart view or checkout. Because the default implementation for hook_cart_display loads the node and uses its node title, instead of the supplied $item and its $item->title.
Part of uc_product_cart_display:
function uc_product_cart_display($item) {
$node = node_load($item->nid);
$element['title'] = array(
'#value' => l($node->title, 'node/'. $node->nid),
);
return $element;
}Any special reason for this?
$item->title is always updated whenever the cart is displayed. So the item->title will -always- be equal to $node->title, as long as no one have used hook_cart_item in the hope that it would actually change something.
I've changed it to this, in our code base:
$element['title'] = array(
'#value' => l($item->title, 'node/'. $node->nid),
);



