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

Excellent work, thank you
Submitted by Zemistr (not verified) on Thu, 08/09/2011 - 22:07.Excellent work, thank you very much
Also, your code has been
Submitted by Tom (not verified) on Wed, 17/08/2011 - 03:24.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
Submitted by Tom (not verified) on Wed, 17/08/2011 - 03:11.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