I find that when anonymous users are ordering something from my site I cannot send order notification messages using the "out of the box" Commerce rules. The error message that I get says that Rules is unable to create the message entity, and the apparent reason that it cannot is that the parameter that the Commerce rule provides [commerce-order:owner] does not work [???] for anonymous users.

I can and have fixed this by changing the parameter to [site:current-user], but am wondering if there is some other way to get this to work. [Like, for example, setting an order property?]


Since the user account for anonymous orders is created upon checkout completion, it may be that you just need to assign your custom rule a higher weight. It would need to execute after the other rule that creates and assigns the order owner user account to the newly completed order.

  • 1
    Thank you VERY much. I did (and do) not want to create an account for anonymous users and so have disabled that rule. Thus, I think, the behavior I'm seeing. – Wyckham Seelig May 10 '18 at 15:19
  • Ok, in that case you'd just need to edit the rule that sends the email to pull it from the [commerce-order:mail] token instead. – Ryan Szrama May 11 '18 at 18:55
  • Actually, that will not work. Here's why: both the "admin order notification" and the "order notification" rules begin by instantiating a message object, and both of those rules pass the parameter commerce-order:owner to that instantiation process. If the user is logged in, this works fine, but if the user is not logged in [i.e., anonymous] it fails. Looking at $order just before commerce_checkout_complete is invoked shows correct $order->uid properties: the user's uid if logged in and 0 if not [i.e., anonymous]. So I'm baffled. – Wyckham Seelig May 12 '18 at 18:37
  • I've done some more digging, and now have a plausible explanation for what is happening. However, I cannot fix it because it appears that rules is not invoking the token replacement code contained in commerce_orders_token.inc. I've tried clearing caches and rebuilding the registry to no avail. – Wyckham Seelig May 13 '18 at 16:47
  • I now report the following: 1) When the user creating the owner is logged in, commerce-message is able to send admin notification messages. 2) When the user is NOT logged in, and the user token in the rules action that creates the message is site:current-user, commerce-message is, again, able to send an admin notification message. 3) When the user creating the order is not logged in and the user token in the rules action that creates the message is commerce-order:owner, commerce-message is not able to send an admin notification message. More about this in next comment. – Wyckham Seelig May 20 '18 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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