While the comments itself are not a problem, I believe some change has to be addressed here to give a better product for the user point of view.
Two things are happening:
- Each time an order is saved, stock is leaving a message of stock being decremented to the same value because the function is actually executed with qty = 0
- If you have 3 items of a product, and you then edit it to 2, the function properly add the stock, but the comment says it has been 'decreased', while it was increased.
I am submitting a patch, and this time I have changed a function name. This is the first time I've done this in such a project, but I believe the semantic of the function helps in keeping the code clean and understandable, and I guess this one won't harm. You can include the changes w/o changing the function name. If you prefer the patch w/o the function name change, let me know.
Changes include:
- Only adjust stock on order edition if the qty changed
- Change uc_stock_decrement_product_stock() for uc_stock_adjust_product_stock()
- Add a conditional !action to the log message which will be translated into 'decreased' or 'increased' depending on the value passed to this function.
- Improved the function documentation of uc_stock_adjust_product_stock()
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 651556_stock_adjust.patch | 3.83 KB | hanoii |
| #1 | 651556_order_edit_stock_enhancements.patch | 2.81 KB | hanoii |
Comments
Comment #1
hanoiiComment #2
tr commentedI don't want to eliminate uc_stock_decrement_product_stock() in Ubercart 6.x-2.x because that would break any contributed modules that use this function. Can you re-roll your patch and put uc_stock_decrement_product_stock() back in as a wrapper which just calls uc_stock_adjust_product_stock() ?
Comment #3
tr commentedTagging
Comment #4
hanoiiI'll try to reroll that patch soon. Probably tomorrow.
Comment #5
tr commentedBe aware that #690740: Messages of "stock decrement" in admin comments with no stock changes (fix included). fixed your problem "- Each time an order is saved, stock is leaving a message of stock being decremented to the same value because the function is actually executed with qty = 0", so please download the -dev version of uc_stock and make your patch against that version.
Comment #6
hanoiiIt took me a while, but here it is.
patch re-rolled with the #690740: Messages of "stock decrement" in admin comments with no stock changes (fix included). bit removed and the wrapper function.
Comment #7
tr commentedCommitted with some minor changes to the comments.