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()

Comments

hanoii’s picture

Status: Active » Needs review
StatusFileSize
new2.81 KB
tr’s picture

Status: Needs review » Needs work

I 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() ?

tr’s picture

Issue tags: +uc_stock

Tagging

hanoii’s picture

I'll try to reroll that patch soon. Probably tomorrow.

tr’s picture

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

hanoii’s picture

Status: Needs work » Needs review
StatusFileSize
new3.83 KB

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

tr’s picture

Status: Needs review » Fixed

Committed with some minor changes to the comments.

Status: Fixed » Closed (fixed)
Issue tags: -uc_stock

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