0

Perhaps a noob question, but how do I change the order in which Completion Rules fire?

There is a default Reaction Rule called 'completion'. I wanted to add a 2nd Rule which executes some custom PHP but it never 'fires'.

I see no way to change the 'weight' as in other Drupal rules.

I also tried adding what I need as an Action in that default 'completion' rule, but it also doesn't seem to fire.

Here is the reaction rule that fires on order 'completion'

` { "rules_completion" : { "LABEL" : "completion", "PLUGIN" : "reaction rule", "REQUIRES" : [ "php", "rules", "commerce_checkout" ], "ON" : [ "commerce_checkout_complete" ], "DO" : [ { "php_eval" : { "code" : "jch_send_quote()" } }, { "commerce_checkout_complete" : { "commerce_order" : [ "commerce_order" ] } } ] }

`

And here is the php code for jch_send_quote() which doesn't seem to fire:

function jch_send_quote(){ global $user; watchdog('dev', 'jch_send_quote running here'); drupal_set_message($user->uid); die('jch_send_quote running here') }

What am I missing?

  • Added Rule and php to question. Any ideas? – jchwebdev Jun 10 '14 at 16:36
0

You should be able to edit the rule and set it's weight:

Set weight of reaction rule

Screenshot, showing reaction rule with weight of "2"

Lastly, your rule should still fire, even with a different weight. If it's not firing, it's probably an issue with that rule itself.

  • First, I can change the Weight inside the Reaction Rule edit form, but when I save and return to the Rules View, every Rule appears with a Weight of 0... at least those in 'Completion' for Commerce. Second, I -thought- that all the Reaction Rules should fire. I simply added a die() message and it never 'dies' or displays. Is there a fool-proof way to see if/when my code is firing? I'm on a shared host without Devel. Thanks again. ---JC – jchwebdev Jun 10 '14 at 3:26
  • The weight should save and be non-zero if set as such. If that's not the case, something else is broken there. In regards to debug, you could try watchdog. e.g watchdog('dev', 'code running here'); then check in admin > reports > recent log entries – David Thomas Jun 10 '14 at 3:29
  • Thanks. I tried watchdog() and nothing is appearing in the recent log entries. Any other ideas on what could be going on? – jchwebdev Jun 10 '14 at 4:45
  • You would need to post your code / rule and relevant conf there, else is just guesswork. – David Thomas Jun 10 '14 at 5:44
  • I added code and rule above. Although I think now this is a conceptual issue. The completion rule is -never- firing... which I don't understand. Can you recommend a tutorial or doc which explains this process? – jchwebdev Jun 10 '14 at 18:00

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.