Adding "Price" field to Ubercart cart page
On the /cart page of Ubercart store, you can usually see such fields:
That's total price per row, and amount of products per row.
For a customer project, I wanted to add single item price to this page, to make it look like this:
After some digging into Ubercart code, that task was solved in ~10 lines (put these lines in your module): t('Price'), 'weight' => 2.5, ); foreach (element_children($table) as $key) { if (empty($table[$key]['nid']['#value'])) continue; // This db-expensive node_load call can be easily avoided by using // single SQL select. But, // that's not so important if visitor usually adds 1-5 products to cart. $n = node_load($table[$key]['nid']['#value']); $p = uc_price($n -> sell_price, array()); // Add data to our new column $table[$key]['price_item'] = array( '#value' => $p, '#cell_attributes' => array('class' =>'price-item') ); }} ?>
That's so easy because Ubercart uses Tapir table builder for most important tables (like cart page) and we can use Drupal hooks to extend them!