I'm working on a module that attempts to tie commerce_license in with the ACL (Access Control Lists) module.

I am attempting to sell access to an individual node. I have a product type, product, and product display which does this. I have a node reference field which allows an admin to select which node to license on product creation, and this reference field is being correctly referenced in my license class (the one in plugins/license_type/ which extends CommerceLicenseBase).

In my save() function, I'm checking to see if the status is COMMERCE_LICENSE_ACTIVE before I add the license owner to the acl, but it appears that the license never gets in this state. I have gone through the checkout process, and even manually completed the order, but I don't ever see the license get to the "active" state.

I've also noticed that the license seems to be created (the save() function is called) when a product that is associated with a license is added to the cart, and NOT on checkout, as is stated in the documentation.

I think the real issue is in my lack of understanding of how the commerce license module works (and possibly how the ACL module works, but that's a different discussion). I've read through the documentation, watched a few tutorials, and looked through the example code, the commerce_license_role module, as well as the commerce_license_og and commerce_file modules, and I'm still not sure what I'm doing wrong - I'm beginning to suspect that my error is not in the code itself, but rather in configuration.

Here is my code:


  public function save() {

    if ($this->uid && $this->product_id) {

      // Get the entity referenced 
      // (this works fine - field is defined in the .module file)
      $node = $this->wrapper->product->commerce_license_acl_node->value();
      $acl_name = 'ACL_' . $this->product_id . '_' . $node->nid;

      // Get the acl associated with this node and product ID
      $acl_id = acl_get_id_by_name('commerce_license_acl', $acl_name);

      // If the ACL doesn't already exist, create it

        // Create ACL if one is not already associated with this license
        $acl_id = acl_create_acl('commerce_license_acl', $acl_name);

        // Grant ACL users read access to this node
        $read   = TRUE;
        $update = FALSE;
        $delete = FALSE;
        acl_node_add_acl($nid, $acl_id, $read, $update, $delete, 0);


      $owner = $this->wrapper->owner->value();

      // I realize a lot of this is redundant. I'm covering all the cases here for my benefit
      // in trying to understand what is going on.
          // *** This case is never true
          acl_add_user($acl_id, $owner->uid);
          drupal_set_message('license_acl set to active');
          // **** This is the state that it always seems to be in
          drupal_set_message('license_acl created');
           drupal_set_message('license_acl set to pending');
          acl_remove_user($acl_id, $owner->uid);
          drupal_set_message('license_acl set to expired');
          acl_remove_user($acl_id, $owner->uid);
          drupal_set_message('license_acl set to suspended');
          acl_remove_user($acl_id, $owner->uid);
          drupal_set_message('license_acl set to revoked');




Is there any documentation out there which goes into depth explaining the workflow of commerce license creation and statuses? Thanks in advance.

1 Answer 1


It looks the license is being activated when the "order paid in full" trigger fires, and I didn't have a payment system in place. I thought I had it configured to bypass this, but enabling the example payment system and the payment ui solved the problem.

However, the user still doesn't have access to the node associated with the ACL, so I need to figure that one out, as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.