2

Currently if you create a product in UberCart, you have to first create the product before accessing the stock tab to set stock levels. I want to be able to set the stock levels when I create the product. I.e. Right below where I set the "list price". How would I do this?

rockstardev
  • 13,479
  • 39
  • 164
  • 296

2 Answers2

2

Well, that's going to involve a little work.

  1. You're going to have to create a hook_form_alter implementation to add the new form fields to the node_add/node_edit form.
  2. You're going to want to add a hook_nodeapi() implementation for $op=='validate' to make sure you're getting valid information.
  3. You're then going to want to extend that hook_nodeapi() implementation for $op=='insert' and 'update' to grab the field value (which should be stuck to the $node object) and write it to the stock levels table, whose name I'm too lazy to look up right now.

Alternately, instead of 2 and 3, you could mess around with creating a validation and submit function, and append them to the #validate and #submit arrays of the form.

John Fiala
  • 4,561
  • 3
  • 30
  • 26
0

For people looking for a module-based solution to this problem in Drupal 7, the latest dev version of the "Ubercart Product Power Tools" module has an excellent per-product setting to make stock-tracking active on creation, as well as set default stock quantity and threshold for the product.