php, Drupal developer, CodeIgniter - freelance web developer

Ubercart 2 - links to products in admin order view

For several shops operated by Drupal I have used modules Ubercart 2 and clients are satisfied with the outcome. But all they had a requirement for review of order to be able to click on product name and to go to his page. This functionality is missing in Ubercart. Partial solutions are possible with the module Views. I've looking google around a bit and eventually it turned out that thanks to the hooks with very little intervention I can add this link and without forking the code. For this purpose you have to create module and add this function:

function MYMODULENAME_tapir_table_alter(&$table, $table_id) {
  if ($table_id == 'op_products_view_table' || $table_id == 'op_products_customer_table') {
    $order = $table['#parameters'][1];
    if ($order->order_id && is_array($order->products)) {
      foreach ($order->products as $key => $product) {
        $table['#rows'][$key]['product']['#value'] = ''.$table['#rows'][$key]['product']['#value'].'';
        unset($table['#rows'][$key]['model']['#cell_attributes']['nowrap']);
      }
    }
  }
}

 

From here you can download the finished module uc_order_product_link-6.x-1.0.tar.gz

Requirements

  • Drupal 6.х
  • Ubercart 2.х
  • Ubercart Order

Instalation

  • Unpack archive in the modules directory (usually /sites/all/modules)
  • Activate the module in Site building > Modules
  • Go to any order ready and you will see links to product names
Comments

Excellent work, thank you

Excellent work, thank you very much

Also, your code has been

Also, your code has been messed up somehow.

It should be:

<code>
<?php

function uc_order_table_tapir_table_alter(&$table, $table_id) {
if ($table_id == 'op_products_view_table' || $table_id == 'op_products_customer_table') {
$order = $table['#parameters'][1];
if ($order->order_id && is_array($order->products)) {
foreach ($order->products as $key => $product) {
$table['#rows'][$key]['product']['#value'] = '<a href="/node/' . $product->nid .'" target="_blank">'.$table['#rows'][$key]['product']['#value'].'</a>';
unset($table['#rows'][$key]['model']['#cell_attributes']['nowrap']);
}
}
}
}

?>
</code>

This sounds perfect, but the

This sounds perfect, but the uploaded file no longer exists. Not a problem, as you've put the code on the page... Just so you know.

Thanks muchly.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • Each email address will be obfuscated in a human readable fashion or (if JavaScript is enabled) replaced with a spamproof clickable link.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.

www.stefanpetrov.net © 2007 - 2012All rights reserved

powered by Drupal European hosting