1 godzinę temu, Eutanasio napisał:The problem is not with currentStock (which is the actual real stock after a stock variation for X reason) this value is correct.
The issue is that emailAlerts module uses the function hookActionProductQuantityUpdate in which the param delta_quantity is used but has null value. As @ventura suggested, the issue was a bug in StockAvailable.php where the Hook::exec('actionUpdateQuantity' was missing this param. But despite adding it, the value keeps being null.
I also checked further the code on StockAvailable.php to see where is calculated the delta_quantity param, which I found at public static function setQuantity as:
$deltaQuantity = -1 * ((int) $stock_available->quantity - (int) $quantity);But this part of the code doesn't seem to be triggered on any of the processes (I used PS log to confirm this).
I checked StockAvailable.php and $deltaQuantity is only used inside StockAvailable::setQuantity(). To fix your problem you will need to add $deltaQuantity to StockAvailable::synchronize(). This function runs after order is validated, and this one is also executing actionhookQuantityUpdate. You can find it inside class PaymentModule-> ValidateOrder().
From what i found $deltaQuantity is only used for stockmovements made by user in BackOffice. Rest is handled by StockManager Class.