14 replies [Last post]
Chris Herberte's picture
Offline
Joined: 10/01/2008
Juice: 48
Was this information Helpful?

A minor one,

Under the user's profile view, when 'view orders' permissions are enabled (a recently added option i believe) all previous orders are listed and further information is displayed upon clicking the order number.

Unfortunately clicking the order number simply is not obvious to our customers. uggh.

My suggestion is to add "View" under an "Operations" column, to make this usability improvement.

See attached screenshot. Currently i'm using a hacked uc_orders to achieve this but it would be awesome to get this into uc base/core.

Cheers, Chris.

PreviewAttachmentSize
order-history.pngorder-history.png6.92 KB
zmove's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 1192
Re: Add 'view' operation to Order History

I believe it's in a theme_ function, so easily modifiable by redeclaring it in your template.php and make the change.

For sure, I agree with you and it would be cool to see that in core as it's more user friendly and it would avoir you to redeclare the theme_ function for each project you do.

But it's very minor issue with a very low level of priority IMHO.

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3424
Re: Re: Add 'view' operation to Order History

I had to deal with this same problem when I wrote my Package Tracking module (http://www.ubercart.org/contrib/2852), because I needed to display a tracking number with a link to the tracking information on the order page.

There is no theme function to override here. That page is generated by uc_order_history(), so the whole function needs to be replaced. Without hacking core, I overrode the user/#/orders menu to call my own function instead of uc_order_history() - you can look in my code to see how I did this.

I think uc_order_history() could be re-designed so that it is easy to hook into. For this to happen, someone has to rewrite the code and post it as a proposal. I don't have the time myself.

Actually, what I REALLY think needs to be done is that "Order" needs to be a node type (for many reasons I've discussed before) instead of just DB tables as it is now. If that were done, then a page listing the order history could trivially be generated with views, and trivially themed to include/exclude/reformat information using the normal Drupal theming mechanisms. Ubercart's capabilities would be increased, while at the same time a lot of Ubercart code could be eliminated because this stuff would be done by core modules or other contributions. Again, I don't have time to tackle this project myself.

<tr>.
TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3424
Re: Re: Re: Add 'view' operation to Order History

One more comment, about the usability issue:

I agree, clicking on the order number is non-intuitive, and easily overlooked. I know this issue has been raised before. I agree this page could use minor tweaks in core, right now, to make it easier to user. Your suggestion is a good one.

<tr>.
Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Add 'view' operation to Order History

Two quick questions... would you also recommend taking the link off of the order number and maybe adding another operations link for the pop-up invoice? Also, I'm willing to entertain the idea of orders as nodes in UC 3.x, but I'm curious if the same problems would be solved by exposing order tables to Views 2.0. Puzzled

Chris Herberte's picture
Offline
Joined: 10/01/2008
Juice: 48
Re: Re: Re: Add 'view' operation to Order History

The initial request was a simple suggestion for core (a 2 liner) to save fiddling with menus and uc_order_history to improve usability. Although theme override would be an awesome addition as would views support.

I don't know if a link to invoice would get much use being in the same predicament.

zmove's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 1192
Re: Re: Re: Re: Add 'view' operation to Order History

Orders as node, OMG, is my wonderfull dreams will be realized ? ^^

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: Re: Re: Add 'view' operation to Order History

Heh... I think that's a discussion for another thread, but I'd be happy to have it. With Views 2.0 not being dependent on nodes any more, I just wonder if it's even necessary.

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3424
Ryan wrote:Two quick
Ryan wrote:

Two quick questions... would you also recommend taking the link off of the order number and maybe adding another operations link for the pop-up invoice?

The icons have never really "worked" for me - I always have to hover my mouse over the icons and read the tooltips to figure out which does what. So I personally would just turn those into text links for view, delete, edit, etc. I don't think it's necessary to add a link to the invoice in the order summary, since the first thing a user will do is drill down into the order view to see if it's what he wants, and the invoice tab is right there once you've drilled down.

Ryan wrote:

Also, I'm willing to entertain the idea of orders as nodes in UC 3.x, but I'm curious if the same problems would be solved by exposing order tables to Views 2.0. Puzzled

That would help with a number of small issues. I wouldn't assign much priority to it though. The big win comes only when you switch orders to nodes, then things like the order summary list would just be a normal list of teasers that users can theme with css, theme functions, or templates! Data added to orders by contributed modules would then be automatically included in all the order views, rather than having to implement various ubercart hooks. etc. As you said, fodder for another thread...

<tr>.
zmove's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 1192
Re: Ryan wrote:Two quick

To return to the original purpose of the post, it's true that the order history page should be easily themed. If it's not the case, there is a problem ^^

declaring this funtion as a theme_ function should not be so difficult, no ?

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Ryan wrote:Two quick

Well... it could be wrapped in a theme function, but the theme layer isn't necessarily supposed to change something like all the contents of a table. It's more to be used for changing the HTML output of an element... if it's just CSS you need to adjust, I should be able to add a class to the table no problem.

I suppose what should happen is this should be turned into a TAPIr table, though I'll need to investigate how effective paging is with TAPIr right now. In fact, I think that might be the best thing to do right now. Reason being... when I look at the table in 1024 x 768 with two sidebars, there's no room for another column in the table. If I'm going to overcrowd it, I'd like for people to be able to turn off columns to make it fit in their theme. Thoughts on that? This would most likely then become a D6 feature only.

zmove's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 1192
Re: Re: Re: Ryan wrote:Two quick

This would be a perfect solution. But, provide the possibility to enable/disable column for tapir generated table make me remember the tapir integration of 5.x. Why did you removed this dependency ? in 5.x, we could choose the column of the cart form, order, and some others tables like that, and now the feature is removed.

It is to prepare a view integration for all listing ? (*dream*)

haggis's picture
Offline
Joined: 02/22/2009
Juice: 27
Re: Add 'view' operation to Order History

I'm looking for the exact same thing. So I used the code of TRs tracking module. Everything seems to work except my custom callback, which will never called.

I set some drupal_set_message() to see if and at which time the methods are called. Can you see why my callback isn't fired?

<?php
/**
* Implementation of hook_menu().
*
* Registers _uc_order_tag_show() callback for displaying
* the tag.
*
* Callback is invoked when tracking request is posted to
* user/[user_number]/orders/tag/[order_id]
*
* @return An array with the menu path, callback, and parameters.
*/
function uc_order_tag_menu() {
   global
$user;
  
$items = array();
  
drupal_set_message('<pre>entry</pre>');

  if(

$user->uid) {
     
$items[] = array(
       
'title' => t('The orders tag.'),
       
'path' => 'user/'.$user->uid.'/orders/tag',
       
'callback' => '_uc_order_tag_show',
       
'type' => MENU_CALLBACK,
      );

     

drupal_set_message('<pre>redefine callback</pre>');
     
// Modify user/#/orders menu to callback to uc_tracking_order_history()
      // instead of uc_order_history().  Allows us to modify core behavior
      // without hacking uc_order.module, but this is a fragile solution that
      // relies on this uc_tracking module loading after uc_order.  This solution
      // also had the potential to break when uc_order.module is updated, unless
      // uc_tracking_order_history() is updated at the same time.  It would be
      // better to have these changes in the core function uc_order_history()
      // permanently. (Tim Rohaly)
      
$items[] = array(
       
'path'        => 'user/'. $user->uid .'/orders',
       
'title'       => t('Orders'),
       
'description' => t('View your order history.'),
       
'callback'    => 'uc_order_tag_order_history'// here's the magic
       
'callback arguments' => array(arg(1)),
       
'access'      => user_access('view all orders') || $user->uid == arg(1),
       
'type'        => MENU_LOCAL_TASK,
       );

  }
   return

$items;
}

function

_uc_order_tag_show($oid) {
  return
'some output';
}

/**
* Modified version of uc_order_history, changed to add tag
* display column into table of orders.
*
* @param $uid
*   The user ID whose orders you wish to list.
*/
function uc_order_tag_order_history($uid) {
 
drupal_set_message('<pre>execute my callback</pre>');

 

drupal_set_title(t('My order history'));

 

$breadcrumb = drupal_get_breadcrumb();
 
$breadcrumb[] = l(t('My account'), 'user/'. arg(1));
 
drupal_set_breadcrumb($breadcrumb);

 

$header = array(
    array(
'data' => t('Date'), 'field' => 'o.created', 'sort' => 'desc'),
    array(
'data' => t('Order #'), 'field' => 'o.order_id'),
    array(
'data' => t('Status'), 'field' => 'os.title'),
    array(
'data' => t('Products'), 'field' => 'products'),
    array(
'data' => t('Total'), 'field' => 'o.order_total'),
    array(
'data' => t('Tag')),
  );

 

$result = pager_query("SELECT o.order_id, o.created, os.title, SUM(op.qty) AS products, o.order_total AS total FROM {uc_orders} AS o LEFT JOIN {uc_order_statuses} AS os ON o.order_status = os.order_status_id LEFT JOIN {uc_order_products} AS op ON o.order_id = op.order_id WHERE o.uid = %d AND o.order_status IN ". uc_order_status_list('general', TRUE) ." GROUP BY o.order_id". tablesort_sql($header), 20, 0, "SELECT COUNT(*) FROM {uc_orders} WHERE uid = %d AND order_status NOT IN ". uc_order_status_list('specific', TRUE), $uid);

 

// Build a table based on the customer's orders.
 
while ($order = db_fetch_object($result)){
   
$link = l($order->order_id, 'user/'. $uid .'/order/'. $order->order_id);
    if (
user_access('view all orders')){
     
$link .= '<span class="order-admin-icons">'. uc_order_actions($order, TRUE) .'</span>';
    }
   
$rows[] = array(
      array(
'data' => format_date($order->created, 'custom', 'm/d/Y')),
      array(
'data' => $link, 'nowrap' => 'nowrap'),
      array(
'data' => $order->title),
      array(
'data' => (!is_null($order->products) ? $order->products : 0), 'align' => 'center'),
      array(
'data' => uc_currency_format($order->total, TRUE), 'align' => 'right'),
      array(
'data' => 'test'), //uc_order_tag_get_order_tag_links($order->order_id), 'align' => 'left'),
   
);
  }

 

$output = theme('table', $header, $rows) . theme('pager', null, 20, 0);

  return

$output;
}
?>

Deleting the cache results in this output:
* uc_order execution
* entry
* redefine callback
* Cache cleared.

So "* execute my callback" is missing.

haggis's picture
Offline
Joined: 02/22/2009
Juice: 27
Re: Re: Add 'view' operation to Order History

Sometimes it helps to see the code in another environment than your IDE Eye-wink

In D6 there's another syntax of hook_menu:

<?php
$items
['user/%user/orders'] = array(
       
'title' => 'Orders',
       
'description' => 'View your order history.',
       
'page callback' => 'uc_order_tag_order_history',
       
'page arguments' => array(1),
       
'access callback' => 'uc_order_can_view_order',
       
'access arguments' => array(1),
       
'type' => MENU_LOCAL_TASK,
      );
?>

Are there any other ways to add columns to this page at Ubercart 2?

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: Add 'view' operation to Order History

Not right now... on D6 you can use hook_menu_alter() to change the page callback for the Orders tab to use your modified version, tho.