开发者

Setting UberCart stock levels on content creation?

Currently if you create a product in UberCart, you have to first create the product before accessing t开发者_运维技巧he 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?


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.


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.

  • Ubercart Product Power Tools
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜