# Solved: ChildLineItems are set to quantity 0

**URL:** https://forum.shopware.com/t/solved-childlineitems-are-set-to-quantity-0/87306
**Category:** Shopware 6 (English)
**Tags:** programming
**Created:** [30. April 2021 um 12:48 UTC](https://forum.shopware.com/t/solved-childlineitems-are-set-to-quantity-0/87306 "2021-04-30T12:48:13Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![euroxid](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/euroxid/32/15105_2.png) [@euroxid](https://forum.shopware.com/u/euroxid)
#### Post date: [30. April 2021 um 12:48 UTC](https://forum.shopware.com/t/solved-childlineitems-are-set-to-quantity-0/87306/1 "2021-04-30T12:48:13Z")

</div>

There is a bug in Shopware 6, where the quantity of ChildLineItems is set to 0 if any discounts are present.

The reason is that for the discount calculation, the items are „attempted“ to be cloned in LineItem::createFromLineItem(). As ChildLineItems are objects, there are not copied but referenced.

The solution is a decorator:

```
class LineItemQuantitySplitterDecorator extends LineItemQuantitySplitter
{
public function getDecorated()
{
    return LineItemQuantitySplitter::class;
}

public function split(LineItem $item, int $quantity, SalesChannelContext $context): LineItem
{
    $item = clone($item);
    return parent::split($item, $quantity, $context);
}
}

```

This post is made in the hope that it pops up in the search of another dev - I just spent 12 hours hunting down that bug.
