小编adm*_*i22的帖子

Shopware 6 中嵌套 LineItem 的用例是什么?

有人以前使用过嵌套 lineItems 吗?我在文档中找到了参考资料,并且还偶然发现了一些测试,其中 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());
    }
Run Code Online (Sandbox Code Playgroud)

这个功能得到很好的支持吗?例如,不可能通过管理“创建订单”界面创建嵌套的 lineItem,而且我也没有找到通过店面创建嵌套项目的方法。此功能的预期用例是什么?

php e-commerce shopware shopware6

2
推荐指数
1
解决办法
410
查看次数

标签 统计

e-commerce ×1

php ×1

shopware ×1

shopware6 ×1