This module provides the ability to manage purchased files with Drupal Commerce. Commerce File is packaged for download at http://drupal.org/project/commerce_file.

Install

  • Setup your private file system path at admin/config/media/file-system.
  • Place the entirety of this directory in sites/all/modules/commerce_file
  • Navigate to administer >> build >> modules. Enable Commerce File.

Recommended modules for use with Commerce File

  • File Field Sources

Implementation

Field Setup

  • Navigate to Manage Fields on a Commerce Product type, ie admin/commerce/products/types/product/fields
  • Add a field of type "Commerce File"
  • Choose an upload destination, ie Private Files
  • Enter file settings
  • Enter Access Limit settings or leave as default for unlimited access. These settings are applied to the customer's file license upon purchasing

Adding files to products

  • Edit a product at admin/commerce/products
  • Upload a file to the Commerce File field
  • [Optional] Set Access Limits for the uploaded file. This will override the field settings.
  • Save the product

What happens when a product with a file is purchased?

  • A Commerce File field on the product Commerce line item is populated with the files from the referenced Commerce Product. This provides a snapshot of the file and access limits, similar the product's sell price.
  • The line item field is synced with the referenced product on cart refresh. This refreshing continues while the order is considered to be in the shopping cart.
  • Once the order is not considered to be in the shopping cart, the line item's Commerce File field's value is frozen and represents the customer's as purchased file and access limits.
  • When an order's status is updated to 'Completed', then the file and access limits are issued to the customer's user account. This process is controlled by a rule and can be altered to include any other logic before issuing.
  • The customer's purchased files are viewable at user/[uid]/licensed-files. This is a view and can be altered to display the file licenses any way necessary. The license contains the user's uid, file, all referenced line items for the same file, and native file access limits for an admin to adjust the limits.

Access Control

  • File downloads are controlled with the default Rule "Control access to licensed file downloads"
  • A user can download their purchased file if they have an Active license with no limits that have been exceeded.