有人以前使用过嵌套 lineItems 吗?我在 docs 中找到了引用资料并且还偶然发现了一些测试,其中 lineItem 是 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());
}
此功能得到良好支持吗?例如,不可能通过管理“创建订单”界面创建嵌套的 lineItem,而且我也没有找到通过店面创建嵌套项目的方法。此功能的预期用例是什么?
最佳答案
某些扩展程序使用此功能,例如Custom Products 。在那里,它用于将可定制选项与附加费分组到可定制产品本身的保护伞下。虽然目前在普通 Shopware 中可能没有用于创建嵌套订单项的用户界面,但它仍然经过持续测试并且是官方支持的功能。
关于php - Shopware 6 中嵌套 LineItem 的用例是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72963216/