Selling downloads – How I got it working
Since there is not much info available on how to make the magic of automated-download-access work, I'll post roughly how I did it.
1. Create a commerce product as usual and add a "Commerce File" field (from the Commerce File module). There you will have to specify a private location for the stored downloadfiles since they will be protected.
2. Set permissions for the customer role (e.g. auth. user): "Access own commerce file license"
3. Do two rules:
(a) On payment success >> Issue licenses for files in the order
(b) On requesting a download >> condition: user has role [e.g. auth. user] >> Allow download
The second rule took me a few days to figure out because you can't set it in the shop-rules. Go to the general rules and create it there. I have tried to allow downloads on payment success or whet the license was issued but that doesn't work.
The customer process now works like this:
Anonymous user puts product in the cart.
Checkout
Recieve email with login
Login
Click on "Files" tab. Klick on the listed file > downloading...

Comments
This is a chart I made for my
This is a chart I made for my documentation. Maybe someone else might find it useful to begin with.
Thankyou Brian
Thankyou for writing your progress down with downloadable files and the chart.
I fully intend to build a site with downloadable items in the near future. But I am glad you are sharing the knowledge now. So there will be a nice reference for myself and others.
Best regards from Josh
Challenges setting this up
Brian, your posting is much appreciated. Being new to Drupal commerce and several of the related modules, I'm having some challenges getting this set up.
1) I don't see the option to give customers permission to "Access own commerce file license," only "Access own commerce file license logs"
2) I'm clueless on how to set up the rules correctly - I can't find any clear documentation on the step-by-step process
Could you point me to a source that provides a bit more detail on how to get this up and running? I see there is a capability to import rules. Would it be possible to get an export of the rules above and import them?
I'm working on providing the ability to download individual mp3 files (Messages), and more challenging, sets (Message Series) of mp3 files. I thought maybe tarring them into a single file, but the file size may get to be ridiculously large. Will see when I get there...
I'm working on determining how to convert messages at http://rightstartradio.org to mp3 products and CDs. We're giving away the daily radio broadcasts, but will charge a modest fee for the full length, un-edited message.
Thanks!
Chuck
Commerce Downloads
I found http://drupal.org/project/commerce_downloads, have installed it and am working through the examples. Looks like this might provide everything required...
Yes it's a bit challenging.
Yes it's a bit challenging. But once you get it it works great.
For (1), if I go to /admin/people/permissions/list I have the option "Access own Commerce File Licenses" inthe Commerce File section. See the screen shot. If you don't have that I don't know why.
For (2), the first rule you create in Store > Configuration > Orders & Checkout > Checkout Rules. (admin/commerce/config/checkout/rules) This is to actually create the license where the customer later gets permission for in the second rule.
Click "add new rule", in the Action section click "Add action" and select "Issue licenses for files in the order". It should look like in the screen shot.
The other rule you'll have to create by going to Configuration > Workflow > Rules:
- Add new rule
- Add Event and select: Requesting a download for a licensed file
- Add Condition and select: User has role Authenticated User (or whatever role your customers have in your shop)
- Add Action and select: ALLOW download of a licensed file
These are the rules you can import with copy and paste. I don't know weather it works out of the box on your installation.
Rule 1
{ "rules_allow_download_file" : {"LABEL" : "Allow Download File",
"PLUGIN" : "reaction rule",
"WEIGHT" : "-10",
"TAGS" : [ "commerce" ],
"REQUIRES" : [ "rules", "commerce_file" ],
"ON" : [ "commerce_file_license_download" ],
"IF" : [
{ "user_has_role" : {
"account" : [ "commerce-file-license:owner" ],
"roles" : { "value" : { "2" : "2" } }
}
}
],
"DO" : [
{ "commerce_file_license_allow_download" : { "license" : [ "commerce-file-license" ] } }
]
}
}
Rule 2
{ "rules_allow_download_file" : {"LABEL" : "Allow Download File",
"PLUGIN" : "reaction rule",
"WEIGHT" : "-10",
"TAGS" : [ "commerce" ],
"REQUIRES" : [ "rules", "commerce_file" ],
"ON" : [ "commerce_file_license_download" ],
"IF" : [
{ "user_has_role" : {
"account" : [ "commerce-file-license:owner" ],
"roles" : { "value" : { "2" : "2" } }
}
}
],
"DO" : [
{ "commerce_file_license_allow_download" : { "license" : [ "commerce-file-license" ] } }
]
}
}
Hi Brian, the source of your
Hi Brian, the source of your two roles are identical. Could you post the second again, please? That would be a great help ...
Michael
Rule 1 (issue file license)
{ "rules_issue_file_license" : {"LABEL" : "Issue file license",
"PLUGIN" : "reaction rule",
"WEIGHT" : "9",
"TAGS" : [ "commerce" ],
"REQUIRES" : [ "commerce_file", "commerce_checkout" ],
"ON" : [ "commerce_checkout_complete" ],
"DO" : [
{ "commerce_file_license_issue_order" : { "order" : [ "commerce-order" ] } }
]
}
}
Rule 1 (issue file license) error
Hi Brian.
When I import get the error:
Integrity check for the imported configuratoin failed. Error message: Missing configuration for parameter license-status..
Thanks.
...
Sorry, I have no clue how to fix that. I guess there are no options defined for the license status (like pending, open, closed...). But I also don't know where to set that right now.
I got this too in my 7.9 site
Man, I am just striking out today. I would suggest maybe it has something to do with the option to allow access to own license files, except for the fact that it did give an option in the 7.10 interface but it didn't change anything. Still no working license issue...
I installed the dev and seems
I installed the dev and seems to have solved the problem.
Thanks.
still no "allow user to view own file liscence" permission
I have the commerce downloads module and I even reloaded and updated a,s ccollins61 pointed out, to no avail. Only access user liscence file logs permission is available. I had no trouble importing your rules but they do not work and i think it has something to do with this permission I cant seem to allow
...
Wow, I don't have that one. Maybe it is called differently in your (language-)version? In the description it says: "Allows users to view their own Commerce File Licenses."
Access own Commerce File Licenses
Allows users to view their own Commerce File Licenses. Warnung: Sollte nur vertrauenswürdigen Rollen gewährt werden; diese Berechtigung hat Auswirkungen auf die Sicherheit.
here is what I got
Drupal Version 7.9 with all of the same modules in the Drupal commerce downloads distro, but using the latest versions. I am going to download the distro ccolins61 linked to and see if maybe I set it up wrong and since I probably don't know what I'm looking for then I will see if i can run it on the latest Drupal core to see if maybe they aren't playing nice either. Ill Post back jumping for joy and/or waggling my yellow rookie streamer if I find anything interesting...
Update= only works on Drupal 7.7?
Ok Ive used the commerce download distro (with the 7.7 core) to test and it worked perfectly. I updated all of the modules to the latest releases without updating the core from 7.7 to 7.10 and the rules continued to work perfectly. then i built another site and another database with a Drupal 7.10 core and loaded it with the commerce downloads profile with no core files and got the same problem importing the rules but this time that missing allow_own_access to file license showed up where it did not in my 7.9 core site. I enabled it and all the modules and permissions to match those in the 7.7 site and still no issue of the file license. Then I updated all the modules that came in the commerce downloads suite and still no issue of commerce file licenses. It seems that these modules do not play nice with the updated Drupal core. Has anyone gotten this to work on the post 7.7 updates?
7.7
Ok, thanks for that information. I am still on 7.7 so I won't be updating for now. Maybe the latest dev version works for you too like it worked for Sergio?
yes
I am currently rebuilding site with the 7.7 core. The permissions access own randomly disappeared on me again but the downloads and file licensees work soooo i guess that's ok... :)
Access own ...
Shortly after the original post was made, there was an update to the commerce_file module. 7.x-1.0-beta2 ( http://drupal.org/node/1314544 ) "fixed" and issue ( http://drupal.org/node/1239258 ) which requested the "Access own commerce file license" be removed.
Hopefully this will help future readers.
Great post!
Cheers,
Jason
what about an option to have the customer choose from multiple..
What about an option to have the customer choose from multiple Commerce Files within one product. I am trying to have one product that comes in various formats. any ideas on how to give the user the ability to select from multiple files?
thats done with the product
thats done with the product part of the store. you create another field in the digital product like say size or color and then when you make a digital product display you make a corresponding field there and attach all of your corresponding products. I forget where you make it required to pick the options but you want to look that up. its not specific to the digital file. and yes a different product for every little variation can get to be a pain but they have other bulk input modules for that too. BTW guys they got this working as a feature and it now runs on newer versions of features. ill have to go look that up again. it says that its obsolete already so if anyone has an update on the cool thing to do now?