When products, added to the shopping cart are not fully available in stock user is presented with an option, that would split his order into two. This allows to ship immediately available products now, but non-available ones later once they arrive in stock. To track this a "PackageNum" column in the "OrderItems" table is used (each item in order would have either 1 or 2).
Then once shopping cart is processed the order associated with it is split into 2 orders (according to PackageNum column). Issue is that value in "PackageNum" column is kept as-is which may result in issue if 2nd order (that has number ending with "-001") is returned back to Incomplete status and is processed again.
Solution
In theĀ OrdersEventHandler::SplitOrder
method setĀ PackageNum
to 1 for all created sub-orders.