1

After the order is paid in full (or not checkout is complete if there is no payment required and I ever get that working) I need to do a bunch of processing to set up the product the user has just bought. Only once that is done can I say the order is complete and I thought this would do it

commerce_order_status_update($order, 'completed');

But it doesn't change the order status. They are always left as Pending.

How do I programmatically change an order status from pending to completed?

1 Answer 1

3

It sounds to me like you're updating the order to completed before the checkout completion rule fires that updates the order to pending. You can confirm this by looking in your revision log for the order in question.

If I were you, I'd just add a condition to that default checkout completion rule to not update the order status if it is already completed.

2
  • That works well for the No Payment method but after I set the status in the paid_in_full hook the system changes it to Checkout: Complete and then Pending. I could add another condition to not make it Checkout: Complete if the order is already complete but I feel I am blocking too much of the intended flow. Is there a hook that is called when the order is set to Pending, and should I be doing my post-processing in there?
    – Craig
    Commented Jan 12, 2014 at 20:07
  • 1
    I changed my hook_commerce_checkout_complete function to use these two lines to trigger the post processing, rather than doing it in paid_in_full $orderRemainingBalance = commerce_payment_order_balance($order); if ($orderRemainingBalance['amount'] == 0)……
    – Craig
    Commented Jan 12, 2014 at 22:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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