add newly created nodes to the shopping cart of Ubercart

GrandVizier - August 21, 2008 - 06:43

First I'll be clear with my overall objective, to add newly created nodes to the shopping cart of Ubercart.

I've got the workflow-ng module set up so that when a new node is created of a certain type, my custom module will be called and from there i can add the node to the shopping cart, along with the node's attached file I'm adding with my own module. However, I'm not quite sure how to add products to the cart through code using Ubercart. I was looking into the method hook_add_to_cart() in uc_cart.module, but that just seems to be used for confirmation before a product is added with the interface. My goal is to add the product in my custom module. Does any one know where I can find this out?

Hmm... it sounds like you're

rszrama - August 21, 2008 - 13:14

Hmm... it sounds like you're having fun figuring out the custom module part, and that's totally understandable. I get a kick out of development, too. ; ) However, I did recently release a module that I think does exactly what you're looking to do, though it is tied to a particular node type. I'm not sure how your nodes are setup and/or how you want to connect them to products, but if you can't use the module you can at least get good example code from it:

http://drupal.org/project/uc_node_checkout

----------------------
Drupal by Wombats | Current Drupal project: http://www.ubercart.org

almost there

GrandVizier - August 22, 2008 - 11:45

thanks - i looked through that module and it seems to have a bit more overhead then I need - I did come across the uc_cart_add_item() method and made use of that - though I then came across problems with the nodes I was creating not being products, which I thought I solved by tweaking your uc_node_checkout_product_map() method - but this leaves me with the final problem of making sure the new node/product are associated properly at checkout - I might come across the solution as my development continues, thanks

 
 

Drupal is a registered trademark of Dries Buytaert.