4 replies [Last post]
sirisha's picture
Offline
Joined: 09/15/2007
Juice: 26
Was this information Helpful?

Hi all,
I added some 2 extra fields in product. Now I want to access that field in place of sell price where we are calculating the qty*sellprice. Can anyone please help me where I can add this one .Thanks in advance.

zmove's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 1192
Re: Adding our own price in place of sell price

you need to use the tapir hooks hook_table_alter(). See the tapir documentation for help

For example see my little module that add an unit price to cart view

<?php
function uc_unit_price_table_alter($table_id, $op, $args = NULL) {
   
    switch (
$table_id) {
      case
'uc_cart_view_table':
        case
'op_products_view_table':
            switch (
$op){
                case
'fields':
   
                   
$fields[] = array('name' => 'unit_price',
                       
'title' => t('Unit price'),
                       
'weight' => 2,
                       
'enabled' => true,
                    );
                       
          return
$fields;
                   
                case
'data':
               
                    foreach (
$args['#parameters'][1] as $item) {
                       
$data['unit_price'][] = uc_currency_format($item->price);
                    }
                return
$data;
            }
        break;
       
    }
}
?>
sirisha's picture
Offline
Joined: 09/15/2007
Juice: 26
Re: Adding our own price in place of sell price

I will add the fields but I dont want to show it. I just want to access that field in place of sell price by writing if condition.

zmove's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 1192
Re: Re: Adding our own price in place of sell price

Ah, for that case, I think you need to use a node-product.tpl.php file in which, instead of printing $content, you will print only fields you need.

To easily see what field is available to you, use the excellent content template module

cosmo83@drupal.org's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik
Joined: 08/08/2007
Juice: 236
What type of condition??

Are you considering to use the other fields price when checking out?? That will require a bit of digging/patching ubercart.

Are you looking for some kind of attributes. If you can list the functionality better, the guys can be of much help.

BTW, good to see another Indian in the forum

http://www.vingowine.com