I recently ran into a problem while developing a product discounts function. The function should apply discounts to a certain quantity of a product variant, which may result in a line item split. In the cart this works fine, but in the checkout I get unnessecary additional line items displayed. Expected are two lines - one with a discount and one without a discount, but in checkout there is a third line - also not discounted. The total quantity is still correct, but an additional line split happens. As far as I could see, this happens if and only if the non-discounted line appears before the discounted line in cart.
The function run result only allows targeting a product variant and not specific lines, so I do not see room for changes in the function here. That is why it seems like a bug to me. I appreciate any help on this.