views:

64

answers:

1

Hi, I am trying to make a module that works with ubercart. What I need to know is how do I hook into the loading of a product. I want to modify some of the data slightly before any output. Thanks

+2  A: 

Use hook_nodeapi and the load view $op to add/alter data.

http://api.drupal.org/api/function/hook_nodeapi

This function is fired when a node is being loaded. What you will want to do is:

mymodule_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
   switch ($op) {
      case 'load':
        if ($node->type == 'product') {
            var_dump($node);
        }
   }
}

Try that out. That should dump the node object if the node is a product, and you can see how to add/alter data in the node object from there.

Kevin
Thanks that was a lot easier than I thought it was going to be.
Kareed

related questions