Quantcast
Viewing all articles
Browse latest Browse all 426

Grant file licenses to past orders after updating a product's files

If your customers have purchased a product and you forgot to attach the file or need to attach additional files, this recipe will allow you to grant file licenses to customers who have purchased the product in the past.

Image may be NSFW.
Clik here to view.
commerce_file-retroactive_licenses.png

Requirements

Commerce File
Rules
Views Bulk Operations

Create the Rules component

The exported component is below, here are the steps to create it:

  1. Create a new Rules component of type Action set.
  2. Add a variable to your component of type Commerce Order, give it a label (Commerce order) and machine name (commerce_order). It's usage is Parameter.
  3. Add an action: Commerce File License > Issue licenses for files in the order.
  4. In the data selector, choose the Commerce order variable you set up in step #2. Set the issued license status to Active, and check Refresh line item files based on the product files (this is the key to granting licenses based on the files attached to your current products).

{ "rules_retroactively_grant_file_licenses" : {
    "LABEL" : "Retroactively grant file licenses",
    "PLUGIN" : "action set",
    "REQUIRES" : [ "commerce_file" ],
    "USES VARIABLES" : { "commerce_order" : { "label" : "Commerce order", "type" : "commerce_order" } },
    "ACTION SET" : [
      { "commerce_file_license_issue_order" : {
          "order" : [ "commerce-order" ],
          "license_status" : "active",
          "product_refresh" : 1
        }
      }
    ]
  }
}

Modify your orders view

You could also create a new view or view display.

Navigate to admin/structure/views/view/commerce_orders/edit/admin_page.

  1. Add a field to your view: Bulk operations: Commerce Order
  2. Under Selected bulk operations, check Retroactively grant file licenses (or whatever you called your Rules component).
  3. You'll then probably want to move the VBO field you just added to make it the first field, so that your checkboxes are in the first column.

Now when you need to grant licenses for past orders, just select the relevant orders and choose the "Retroactively grant file licenses" action.

AttachmentSize
commerce_file-retroactive_licenses.png16.51 KB

Viewing all articles
Browse latest Browse all 426

Trending Articles