When you purchase a license for a file the first time, its granted and actual download count is displayed at the customer's Files user area (at user/[UID]/my-files). For example: 1/10 when the file has been download 1 time out of 10 possible times.
When the same user purchases the same file later, it gets displayed in addition to the first one, linked to the same download link, with the expiration date later than the original's one, but its download counter re-credited to 0/10. See the attached screenshot 1.
Subsequent downloads will only increment the original counter. See the attached screenshot 2.
When the original file's download limit is reached (10/10), no more downloads will be possible, even for the newly purchased file that should still have all 10 downloads possible. See the attached screenshot 3.
Comments
Comment #1
Tyler the Creator CreditAttribution: Tyler the Creator commentedI'm looking into this issue (or at least a similar one) on one of my current projects. The module is coded with the intention of only having 1 active license per product. If the user manages to buy more than 1 license of the same product, the module grabs the first license it finds and ignores the rest. Meaning when it comes time for the module to check if a file should be downloadable, it grabs the same license for both and checks the download limit on just that 1 license, making both files either downloadable or not.
I'm trying to make a patch to fix this functionality, I'll upload it once I figure out an elegant solution.
Comment #2
bojanz CreditAttribution: bojanz commentedI'm not convinced it makes sense to have multiple active licenses for the same file.
A better approach might be to simply forbid that.
Comment #3
Tyler the Creator CreditAttribution: Tyler the Creator commentedWith our project, we want to use something of an "honour system". A user can certainly buy a license to a file, and then distribute that file to as many people as they want once they've downloaded it, but we hope that if a user wants 30 files, they would buy 30 licenses. In that case, a user would need 30 different active licenses (at least until they're downloaded) for the same file.
Also as the module works right now, once a file hits it's download limit, if a user went to buy a new license for that same file, the commerce_file_can_download function is still grabbing the license that has already hit the limit, so the new file can't be downloaded.
You can certainly let me know if these scenarios aren't what the module is intended for, and I can try to find another solution.
Comment #4
roball CreditAttribution: roball commentedImagine the case when you have set the download limit to 1 (one time) and no expiration. After a customer has bought the license and downloaded the file, he will never ever be able to download the file again, even if he purchases it again years later.
Comment #5
bojanz CreditAttribution: bojanz commentedOkay, let's fix that properly then.
I won't have time for this bug in the upcoming days, so a patch would be helpful.
Comment #6
roball CreditAttribution: roball commentedGreat to hear you agree, bojanz that there may be scenarios where it indeed makes sense to purchase the same file more than once. Another example is when a file will be replaced by a newer, enhanced version, which customers may want to purchase as well.
Interested in the patch Tyler Pepper announced to try rolling out.
Comment #7
Tyler the Creator CreditAttribution: Tyler the Creator commentedI believe I have it working correctly, I added some code to pass the license_id on the file's views row to the formatter, and if the license_id isn't part of the view it just falls back to the original code (though that shouldn't really happen, since the download limit field on the view is also assuming that the license_id field is in the view). I also fixed a problem where clicking on a file belonging to 1 license would mark another as downloaded by passing the license_id into the file download url query, and making sure that the download token was distinct to each license_id.
Let me know if this works for you.
I patched both 7.x-2.x-dev and 7.x-2.0-beta2.
Comment #8
Tyler the Creator CreditAttribution: Tyler the Creator commentedMarked for review.
Comment #9
roball CreditAttribution: roball commentedTyler Pepper, thanks a lot! Your patch
commerce_file-allow_multiple_active_licenses_per_file-2215357-7-7.x_2.x_dev.patch
from #7 is working perfectly for me! FYI, it can also be applied against the stock 7.x-2.0-beta2 release.Comment #10
roball CreditAttribution: roball commentedThe attached screenshot shows how the My Files section looks now (after applying your patch) :-)
Comment #11
Tyler the Creator CreditAttribution: Tyler the Creator commentedI have to open this back up for review since one of my co-workers QA'd our project and found a bug where a user could download a file with multiple licenses indefinitely until the page was reloaded. The new patch contains everything from before, plus a check to reload the page once the download limit is hit, while displaying a Drupal error message. The patch also changes the original direct to 403 page functionality to the same page reload & Drupal error message when trying to download a file with 1 license multiple times passed the download limit.
Comment #12
roball CreditAttribution: roball commentedTyler Pepper, thanks a lot! I very much like the automatically loading of the my-files page once the download limit has been reached, with the error message. I think the wording 'Please purchase more downloads from the store.' may be better renamed in something like 'If you need more downloads, you may want to purchase another license.'
Comment #13
roball CreditAttribution: roball commentedSorry, just found a bug:
Although the my-files page perfectly displays the different purchases of the same file perfectly, the Checkout complete page a customer will see directly after completing the payment doesn't if you have purchased a file in the past and already hit its download limit. When you purchase the file again, the Checkout complete page only contains references to the very first purchased file. Since that one no more has a download grant, they will display without any download link.
Comment #14
Tyler the Creator CreditAttribution: Tyler the Creator commentedOh ok, I assume that's with the License information and License completion message checkout panes enabled? That's probably why I missed it (both are disabled on my project at the moment). Thanks for picking that up!
Comment #15
roball CreditAttribution: roball commentedI have the License completion message pane enabled on the Checkout complete page. The License information is kept Disabled, since it did not seem to provide any information.
You can see the attached screenshot how my Checkout complete screen looks. I have purchased the same file twice. It was already purchased earlier and its download limit has been reached. Thanks for your work on it!
I think it would also be useful to see in the Checkout complete screen how many times each purchased file can be downloaded.
Comment #16
roball CreditAttribution: roball commentedIn addition to the problem reported in #13, the patch from #11 introduces another problem:
Each time the admin visits admin/commerce/licenses the dblog logs the following two PHP notices per licensed file:
and
After reverting the patch these errors no more occurred.
Comment #17
Tyler the Creator CreditAttribution: Tyler the Creator commentedThanks for catching these problems! I can understand how certain things work in 1 project but not another due to minute differences in the configs. Here's a new patch. I couldn't get the dblogs to show your error but I think I managed to fix it. Let me know!
Comment #18
roball CreditAttribution: roball commentedThank you very much for the revised patch - now everything seems to work perfect! File links display fine on the License completion message pane, and there are no more PHP notices. Would be nice to get this committed.
Comment #19
roball CreditAttribution: roball commentedbojanz, do you think you will find some time to review Tyler Pepper's patch from #17? It is working fine for me.
Thanks!
Comment #20
roball CreditAttribution: roball commentedComment #21
roball CreditAttribution: roball commentedThe patch from #17 no longer applies to the recently released 7.x-2.0-beta3:
Comment #22
Tyler the Creator CreditAttribution: Tyler the Creator commentedNice catch! Try this one.
Funny thing is that I think what was breaking #17's patch was another patch that I made that got committed and released.
Comment #23
Tyler the Creator CreditAttribution: Tyler the Creator commentedComment #24
roball CreditAttribution: roball commentedPerfect - patch #22 works perfectly, thank you.
Now we have to wait for bojanz's decision on committing it.
Comment #25
bojanz CreditAttribution: bojanz commentedI'll try to review this soon. It's definitely a release blocker for me.
Comment #26
roball CreditAttribution: roball commentedExcellent news, thank you bojanz!
Comment #27
drakythe CreditAttribution: drakythe commentedI just applied this patch and #2219835: Commerce File Download Limit Hook - Commerce File Bulk so I could use your commerce_file_bulk module, Tyler, and they work great!
This module however introduced a whitespace and file permission issue, so you may want to re-roll it.
The errors I got on applying this patch (after #2219835: Commerce File Download Limit Hook - Commerce File Bulk):
commerce_file-allow_multiple_active_licenses_per_file-2215357-22-7.x_2.x.patch:47: trailing whitespace.
warning: commerce_file.module has type 100755, expected 100644
warning: 1 line adds whitespace errors.
Comment #28
Tyler the Creator CreditAttribution: Tyler the Creator commentedHmm I just applied both patches (Download Limit Hook first, then this one) on both 7.x-2.0-beta3 and 7.x-2.x-dev and I couldn't reproduce the whitespace errors. Which version of the module are you using?
Comment #29
drakythe CreditAttribution: drakythe commentedTyler, I was using the dev version, I just tried it again with the Beta-3 and confirmed the error. I've attached a screenshot from vim with whitespace highlighting on this patch (the red bit). Again just to clarify, I applied both of your patches in the order of #2219835: Commerce File Download Limit Hook - Commerce File Bulk Then this one. They apply, but change the file permissions and add a white space, both errors occur on OSX/Linux when applying this patch.
Comment #30
Tyler the Creator CreditAttribution: Tyler the Creator commentedOh ok, I see it now. Try this new patch:
Comment #31
pun_pun CreditAttribution: pun_pun commentedHello!
Tyler Pepper, thank you for your patch!
I use commerce kickstart (7.x-2.17)+Commerce File 7.x-2.0-beta3 and your patches work only for Checkout pane (CHECKOUT COMPLETE) but in the user profile "files" tab there are inactive links. The same inactive links are in the product list in the shop. I applied patch #30 and #2219835: Commerce File Download Limit Hook - Commerce File Bulk... Maybe I've missed something?
And for anonymous users displays the alarm "This file has hit the download limit. If you would like to continue downloading this file, please purchase more licenses from the store. 404 ERROR Not found" but not "403 error. Access denied" when try to use download link. I think it is not really correct.
Thank you!
Comment #32
pun_pun CreditAttribution: pun_pun commentedHello! I think, I found the reason why links are not active for newly purchased additional licenses for the same product. When using more then one licence for the same file the counters do not count downloads for each licence separately (licenses are different, but download link is the same). Any downloads by any licence shows only on the first licence counter until it reaches the download limit (10/10) and then all download links become inactive for all licenses. %)
Comment #33
Tyler the Creator CreditAttribution: Tyler the Creator commentedHey pun_pun, I haven't tested my patches with commerce kickstart so it could be working a bit differently than regular commerce for some reason. It's something that I (or someone else in the community) will have to look into when we have time. Hopefully this can get resolved soon as I really hope that these Commerce modules get patched with the new fixes.
Comment #34
pun_pun CreditAttribution: pun_pun commentedTyler Pepper, thank you! I'll be waiting for the news. :)
Comment #35
bojanz CreditAttribution: bojanz commentedThis will need to be rerolled / retested now that #2302897: Access token generation changed in file_entity module has been committed.
Comment #36
Tyler the Creator CreditAttribution: Tyler the Creator commentedNew patch attached based on newest version of 7.x-2.x-dev
Comment #37
Tyler the Creator CreditAttribution: Tyler the Creator commentedComment #38
Tyler the Creator CreditAttribution: Tyler the Creator commentedWondering if anyone can review this, or if it needs to be rerolled again. It would be nice to get this committed.
Thanks!
Comment #39
Tyler the Creator CreditAttribution: Tyler the Creator commentedAnyone? :\
Comment #40
DamienMcKenna