Adding more columns to "View orders" page

Posts: 20
Joined: 08/08/2007

Our managers who process our orders every day has asked me if it's possible to add 2 more columns to the "view orders" page that displays the shipping method and order time at a glance.

I narrowed it down to uc_order.module and altering function uc_order_admin... I managed to add the columns by adding new lines into $header = array(, but can't get the information to display. Are there any more lines that I should add/alter? If so, what should I be adding?

Any help to this PHP newbie would be appreciated!

Posts: 332
Joined: 08/07/2007
Administrator

Check out the while loop in uc_order_admin. Are you adding any additional information into the $rows variable? uc_order_admin uses Drupal's theme_table to build the table. theme_table uses an array of arrays (in this case, the variable $rows) to output the table. If you're only altering $header, it would not place any additional information in the rows.

--

-Shawn Conn: If the Name Don't Rhyme It Ain't Mine

Posts: 20
Joined: 08/08/2007

Actually, I did try to put things under $rows - but I ran into a brick wall because I truly have no idea what to put there in order for the columns to display shipping method, and purchase time. Guess that's where I need everyone's help here! Thanks Smiling

Posts: 80
Joined: 08/09/2007
Uber DonorBug Finder

Were you able to figure out how to do it? Is the orders table available to tapir?

--

Biodiesel * (ubercart + drupal) = Sundays Energy

Posts: 46
Joined: 10/02/2007
Bug FinderGetting busy with the Ubercode.

(Purchase date is a field displayed by default in the current version of Ubercart.)

In addition to adding space for a column in the header and rows arrays, you need to load the data for the column. As is, the database query retrieves only a few fields mainly from the uc_order table (order id, user id, billing first name and last name, order status, and timestamp of order creation).

We wanted to add the company name to the orders list, so I added 'o.billing_company' to the fields retrieved by the SQL query. (See the attached patch.)

If you want to add a column for shipment type, you would need to reference the uc_shipments table as well. You could try changing the database query to something like:

$sql = 'SELECT o.order_id, o.uid, o.billing_first_name, o.billing_last_name, o.billing_company, o.order_total, o.order_status, o.created, oh.shipping_method, os.title FROM {uc_orders} o LEFT JOIN {uc_shipments} oh ON o.order_id = oh.order_id LEFT JOIN {uc_order_statuses} os ON o.order_status = os.order_status_id WHERE '. $status . (($sort == NULL) ? ' ORDER BY o.created DESC' : $sort);

AttachmentSize
uc_order.company_name.diff2.18 KB
Posts: 80
Joined: 08/09/2007
Uber DonorBug Finder

Thanks for the patch. Uberdudes, I vote for moving the company column into core or making the table editable via tapir. Also, I thought the order table was going to be sortable?

--

Biodiesel * (ubercart + drupal) = Sundays Energy

Posts: 4695
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Yeah, this really should be sortable and tapified... but for those things to both happen, I'd have to rework TAPIr a bit. I'll try to address the sorting now and look into TAPIr later.

EDIT: Funny, the code looks like I thought it should be sorting, but I was never calling the function to get the tablesort SQL. Fixed in Bazaar.

Posts: 80
Joined: 08/09/2007
Uber DonorBug Finder

Still nothing on this front? It looks like it might be up to us to build a contrib module? I'll get someone on it tomorrow.

--

Biodiesel * (ubercart + drupal) = Sundays Energy

Posts: 57
Joined: 08/23/2007

And here is yet another use for this line of development:

Enabling admins to also search by the name of the person placing the order, not just the ship-to person.

Jim

--

(Drupal^Ubercart) * (Design^Development^Hosting) = Sundays Energy

Posts: 4695
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Are you aware of /admin/store/orders/search?

Posts: 57
Joined: 08/23/2007

Yes, thanks for the chance to clarify. The example is this:

Ship to:
[ shipping address ]

Bill to:
[ billing address ]

At /admin/store/orders/search, when I input Firstname Lastname (or FIRSTNAME LASTNAME) into the Billing first and last name fields, no results are returned.

Only when I put FIRSTNAME LASTNAME into the Shipping first and last name fields is there a result:

Order ID     Customer        Total      Purchase Date    Status	                             
743	    Firstname Lastname    $57.25	11/04/2007       Pending

Also, no results are returned unless the search terms are ALL CAPS. Based on these types of inconsistencies, she's under the impression that you can't search by shipping name, only billing name (though my example here contradicts that). I think it's these kinds of things that are confusing the client as much as anything.

Thanks,

Jim

--

(Drupal^Ubercart) * (Design^Development^Hosting) = Sundays Energy

Posts: 4695
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Sounds to me like a bug report in the making. Eye-wink I can just doublecheck the code to make sure it's checking the right fields and use a little strtolower() to get rid of case matching. I should've done that already anyways.

(EDIT: Current code looks correct, though it'll need some testing I guess. I'm definitely using strtolower() all over the place in there, though.)

Posts: 57
Joined: 08/23/2007

Yeah, I can believe that! Well, I appreciate you looking into this, especially since it's becoming pretty off-topic....

Cheers,

Jim

--

(Drupal^Ubercart) * (Design^Development^Hosting) = Sundays Energy

Posts: 1
Joined: 02/23/2008

I believe you have violated the privacy of [ Company ] and [ Customer ] by posting their address and phone number. This information was used to place an order, not to be posted on a forum.

Posts: 4695
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Good point. This information has been wiped from our database.

Posts: 18
Joined: 03/16/2008

Hi, there.

I'm looking for a way to display each order's balance in the table. Has anyone done that already?