[Solved] Ubercart hook_order Not Working in Drupal 7?

Michael Phipps's picture

I use Ubercart's hook_order to add some additional code to record a purchase in my accounting software, however, when I upgraded to Drupal 7, hook_order stopped working. I didn't get it. The documentation at Ubercart still indicated that the hook was still there - but infact it has been changed! All of Ubercart's hooks now are namespaced. So instead of hook_order, we now have to use hook_uc_order.

Some of the information I've seen on the web is a bit unclear about what the change looks like in real life, so I'll give an example that I use. As I mentioned above, I have a module called saasu that connects to the saasu accounting web app. (I highly recommend Saasu by the way!)

In my module I used to implement hook_order like this:

//OLD CODE
function saasu_order($op, &$order, $arg2) {
// do stuff here
}

The only change I had to make to my module to make it work in Drupal 7 was use the new namespaced hook_uc_order:

//NEW CODE
function saasu_uc_order($op, &$order, $arg2){
// do stuff here
}

That's it!

I want to acknowlege Bensey's post over in the ubercart forum as the inspiration for this post.

© 2010 Your Name.. Drupal theme by Kiwi Themes.