What I'm trying to do is to allow people to buy roles on our site. Most of these will be anonymous users who do not have accounts on our site. I've followed the directions from a post here: http://www.drupalcommerce.org/node/381#comment-1624

Here's how I did it:

I created a new Rule called "Assign [Role Name]"

I added two events: 1. Completing the checkout process and 2. When an order is first paid in full

I added a condition: Order contains a particular product, Parameter: Order: [commerce_order], Product SKU: [productsku]

I added an action: Add user role, Parameter: User: [site:current-user], Roles: [Role Name]

The user gets an error after they have completed the checkout, and they do not receive the role. Here's the error:

Notice: Trying to get property of non-object in rules_action_user_add_role() (line 45 of /Applications/MAMP/htdocs/solar7/sites/all/modules/rules/modules/user.eval.inc).

However, if the user DOES have an account, they are given the role just fine. So it's clearly some problem with anonymous users. Either that, or I have not set up my rules correctly.

Comments

trevorkjorlien’s picture

Component: Rules Core » Rules Engine
Status: Active » Closed (duplicate)

Posted to Drupal Commerce issues: http://drupal.org/node/1266968