Purchases Listing

Contrib type: 
Module
Status: 
Work in progress

Downloads

Compatibility: 
Ubercart 1.x

This module provides a tab on the product page named “Purchases” and provides a listing of the orders made for the product. The default listing includes all orders and is sorted descending by date. To access this tab, a user must have the ‘view purchases list’ permission (available with this module).

There are 3 list formats with corresponding tabs:

List View
3 column table, column one has the order details (including attributes), column 2 has the billing address, column 3 has the delivery address. The addresses here are formatted using the us_address_format function. If the user has ‘view all orders’ permission, the ID value is displayed as a link to that page.

Table View
This view provides the data in one large table. The addresses here are currently US centric (I need a better understanding of international addresses). If the user has ‘view all orders’ permission, the ID value is displayed as a link to that page. If the product has attributes, the attributes populate separate columns.

Download
Not really a view per se, but this option provides the data as a CSV file. The method for creating the file follows the method used by the Webform module.

Currently you can query the listing by date, the default dates are the first/last order dates and the defaults.

It’s just a start and I already see a number of ways of improving on the module. Any thoughts or ideas would be appreciated. I created this module as we have a number of events that people can sign up for and we wanted to be able to provide access to “registration” information to users who are organizing the event, but are not administrators of ubercart. I found the some posts on signup/event module integration (noted below), but since that integration doesn’t currently exist, I thought this might work in the short term.

The files are attached as both .tar.gz and .zip


PreviewAttachmentSize
uc_purchases.zip4.64 KB
uc_purchases.tar.gz4.38 KB
sparq-l's picture
Offline
Joined: 12/19/2007
Juice: 79
Re: Purchases Listing

Just wanted to say this is a great module. One suggestion, have you considered adding a status filter it?

It seems it would be really useful to narrow purchases by date and order status. Looks like I need to learn some PHP...

rjl@drupal.org's picture
Offline
Joined: 01/18/2008
Juice: 28
Re: Re: Purchases Listing

Definately a good idea. My original intention was to include status in the filter in this first iteration, but we really needed something fast, so I skipped it for the short term as it wasn't vital for what we needed. I hope to get back to this in the next week or so as there are some other changes that I would like to make as well.

Thanks

rjl@drupal.org's picture
Offline
Joined: 01/18/2008
Juice: 28
File Update

I have updated the files.

1. There was a small bug in the date selector that has been fixed
2. Added Order Status to the filter
3. Updated a number of string values to use the t() function.

AttachmentSize
uc_purchases.tar.gz 4.01 KB
uc_purchases.zip 4.27 KB
sparq-l's picture
Offline
Joined: 12/19/2007
Juice: 79
Re: File Update

wow, that's killer. I'll install it and let you know if I have any bumps.

cosmicdreams's picture
Offline
Joined: 07/11/2008
Juice: 6
Found / Fixed a bug

In my use of the module I found that the first page hit of the product listing showed proper information. But if you refresh the page, you'll notice that the start and end dates are both set to 1969 (this also occurs if you click on the Table or Download links). I think I was overly aggressive in fixing this for my site, since I effectively fixed it two different ways. You can take you pick which you'd like to include;

1st way : lines 69-71
//added extra check to handle error
$start_date = isset($_SESSION['uc_purchases']['start_date']) ? $_SESSION['uc_purchases']['start_date'] : $_SESSION['uc_purchases']['created_min'];
$end_date = isset($_SESSION['uc_purchases']['end_date']) ? $_SESSION['uc_purchases']['end_date'] : $_SESSION['uc_purchases']['created_max'];

2nd way : lines 79-84
$_SESSION['uc_purchases']['order_count']=0;
$_SESSION['uc_purchases']['start_date']=$now;
$_SESSION['uc_purchases']['end_date']=$now;
$_SESSION['uc_purchases']['created_max']=$now;
$_SESSION['uc_purchases']['created_min']=$now;
$_SESSION['uc_purchases']['qty_sum']=0;

2nd way : lines 87-92
$_SESSION['uc_purchases']['order_count']=$row->order_count;
$_SESSION['uc_purchases']['start_date']=$row->created_max;
$_SESSION['uc_purchases']['end_date']=$row->created_min;
$_SESSION['uc_purchases']['created_max']=$row->created_max;
$_SESSION['uc_purchases']['created_min']=$row->created_min;
$_SESSION['uc_purchases']['qty_sum']=$row->qty_sum;\

The problem was caused by relying on the update function to set the start_date and end_date functions with the proper value while also setting other session variables like created_min and created_max during the first page hit. Since it is possible for a user to hit the page a second time without executing and update, the error resulted.

For the first way I fixed this problem, I added a check for the existance of start_date and end_date. If they don't exist I use the created_min and created_max values.

After doing that I realized that the truly proper way of fixing this is the set the start_date and end_date during the first hit along with the rest of the session variables. So the two parts I've included accomplishes this for both outcomes of the logic tree provided near line 74.

Marillion@drupal.org's picture
Offline
Joined: 08/29/2008
Juice: 15
Is it possible to make the table view sortable?

Hi,

first of all, thanks for this great module! It is very useful for my needs.

Could you make it possible to have the table view sortable, especially sortable for product options?

So far I have to download the list and sort it somewhere else, that means extra work...

Greetings
Markus

reuben005's picture
Offline
Joined: 11/01/2008
Juice: 11
Re: Is it possible to make the table view sortable?

is it possible to have a list of all products for which an order has been placed? i actually want to have a list of products for which an order has been placed, so that i can place an order for it at my end, and then dispatch it to my customers.

drupalmind's picture
Offline
Joined: 01/06/2009
Juice: 46
Re: Re: Is it possible to make the table view sortable?

When to port to drupal 6?
i have client to see the same thing by using drupal 6
any other related method which will provides per products orders or say purchases will be very help full for me but drupal 6
thanks in advance

drupalmind's picture
Offline
Joined: 01/06/2009
Juice: 46
When to port to drupal 6?

sorry^^^^^^^^^^^^^^^^^^
When to port to drupal 6?
i have client to see the same thing by using drupal 6
any other related method which will provides per products orders or say purchases will be very help full for me but drupal 6
thanks in advance

drupalmind's picture
Offline
Joined: 01/06/2009
Juice: 46
I have tried to port it for drupal 6

I have tried to port it for drupal 6. there are some problems occur but i don't understand what was that.
i don't get any output...if anyone get the solution please discuss

AttachmentSize
uc_purchase-d6.zip 4.3 KB
hedgehog's picture
Offline
Joined: 10/07/2008
Juice: 14
Bug persists with Download link?

Hi, thanks for this great module and thanks cosmicdreams for fixing the bug with the date. I put in both your fixes and it worked except for when I click the Download link, in which case I get a blank file, unless i make sure to click the Show All button first.

Do you know how this could be fixed?

starryeyez024's picture
Offline
Joined: 03/12/2009
Juice: 17
Company name error

there was an error in your code causing the company name to not display in the table view.

it said $row[] = $data->billing_company_company;
and $row[] = $data->delivery_company_company;

in two places in the code, where it should have only been
$row[] = $data->billing_company;
and $row[] = $data->delivery_company;

Also I'm not sure how to change the settings either in Drupal or within this module to disable the paging of the data. At the bottom of either the list view or the table view there is a list of page numbers because there's so many entries, and so when I download a .csv file, it only exports whatever page I'm viewing at the time instead of all the data.

Help?

Terrence LP's picture
Offline
Joined: 08/12/2008
Juice: 4
Bug persists with Download link?

I'm taking a stab at fixing this and here is where I'm looking -

in uc_purchases.module - the query output is limited to 25 records like so:

line 106 - $result = pager_query($sql, 25, 0, $sql_count, $nid, $start_date, $end_date);
line 115 - $result = pager_query($sql, 25, 0, $sql_count, $nid, $start_date, $end_date);

and then there is the theme layer -

line 159 - $out .= theme('pager', NULL, 25, 0);
line 271 - $out .= theme('pager', NULL, 25, 0);

so I'll test and see what's causing the download link to be limited to 25 records, stay tuned!