3 replies [Last post]
arielgold's picture
Offline
Joined: 02/14/2010
Juice: 63
Was this information Helpful?

I'm trying to display item price on the /cart page

I made a theme_uc_cart_view_form function in template.php and tried to print_r($form['items']
but I didn't see the price.

Now what?

alien73's picture
Offline
Bug Finder
Joined: 11/10/2007
Juice: 450
Re: Show item price in cart?

did you try

$node->list_price
$node->sell_price

etc.....

arielgold's picture
Offline
Joined: 02/14/2010
Juice: 63
Re: Re: Show item price in cart?

no dice. i read somewhere i might need to extend a tapir table, but I don't know how to do that.

arielgold's picture
Offline
Joined: 02/14/2010
Juice: 63
Found it in the forum!

Don't know why I didn't find this before:

http://www.ubercart.org/forum/development/8974/insert_item_price_column_...

When I followed instructions there, the item price showed up, but the labels didn't line up with data. I have no idea why fiddling with the labels worked, but it did:

<?php
function capcart_form_alter(&$form, &$form_state, $form_id) {
  if (
$form_id == 'uc_cart_view_form') {
   
$form['items']['#columns']['price'] = array(
      
'cell' => t('Price'),
      
'weight' => 3,
      
'enabled' => TRUE,
      );
   
$form['items']['#columns']['desc']['cell'] = t('Price');
   
$form['items']['#columns']['qty']['cell'] = t('Total');
   
$form['items']['#columns']['total']['cell'] = '';
   
$form['items']['#columns']['price']['cell'] = t('Qty.');
   
$form['items']['#columns']['remove']['access'] = FALSE;

   

$form['items']['#columns']['products']['weight'] = 1;
   
$form['items']['#columns']['desc']['weight'] = 2;
   
$form['items']['#columns']['qty']['weight'] = 4;
   
$form['items']['#columns']['total']['weight'] = 5;
   
$i = 0;
    foreach (
$form['#parameters'][2] as $item) {
     
$form['items'][$i]['price']['#value'] = uc_currency_format($item->price);
     
$i = $i + 1;
    }
  }
}
?>