21 replies [Last post]
chibiaida's picture
Offline
Joined: 08/08/2007
Juice: 57
Was this information Helpful?

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!

Shawn Conn's picture
Offline
Administrator
Joined: 08/07/2007
Juice: 916
Re: Adding more columns to "View orders" page

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

chibiaida's picture
Offline
Joined: 08/08/2007
Juice: 57
Re: Re: Adding more columns to "View orders" page

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

webmasterkai's picture
Offline
Uber DonorBug Finder
Joined: 08/09/2007
Juice: 299
Re: Adding more columns to "View orders" page

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

Biodiesel * (ubercart + drupal) = Sundays Energy

detour's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 10/02/2007
Juice: 150
adding company name or other fields to the view orders page

(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.diff 2.18 KB
webmasterkai's picture
Offline
Uber DonorBug Finder
Joined: 08/09/2007
Juice: 299
Re: adding company name or other fields to the view orders page

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

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: adding company name or other fields to the view orders p

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.

webmasterkai's picture
Offline
Uber DonorBug Finder
Joined: 08/09/2007
Juice: 299
Re: Re: Re: adding company name or other fields to the view orde

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

Jmmb's picture
Offline
Joined: 08/23/2007
Juice: 301
Re: Re: Re: Re: adding company name or other fields to the view

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

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: Re: Re: adding company name or other fields to the v

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

Jmmb's picture
Offline
Joined: 08/23/2007
Juice: 301
Re: Re: Re: Re: Re: Re: adding company name or other fields to t

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

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: Re: Re: Re: Re: adding company name or other fields

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.)

Jmmb's picture
Offline
Joined: 08/23/2007
Juice: 301
Re: Re: Re: Re: Re: Re: Re: Re: adding company name or other fie

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

Kooda's picture
Offline
Joined: 02/23/2008
Juice: 2
Privacy Violation

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.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Privacy Violation

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

swill's picture
Offline
Joined: 02/09/2009
Juice: 32
Following up...

I also want to add the company to the orders view. Is this still the best solution for updating that view?

Thanks,

Will

acdtrp's picture
Offline
Joined: 03/16/2008
Juice: 59
Hi, there. I'm looking for a

Hi, there.

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

qrios's picture
Offline
Cool profile pic award.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 554
Re: Hi, there. I'm looking for a

I added a sortable username column to this table.
The only way to do this (1.6 is latest) is to hack. I hate this, gives me headaches.

Please provide a theming function for it to override this without hacking Smiling.

For illustration:
I altered function uc_order_admin.

Add to $header array:
array('data' => t('User name'), 'field' => 'o.uid'),

inside while ($order = db_fetch_object($result)) {:
$user = user_load(array('uid' => $order->uid)); //get user object

Add to $rows array:
array('data' => $user->name),

Cheers,

Kees

Drupal Ubercart iDEAL webshop

abubin1's picture
Offline
Joined: 03/12/2010
Juice: 53
Re: Re: Hi, there. I'm looking for a

i am sorry, i am very noob to ubercart. I do not know how to which fields is which.

I want to add sku and product description field into the view orders for user.

I manage to follow this guide and is able to add the column header but unable to add the fields itself.

Can someone please help?

qrios's picture
Offline
Cool profile pic award.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 554
Re: Re: Re: Hi, there. I'm looking for a

You could take a look at http://drupal.org/project/uc_views.

--------
Loungekussens maatwerk, lounge kussens en meer.

cis.vindesh's picture
Offline
Joined: 01/19/2011
Juice: 11
Delivery dates in order in Ubercart

Hello everyone,

I am facing Order view page column add and remove problem
I want to add more column in order view page

Each product line should have two properties:
1. Delivery date. Either in past or in the future. As of now to be set manually.
2. Status. At least two - {Opened, Closed}. As of now to be set manually.

Please guide me how to override
/**
* Handle the "Products" order pane.
*/
function uc_order_pane_products($op, $arg1) {
switch ($op) {
case 'view':
return drupal_render(tapir_get_table('op_products_view_table', $arg1));

case 'customer':
return drupal_render(tapir_get_table('op_products_customer_table', $arg1));
------------------------------------------------------------------------------------------------------------------------
/**
* Build the order view products table.
*/
function op_products_view_table($order) {
.
.
}

/**
* Build the order customer's view products table.
*/
function op_products_customer_table($order) {
...
}
Path: ubercart/uc_order/uc_order.order_pane.inc

AttachmentSize
Order View.png 10.11 KB
erica's picture
Offline
Joined: 11/02/2011
Juice: 9
Adding Columns Is Urgent

The selection of values to show in the Orders page (/admin/store/orders) is simply inadequate. As this thread shows, many people need this feature. Our use case is probably not unusual. Our journal is purchased primarily by institutions. For name, people just put in something like "Library". Without being able to see the company/institution name, we just see a huge list of orders that are indistinguishable from each other, and have to look up every one. I've looked over the uc_order_admin() function and see how it needs to be changed to add in the 'billing_company' or 'shipping_company', but it looks like to make the change, I would have to hack the uc_order module, which I am not willing to do. I'm a relative newcomer to Drupal and Ubercart, so maybe there is something I'm missing -- if so, please clue me in. Otherwise, I would urge the maintainers to make the Orders page more flexible.