Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
function mymodule_tapir_table_alter(&$table, $table_id) {
if ($table_id != 'uc_cart_view_table') return;
// Register new column to tapir
$table['#columns']['price_item'] = array(
'cell' => 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')
);
}
}
The above code not working for custom category with respect to product.
How i will add new table column for category ?
Please Help me.
Comments
Comment #2
TR CreditAttribution: TR commentedComment #3
TR CreditAttribution: TR commentedThat appears to be a piece of code written for Drupal 6.
Drupal 7 uses "#markup" instead of "#value" in the render array.
Comment #4
girishpanchal07 CreditAttribution: girishpanchal07 as a volunteer commentedComment #5
TR CreditAttribution: TR commentedWhy did you delete your post? Did my advice help? Regardless, you should 1) respond to my comments, and 2) leave the post visible so that other people who might have the same issue can see the responses and benefit from them.
I will restore the original post ...
Comment #6
TR CreditAttribution: TR commentedRestored original issue summary.