uc_file now in core

Posts: 328
Joined: 08/07/2007
Administrator

I'm happy now to announce that file downloads, the other big feature request for ubercart, has been brought into ubercart core. Using our product features system, uc_file allows store admins to attach a file download to any product. This approach allows any ubercart product (not just pure digital products) to be associated with file downloads. For example, you could offer a specific SKU for a book product that not only includes a book but also a copy of an e-book or perhaps an MP3 audio book. Additionally, store admins can configure to send customers emails after payment that include file download links. A detailed list of features can been seen below. Thanks to cPill who's original uc_file_product was the basis behind this module. Also, thanks to torgosPizza who was helpful in working out the implementation for uc_file.

Features

  • Admins can set 3 optional limits on downloads (by # IP addresses accessed, by # of downloads, and by a set amount of time after purchase).
  • The hook hook_download_authorize can be used by developers to place further restrictions on downloads.
  • Unique download URLs. This means a customer doesn't need to log on to the store to download the file. Additionally, customers can always log on to view and download their previously purchased file downloads.
  • Customizable emails can be sent to customers informing them of file downloads and their links.
  • File downloads can be retroactively given to customers that have previously purchased certain model SKUs.
  • Admins can grant file downloads through the user edit page.
  • A basic file manager displays all files that exist in the file download directory and if they have an associated product or SKU. Admins can also upload and delete files through this page.
  • The hook hook_file_action that allows developers to create new actions on files (for example an action that would add watermarks to select image files).

As a last note, I named the module such to prevent name space pollution with the original uc_file_product module. Unfortunately, one table name, uc_file_product, overlaps a table created by this module. People enabling this module should be aware that the tables created by the uc_file_products module should be removed to test out this module. Pick it up via bazaar as usual.

--

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

Posts: 950
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Let me be the first to say, THANK YOU! And also a "wow" to some of those features. Quite an excellent list if I do say so. I'll be glad to add this to a test site and give it a whirl.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 950
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

A couple findings:

I have it set to 3 IP address, unlimited downloads and no expiration. When adding the File Download feature to one of our products, checking "Retroactively purchase" in the process, the associated files did not show up under My Account. They only appeared after I went into the Orders admin and updated the status from Payment Receoved to Completed and then back to Payment Received.

In the Files tab, the two files are listed. However clicking on one of these links gives me this error message: You have downloaded this file too many times. Please contact the site administrator if this message has been received in error.

Both files (for the one product) show as having 0 downloads each. This is all with the latest bazaar checkout.

EDIT: Actually setting the Number of Downloads limit (in this case 100) fixed the problem. It seems you can't leave it blank at this point.

EDIT 2: After starting the download, the number of downloads displayed under the Files tab has not changed to reflect how many times I have actually downloaded the file. It is stuck at 0.

Sorry, another update, as I am playing around with this module. I noticed that the file products are attached to users. Is there a reason why this was the preferred method? I'm wondering because, as I've mentioned before, we have 16,000 or more customers (no joke) and if we add one file to a product that everyone has purchased (and they are out there) that would mean 16,000 queries to retroactively add a product to each order that exists.

Of course the retroactively purchasing aspect doesn't seem to work on my test site anyway so I can't really test properly. I'll be sticking to my current file product module but will be glad to continue testing the uc_file method of things on a separate site.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 328
Joined: 08/07/2007
Administrator

Ok lets see. I think I've fixed the problem with retroactive purchases. It was hard coded to check order statuses with a status of 'completed'. It now set to check the configurable status set in the product feature setting page. The problem with leaving the download limit to null has been fixed as well. As far as the download number not changing, did you refresh the page after the download? After the file has transferred (i.e.. the 2nd last line of _file_download_transfer.) the # of downloads should be updated in the database.

To answer your question regarding the table associating files to users, this is done to store the relationship between users and files. For each user's file download there are a number of things we need to keep track of (IP addresses accessed from, downloads transferred, unique hash key, etc.). I'm sure there are ways to implement this relationship, but this is the one that seemed the most evident to me.

As far as the concerns with the large number of queries that the retroactive purchase can occur, that is something I haven't tested yet. Any large store built on ubercart is going to incur a lot of queries, probably with a lot of time outs as we encountered with our true equipment parts site. Just because of the sheer numbers, you can't get around that. I'd recommend either inserting the PHP set_time_limit function or perhaps coming up with programmatic solution for setting up downloads for previous product purchases.

--

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

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

One possibility here would be to update the retroactive files through hook_cron() like Drupal does for search indexing. Have it query the DB for the data with say a 1,000 row limit each cron run. A simple select count(*) can tell you how many users or orders remain to be updated.

Then when you really need to apply the retroactive somewhere, you can just hit cron as many times as you need. Search indexing has a simple form that will call the same function from a form for easier use.

Posts: 950
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Now that's not a bad idea. I could write a module to do that for now, unless it's something that has the potential for Core development later on. I could always just write it as a Contrib. I do like the idea of being able to do all of my product updates separate from the actual database update. (In other words, get all of my files updated across the catalogue, and THEN find and add it to previous orders).

And hey .. am I a bug finder now? Eye-wink

I am going to play with uc_file some more this weekend and will also work on the output a little. In case you haven't seen it, attached is a screenshot of my current File Product module's custom jQuery, accordion My Files page. (The blue bar is the over state for that DIV - clicking on it expands that file view and contracts the currently opened one).

EDIT: Choosing "Any" SKU when assigning a file to a product, and then submitting, yields a blank white screen. Also how hard would it be to add another field to the process? Can I do this with hook_form_alter()? In our case I like to include a tiny bit of "helper text" for "what file this is" - PAL, NTSC, DivX, etc. (See my screenshot).

AttachmentSize
tp_MyFiles.jpg202.72 KB
--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

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

Your setup looks sweet, and you can use hook_form_alter() to add anything to that form. And you're totally a bug finder now. Eye-wink

The feature to incrementally add recursive products to users is ripe for core inclusion. I don't know if Shawn had a chance to address it or not. I'm totally stoked about getting Shawn's last two modules in core, though. These were the 2 most requested features on the forums and at Drupalcon. Cool

Posts: 28
Joined: 10/25/2007

wow this module is pretty freakin swuh-eeeet.

which payment gateway, methods are you using and are those automatically updating the order status to that which will grant the download permission?

i'm using the paypal wps and it (after successful paypal transaction) 1. doesn't clear the cart 2. doesn't automatically update the order to complete, for an order that is exclusively file download

should i hack these? would be an ugly betty hack job...

Posts: 28
Joined: 10/25/2007

@tP

troll 2 in your file list?

=P

Posts: 950
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

troll 2 in your file list?

Yeah, I work for RiffTrax. Mike Nelson (from Mystery Science Theater 3000) and Rich "Lowtax" Kyanka of Something Awful fame, did a humorous commentary for it, a la MST3k.

http://www.rifftrax.com/cart.php?m=product_detail&p=58

And so your problems are with the uc_file module.. and not uc_file_product right? Because they are different and do not play nice together. Need to disable uc_file_product before you can use uc_file.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 28
Joined: 10/25/2007

core uc file is working properly... i think paypal is the hang up here

it would be nice if i could get paypal wps successful transaction reponse to 1. automatically update the order status to "complete" and 2. have the cart cleared

maybe someone's done this or is doing it? ...before i go tear things apart and put it back together such that looks like it's working on the surface but is actually hosed up (that's what usually happens when i start hacking)

Posts: 950
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Well I've noticed that returning from PayPal WPS sets the order status to "payment_received" - so if you set your uc_file settings to look for that order status as the condition where the file's added to the user, that should fix it.

I don't have the issue of the cart not clearing - every time I've tested with WPS I have not had a problem. The cart clears, the order status is payment_received, and the file shows up in the Files tab.

I hope you resolve your problem!

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 4
Joined: 11/03/2007

Just another noob here...
Where is the uc_file settings in laymans terms? Please

Thanks

Posts: 950
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Under Administer > Store Administration, click on Configuration and then Product settings. The third pane down will be for various product Features, one of which is file downloads.

admin/store/settings/products/edit/features

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 2
Joined: 01/11/2008

Hi there. I'm sure I'm going a bit crazy, but I'm trying to put Model/SKU for some files I've added. I really can't see where to add them in to. Where should I be looking, or do you actually have to do some coding? I've had a site running with Drupal for a while, but I've only just added uberCart. I'm using version 5.x-1.0-beta1 of uc_file.

Posts: 950
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

When you are Editing a product, click Features, and then you can use the drop-down and Autocomplete text fields to associate a file, one at a time, with a product. HTH

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 2
Joined: 01/11/2008

Thanks - got it now. In the theme I'd put together I'd actually missed the bit of code to put the tags at the top of the page. All fixed now!

Posts: 3
Joined: 02/19/2008

I've got a couple of issues with my UberCart File downloads I wonder if anyone can help.

1. I recevied notification that the transaction from PayPal happened but it didn't change the Status of the order.

2. How do make use of the Customised Email featured mentioned in this post?

Many thanks,

Rob