0

I am using the Drupal 7 Commerce module. I would like to execute a special code when the payment of the order is completed.

What is the difference between checkout complete and complete?

I googled and I found suggestions for these hook implementations.

First option

function mymodule_commerce_order_update($order) {
  if ($order->status == 'completed' ) {
    // ...
  }
}

Second option

function my_module_commerce_order_presave($order) {
  if ($order->status == 'completed' ) {
    // ...
  }
}

###Third option

I found some suggestions to implement hook_commerce_order_updated().

Fourth option

function mymodule_commerce_checkout_complete($order) {
  if ($order->status == 'completed' ) {
    // ...
  }
}
0

1 Answer 1

2

None of the above. You should be using hook_commerce_payment_order_paid_in_full(), which is always invoked the first time an order's balance drops to $0 or less.

Read more about it in commerce/modules/payment/commerce_payment.api.php.

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.