Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need help with drupal, ubercart and a module hook on product load

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

like image 793
Kareed Avatar asked Dec 15 '25 11:12

Kareed


1 Answers

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.

like image 73
Kevin Avatar answered Dec 17 '25 01:12

Kevin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!