Commerce order either stays as pending or grants double to customer I have 2 rules to handle orders of credits on my site.


The first rule changes the order status to Completed if the order is no longer a cart.
The second rule grants credits to the order owner using a loop.


The problem is that the credits are granted twice.


In the user's orders page, the order appears twice with the same ID. But it only appears once in the admin orders page.
If I omit the first rule and change the order status manually it works fine. In this case, it is still using the same loop. Can anyone think why this might be? Here are the rules:


{ "rules_order_paid_in_full_order_state_to_completed" : {
    "LABEL" : "Order paid in full: Order state to Completed",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "1",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "REQUIRES" : [ "commerce_cart", "commerce_order", "commerce_payment" ],
    "ON" : { "commerce_payment_order_paid_in_full" : [] },
    "IF" : [
      { "NOT commerce_order_is_cart" : { "commerce_order" : [ "commerce_order" ] } }
    ],
    "DO" : [
      { "commerce_order_update_status" : { "commerce_order" : [ "commerce_order" ], "order_status" : "completed" } }
    ]
  }
}

{ "rules_grant_credits" : {
    "LABEL" : "Grant Credits on Completion",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "Checkout", "commerce", "credits" ],
    "REQUIRES" : [ "rules", "entity" ],
    "ON" : { "commerce_order_update" : [] },
    "IF" : [
      { "data_is" : { "data" : [ "commerce-order:state" ], "value" : "completed" } }
    ],
    "DO" : [
      { "LOOP" : {
          "USING" : { "list" : [ "commerce-order:commerce-line-items" ] },
          "ITEM" : { "line_item" : "Line Item" },
          "DO" : [
            { "component_rules_grant_credits_if_product_is_credits" : { "line_item" : [ "line_item" ] } }
          ]
        }
      }
    ]
  }
}
I seem to have fixed it by changing the weight of the second rule. I made the weight 10. I'm guessing that having the weight on default (0) was causing the double triggering.