Discussions

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

Posted: Oct 1, 2011

Comments

commercestudy on October 2, 2011

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

ccollins61 on November 28, 2011

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

Brian on November 29, 2011

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" ] } }
    ]
  }
}

Brian on December 5, 2011

{ "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" ] } }
    ]
  }
}

Sergio on January 5, 2012

Hi Brian.
When I import get the error:

Integrity check for the imported configuratoin failed. Error message: Missing configuration for parameter license-status..

Thanks.

Brian on January 10, 2012

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.

Zyurelaie on January 12, 2012

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

Zyurelaie on January 7, 2012

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

Brian on January 10, 2012

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.

Zyurelaie on January 12, 2012

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

Zyurelaie on January 12, 2012

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?

Brian on January 13, 2012

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?

Zyurelaie on January 13, 2012

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

Zyurelaie on November 3, 2012

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?

drupalcommerce Check out the #Drupal Commerce 2.x Roadmap to see where you can get involved: http://t.co/WAc3jmXY2a
drupalcommerce A new blog discussing the new showcase listing http://t.co/FHOzhAg3tl http://t.co/J5C87imjhb
drupalcommerce RT @drupalcon: Thanks @CommerceGuys and @CommerceJohn for your support, and for #CommerceKickstart! Take the tour http://t.co/ivKEYH7k0o
drupalcommerce Updating our extensions directory: 665 new or updated modules, distributions, sandboxes, & themes. http://t.co/6NMMofYo12 #weloveyouguys