通过布局XML删除UI组件子级


15

如何通过布局XML删除UI组件子级?例如,从下面的xml指令中checkout_index_index.xml。如何删除运送节点?

<item name="sidebar" xsi:type="array">
    <item name="children" xsi:type="array">
        <item name="summary" xsi:type="array">
            <item name="children" xsi:type="array">
                <item name="totals" xsi:type="array">
                    <item name="children" xsi:type="array">
                        <item name="subtotal" xsi:type="array">
                            <item name="config" xsi:type="array">
                                <item name="title" xsi:type="string" translate="true">Subtotal</item>
                            </item>
                        </item>
                        <item name="shipping" xsi:type="array">
                            <item name="config" xsi:type="array">
                                <item name="title" xsi:type="string" translate="true">Estimated Shipping</item>
                            </item>
                        </item>
                        <item name="grand-total" xsi:type="array">
                            <item name="config" xsi:type="array">
                                <item name="title" xsi:type="string" translate="true">Estimated Total</item>
                            </item>
                        </item>
                    </item>
                </item>
            </item>
        </item>
    </item>
</item>

可以使用插件来删除运输节点,但我只是认为应该有一种更好的方法,例如删除节点属性。

Answers:


23

我们可以在此处阅读该文档:http : //devdocs.magento.com/guides/v2.0/howdoi/checkout/checkout_customize.html。您的情况:我们可以应用此指南:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="checkout.root">
            <arguments>
                <argument name="jsLayout" xsi:type="array">
                    <item name="components" xsi:type="array">
                        <item name="checkout" xsi:type="array">
                            <item name="children" xsi:type="array">
                                <item name="sidebar" xsi:type="array">
                                    <item name="children" xsi:type="array">
                                        <item name="summary" xsi:type="array">
                                            <item name="children" xsi:type="array">
                                                <item name="totals" xsi:type="array">
                                                    <item name="children" xsi:type="array">
                                                        <!--Remove fields-->
                                                        <item name="subtotal" xsi:type="array">
                                                            <item name="config" xsi:type="array">
                                                                <item name="componentDisabled" xsi:type="boolean">true</item>
                                                            </item>
                                                        </item>
                                                        <item name="shipping" xsi:type="array">
                                                            <item name="config" xsi:type="array">
                                                                <item name="componentDisabled" xsi:type="boolean">true</item>
                                                            </item>
                                                        </item>
                                                        <item name="grand-total" xsi:type="array">
                                                            <item name="config" xsi:type="array">
                                                                <item name="componentDisabled" xsi:type="boolean">true</item>
                                                            </item>
                                                        </item>
                                                    </item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

结果:

在此处输入图片说明

在此处阅读更多信息:http : //devdocs.magento.com/guides/v2.1/howdoi/checkout/checkout_customize.html#disable-a-component

[编辑]

在结帐页面禁用边栏(“订单摘要”)。

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="checkout.root">
            <arguments>
                <argument name="jsLayout" xsi:type="array">
                    <item name="components" xsi:type="array">
                        <item name="checkout" xsi:type="array">
                            <item name="children" xsi:type="array">
                                <item name="sidebar" xsi:type="array">
                                    <item name="config" xsi:type="array">
                                        <item name="componentDisabled" xsi:type="boolean">true</item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

在此处输入图片说明


By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.