1

I have a site selling edit access to specific nodes. The site uses Drupal 7, Commerce, Commerce License (selling a Role with edit permission), Rules and Flag. On the Add to Cart I have a Line Item Entity Reference where the customer selects the Node they want access to. Upon payment a 12 month license is generated and the Role with edit permissions is added to the User. That all works fine.

Here's what I need: When the payment is successful I need a Rule to trigger and set a Flag (premier_listing) on the Node that was selected during the Add to Cart process. However I can't seem to access the Node Entity in Rules or access the Line Item Entity Reference that the User selected. Anybody have an idea how this could be done? Thanks

1 Answer 1

0

I believe you'll either need to access the node ID from the line item entity using a loop within the Rules UI or what I think a simpler way would be to create a custom Rule that accomplishes the same task.

Something like: Event: order is completed. I guess you could use order paid in full. Conditions: Here is where a custom condition would come into play. You'd need to dig through the order line items to the user-selected node, and then pass that node_id to the Rules action as a parameter. Note: you could also do this entire check within the action and then programmatically set the flag to avoid passing the node_id as a parameter. Actions: Set a flag on a node. (The node parameter).

1
  • 1
    Thanks...this helped me find the solution. After much playing around I found my field in the commerce-line-items data selector. Then added the Action - Fetch entity by ID then set the flag. I was able to change node author too in the same rule..which was also required. Rules is powerful...but you need to think like a programmer (which I'm not). Commented Feb 12, 2015 at 11:21

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.