Rules > Send mail to product's creator? I tried to use a rule found in another topic (https://www.drupal.org/node/2050565), but it doesn't work. I want to send an automatic email to the product's creator, when the product is sold.

{ "rules_send_email_to_product_owner" : {
"LABEL" : "Send email to product owner",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules", "commerce_checkout" ],
"ON" : { "commerce_checkout_complete" : [] },
"IF" : [
  { "data_is" : {
      "data" : [ "commerce-order:commerce-line-items:0:type" ],
      "value" : "product"
    }
  }
],
"DO" : [
  { "mail" : {
      "to" : [ "commerce-order:commerce-line-items:0:commerce-product:creator:mail" ],
      "subject" : "Test mail",
      "message" : "Test mail nr 1",
      "from" : "Sender",
      "language" : [ "commerce-order:state" ]
    }
  }
]


}
}

Any help would be greatly appreciated :)
You need to debug the rule!

This is not a direct answer but can help you find the problem. And it is too long to post as a comment. You should follow these steps regardless of other similar rules working (a teeny tiny difference can be causing the rule to fail).

Required tools

Install the devel module. but NOT on production site, only on your development site. It will add an extra action to rules debug a value under devel section.


Is the rule actually triggered?

Method 1:
Add a simple action, display a message and enter a simple text. Do the required actions actually needed to fire the rule (buy a sample product). Is the message displayed or not? 
Drawback: If the message is not displayed, you wont actually know if the action is not triggered OR there is some error in rule definition, preventing the rule engine from executing it.

Method 2: Go to admin/config/workflow/rules/settings On your site, there is a checkbox to enable rules debugging. It's something like dpm() but for rules only with helpful information. Whenever a rule is triggered, all the thing happening (or failing) will show up in the debugging area. If something has failed it will be printed in red so you can easily find it.
Drawback: Can get annoying going through the rule stacktrace :|

If it's not firing:
There should be something wrong with the event/conditions you have set, Or a fatal error in the rule action definition. If the later find it with method 2 above.

Are the data you are using not null and valid?


Temporarily remove the condition commerce-order:commerce-line-items:0:type. Since you are working on development site this should not be a problem. In the actions (Important: In the beginning, as the first action) add the action debug a value. the value to debug would be "commerce-order:commerce-line-items:0:type. Go and buy the sample product, the rule should fire, and devel's debug a value would print the type. Check if it is set and is what you want it to be.
Do the same for commerce-order:commerce-line-items:0:commerce-product:creator:mail.
Do the same for "language" : [ "commerce-order:state" ] --> However this sounds fishy! why would you set the language as the state?!! You should read the language from user entity (the creator).


Have fun debugging rules!