do some action when order status is changed to complete In drupal commerce I want the rules module to do some action when the order status changes to completed. In fact, after buying some product an order is added to order list. Then, what I need is that when the moderator comes and change the order status to completed the order owner get permission to see some content type.

I have tested these rules but none of them worked!!


Event: After updating an existing commerce order
Condition: Execute custom PHP code

if([commerce-order:status] == 'completed') return TRUE;
else return FALSE;



or this one:


Event: After updating an existing commerce order
Condition: Data comparison

Parameter: Data to compare: [commerce-order:status], Data value: Completed



or this one:


Event: After updating an existing commerce order
Condition: Data comparison

Parameter: Data to compare: [commerce-order:state], Data value: Completed



In fact, without adding any condition the reaction is done after adding an order by customers (do not wait for moderators to complete the order) and with any of these conditions, rules never fire and the is reaction never done.
According to the details provided by you in comments, your rule is assigning new role to the user who is currently editing the order [site:current-cart-order:owner].

You need to use [commerce-order:owner] token in "Add User Role" action.

[commerce-order:owner] represents the user who created the order, and not the user who is editing it.