Has anyone worked with nested lineItems before? I found references in the docs and also stumbled upon some tests where a lineItem is a LineItemCollection:
public function testCartWithNestedLineItemHasChildren(): void
{
$cart = new Cart('test', 'test');
$cart->add(
(new LineItem('nested', 'nested'))
->setChildren(
new LineItemCollection([
(new LineItem('A', 'test'))->setGood(true),
(new LineItem('B', 'test'))->setGood(true),
])
)
);
$cart->add(
(new LineItem('flat', 'flat'))->setGood(true)
);
static::assertCount(4, $cart->getLineItems()->getFlat());
static::assertCount(2, $cart->getLineItems());
}
Is this feature well-supported? It is for example impossible to create a nested lineItem through the admin "create order" interface and I also did not find a way to create nested items through the storefront. What is the intended use case of this feature?
This feature is utilized by some extensions, e.g. Custom Products. There it's used to group customizable options with surcharges under the umbrella of the customizable product itself. While there might be no user interface for creating nested line items in vanilla Shopware currently, it is nonetheless continuously tested and an officially supported feature.