Best Way To Hook In Custom Order Logic

Posts: 8
Joined: 04/15/2008

First off, I'm using Ubercart on a new site that's under development and just wanted to say that it's been a dream to work with. Great job, everyone!

We're nearing completion of our initial Ubercart implementation and have one last requirement to add some custom order logic whenever an order is placed that I wanted to get some advice one.

Basically, our "products" are mostly user subscriptions, so we're using the "Roles Assignment" add-on to automatically assign roles whenever these "products" are purchased, which is working out well.

However, in addition, we also need to write a database record out to a custom table that a third-party application is going to consume, and want to do this immediately after the role assignment is processed (about 10 lines of PHP). So, I'm trying to figure out the best way to add a custom hook to do this without modifying the core Ubercart modules.

One option we're considering is basically creating a custom module based on the Roles assignment module to do this, but I wanted to get some advice to see if there's a simpler way before going down this road.

Thanks in advance!

Posts: 5245
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

There are several places to hook into that you might try before copying the entire module. I'm not sure what the nature of the row is that you need to write, but you can always hook into hook_order() and work either on the submit or update $op to execute your code. For example, you might execute it when the order is detected as having been updated from an in checkout to a post checkout status. You could also try working with a custom workflow action that can be used in a workflow configuration for checkout.

Posts: 8
Joined: 04/15/2008

Thanks, Ryan, for the tips. I've been walking down the hook_order() path since my post yesterday and will continue down that road. Once again, great job with the module(s)!