“This is the real secret of life -- to be completely engaged with what you are doing in the here and now. And instead of calling it work, realize it is play.” ― Alan Watts

Drupal 7 - How to check when an order is complete in Ubercart programmatically

March 30, 2019

I recently had a project where I needed to create a custom module in order to update various information on the user after an order has been put through, and it took me a while of searching around to find the correct hook which would work for this. 

The function I am going to show you will only run when an order is marked as completed, in my case this was when PayPal's IPN had confirmed payment.

You will first need to create your own custom module file and info file and for this example we will call that module my_module, so replace 'my_module' with your own module name.

function my_module_uc_order($op, $order, $arg2) { 
  if ($op == 'update' && $order->order_status == 'payment_received' && $arg2 == 'completed') { 
    // ... your code goes here 

If you need to find out information from the order you can use the devel module and dsm($order), easiest way to do this would be to use hook_init which runs on every page load.

function my_module_init() {