Currently we have a uc_stock_adjust() function, which is used to adjust the stock levels by a set amount. We also have uc_stock_level(), which can be used to find the stock level.
If you want to change the stock level to a fixed number, rather than adjust it, you would need to a) write a db query, b), call uc_stock_level(), get the current level, and then call uc_stock_adjust() with the difference, or c) we could add uc_stock_set(), as a simple way of setting the stock.
Please see the attached patch
| Comment | File | Size | Author |
|---|---|---|---|
| uc_stock_set.patch | 552 bytes | mikejoconnor |
Comments
Comment #1
Island Usurper commentedThanks, Mike. Committed.
Are there any places in uc_stock where it makes more sense to use this function?
Comment #2
mikejoconnor commentedI didn't see any with a quick scan, but I will be giving it a closer look over the next few days.
Comment #4
ionmedia commentedhow can we set stock by nid, not by sku ?
Comment #5
ionmedia commentedComment #6
tr commented@ionmedia: Your support question is totally unrelated to this three-year old closed feature request. Product nodes have many SKUs, in general, so it doesn't make sense to set stock by nid.