Strange Stock Reduction Issue
-
Hi,
We have two stock locations, both set to auto allocate. Location A has 70 in stock, Location B has 64 in stock for a particular product. When the user completes the order, we log into the admin order view and we can see the location select but both locations have a quantity of 0 inputted, which appears to be that location stock was not deducated. After some digging i found out that in the source code, both locations were set with allocated_quantity = line_item_quantity. Which means it was trying to deduct from both locations, but since you have some logic which prevents that (see below) the stock is never reduced.
file: helper-slw-order-item.phpif (array_sum($locationStockMap) !== $lineItem->get_quantity()) { continue; }The offending code appears to be here:
$stockAllocation = array_merge($userStockLocation, $stockAllocation);file: class-slw-order-item.php$userStockLocation contains the user selected stock location, but then since we merge we also have $stockAllocation which has the other location. So the final
$stockAllocationcontains both locations, which results in trying to deduct from 2 locations.Any idea what is going on here? When i change the line above to just be:
$stockAllocation = $userStockLocation;it successfully deducts the correct stock from the single location.Thanks
The topic ‘Strange Stock Reduction Issue’ is closed to new replies.