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

CommentFileSizeAuthor
uc_stock_set.patch552 bytesmikejoconnor

Comments

Island Usurper’s picture

Status: Needs review » Fixed

Thanks, Mike. Committed.

Are there any places in uc_stock where it makes more sense to use this function?

mikejoconnor’s picture

I didn't see any with a quick scan, but I will be giving it a closer look over the next few days.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

ionmedia’s picture

how can we set stock by nid, not by sku ?

ionmedia’s picture

Status: Closed (fixed) » Active
tr’s picture

Status: Active » Closed (fixed)

@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.